rendered paste body#!/bin/sh
# Copyright (c) 2008 gh00p
if [ ! -s "$1" ]; then
echo "ERROR: I need a file name."
exit 1
elif ! which ffmpeg >/dev/null 2>/dev/null; then
echo "ERROR: ffmpeg isn't on my path."
exit 1
elif ! which mplayer >/dev/null 2>/dev/null; then
echo "ERROR: mplayer isn't on my path."
exit 1
fi
file="$1"
shift
if [ -n "$*" ]; then
title="`echo \"$*\" | sed 's/ /+/g'`"
else
title=""
fi
tmpfile=/tmp/`basename $0`.$$
trap "rm -f $tmpfile" 0 1 2 3 5 15
mplayer -endpos 0.1 "$file" > $tmpfile 2>&1
ffmpeg -i "$file" /dev/null >> $tmpfile 2>&1
duration=`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,$$`
fi
fi
cat <<-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: $plotoutline
EOT