IMDB search
#!/bin/bash
wgeturl="`date`.html"
search="`echo $@ |sed 's/ /+/g'`"
wget "http://www.imdb.com/find?s=all&q=$search" -qO "$wgeturl"
tt="`cat "$wgeturl" |grep -m1 -oE "tt[0-9]{7}" |grep -m1 -E "(.*)"`"
rm "$wgeturl"
wget "http://www.imdb.com/title/$tt/" -qO "$tt.html"
title="`cat $tt.html |pcregrep -oMi "<title>(.*)</title>" |sed 's/<title>//g' |sed 's/<\/title>//g' | tr -d '\n' |sed 's/ - IMDb//' |sed 's/\ / /'`"
plot="`cat $tt.html |grep -E "<p>(.*)" -m 2 |sed 's/<p>//g' |tr -d '\n'`"
genre="`cat $tt.html |grep -oE '\/genre\/[a-zA-Z]+\"' |cut -d '/' -f3 |sed 's/\"$/ /' |sort |uniq |tr -d '\n'`"
language="`cat $tt.html |grep '\/language\/' |cut -d '>' -f2 |sed 's/<\/a//'`"
country="`cat $tt.html |grep '\/country\/' |cut -d '>' -f2 |sed 's/<\/a//'`"
keyword="`cat $tt.html |grep '\/keyword\/' |sed 's/<[^>]*>//g' |sed 's/\ / /'`"
rm "$tt.html"
if [[ "$tt" != "" ]]; then echo "http://www.imdb.com/title/$tt" ;fi
if [[ "$title" != "" ]]; then echo "Title: $title" ;fi
if [[ "$keyword" != "" ]]; then echo "Keyword: $keyword" ;fi
if [[ "$plot" != "" ]]; then echo "Plot: $plot" ;fi
if [[ "$genre" != "" ]]; then echo "Genre(s): $genre" ;fi
if [[ "$language" != "" ]]; then echo "Language: $language" ;fi
if [[ "$country" != "" ]]; then echo "Country: $country" ;fi
Here's a snippet to download the poster from imdb (large)
search="echo $@ |sed 's/ /+/g'
" ; ttlink="curl -s "http://www.imdb.com/find?s=all&q=$search" |grep -oiEm1 "\/title\/tt[0-9]+\/" |grep -m1 tt
" ; imagelink="http://www.imdb.com`curl -s "http://www.imdb.com$ttlink" |grep -oE -m1 \/media\/[a-zA-Z0-9]+\/tt[0-9]+" ; image=
curl -s "$imagelink" |grep -E "<img id=\"primary-img\"" |grep -oE "http\:\/\/[a-zA-Z]+.media-imdb.com\/images\/[a-zA-Z0-9]+\/[_.a-zA-Z0-9@,]+.jpg"; md5=
echo "$ttlink" |cut -d '/' -f3 |md5sum |cut -d ' ' -f1` ; if [ -f "cache/$md5.jpg" ]; then echo "$md5.jpg - löytyy" ; else wget -qO "cache/$md5.jpg" "$image" ; echo "$md5.jpg - tallennettu" ;fi