Sometimes you want to rename your movies on disk according to a fixed naming scheme. The following script searches the open movie database for your flick and then renames it as <movie title>(<year>).iso and also saves the cover picture for it.
The Script
#!/bin/sh
# Queries open movie database and renames iso files according "( ).iso" format.
# It also saves an xml file with movie information and downloads the cover picture.
# Copyright 2011 by Reiner Rottmann. Released under the BSD License.
apikey=dbaaa04ad5583f2****************
url=http://api.themoviedb.org/2.1/Movie.search/en/xml/
for movie in *.iso
do
query=`echo $movie| sed 's#^[0-9]*-##g'|tr "-" "+"|sed 's#.iso##g'`
[ -e "$movie".xml ] || curl -s $url$apikey/"$query" > "$movie".xml
title=`cat "$movie.xml"|grep -o ".* "|head -n1|grep -o ">.*<"|tr -d "<>"|tr "'" "-"`
year=`cat "$movie.xml"|grep "released>"|head -n1|cut -d"-" -f1|sed "s#.*>##g"`
imageurl=`cat "$movie.xml"|grep poster|head -n1|grep -o "http://.*jpg"`
if [ -z "$title" ]
then
continue
fi
if [ -z "$year" ]
then
continue
fi
target="$title ($year)"
[ -e "$target.iso" ] || echo mv \"$movie\" \"$target.iso\"
[ -e "$target.xml" ] || echo mv \"$movie.xml\" \"$target.xml\"
[ -e "$target.jpg" ] || echo wget -O \"$target.jpg\" $imageurl
done
| < Prev | Next > |
|---|