All pastes #986530 Raw Edit

glean.sh

public shellscript v1 · immutable
·published 2008-04-15 21:31 UTC
rendered paste body
#!/bin/sh# Copyright (c) 2008 gh00pif [ ! -s "$1" ]; then	echo "ERROR: I need a file name."	exit 1elif ! which ffmpeg >/dev/null 2>/dev/null; then	echo "ERROR: ffmpeg isn't on my path."	exit 1elif ! which mplayer >/dev/null 2>/dev/null; then	echo "ERROR: mplayer isn't on my path."	exit 1fifile="$1"shiftif [ -n "$*" ]; then	title="`echo \"$*\" | sed 's/ /+/g'`"else	title=""fitmpfile=/tmp/`basename $0`.$$trap "rm -f $tmpfile" 0 1 2 3 5 15mplayer -endpos 0.1 "$file" >  $tmpfile 2>&1ffmpeg -i "$file" /dev/null >> $tmpfile 2>&1duration=`awk '$1=="Duration:" {sub(/,/,"",$2); print $2}' $tmpfile`res=`awk '$1=="VIDEO:" {print $3}' $tmpfile`aspect=`awk '$1=="Movie-Aspect" {print $3}' $tmpfile`fps=`awk '$1=="VIDEO:" {printf("%.2f", $5)}' $tmpfile`vbitrate=`sed -ne '/^VIDEO:/s/.*fps *//p' $tmpfile`vcodec=`awk '$1=="VIDEO:" {print $2}' $tmpfile`audio=`sed -ne '/^ *Stream.*Audio: [^,]*, /s///p' $tmpfile`acodec=`sed -ne '/^ *Stream.*Audio: \([^,]*\).*/s//\1/p' $tmpfile`releasedate="?"imdblink="?"imdbrating="?"plotoutline=""if [ -n "$title" ]; then	url="http://www.imdb.com/find?s=all&q=$title"	imdbpath=`curl -sD/dev/null "$url" | awk '/Titles..Exact Matches/ { sub(/.*<a href="/, ""); sub(/".*/, ""); print; nextfile; }'`	if [ -n "$imdbpath" ]; then		imdblink="http://www.imdb.com$imdbpath"		trap "rm -f /tmp/glean,$$" 0 1 2 5 15		curl -sD/dev/null "$imdblink" > /tmp/glean,$$		releasedate=`awk '/Release Date:/ {getline; gsub(/<[^>]+>/, ""); print; nextfile; }' /tmp/glean,$$`		imdbrating=`awk '/User Rating:/ {getline; gsub(/<[^>]+>/, ""); print; nextfile; }' /tmp/glean,$$`		plotoutline=`awk '/Plot Outline:/ {getline; sub(/<.*/, ""); print; nextfile; }' /tmp/glean,$$`	fificat <<-EOT	Release Name:	${file%.avi}	Release Date:	$releasedate	Size:		`ls -lh "$file" | awk '{print $5}'`B	Source:		?	Method:		?	Play Time:	$duration	Resolution:	$res${aspect:+ ($aspect)}	Frame Rate:	$fps	Video Bitrate:	$vbitrate	Video Codec:	$vcodec	Audio:		$audio	Audio Codec:	$acodec	IMDB:		$imdblink	IMDB rating:	$imdbrating	Plot outline:	$plotoutlineEOT