IMDB Search

By zenx on Jun 05, 2011

IMDB search


search="`echo $@ |sed 's/ /+/g'`"
wget "$search" -qO "$wgeturl"
tt="`cat "$wgeturl" |grep -m1 -oE "tt[0-9]{7}" |grep -m1 -E "(.*)"`"
rm "$wgeturl"
wget "$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 "$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


Sign in to comment.
zenx   -  Jul 23, 2011

Here's a snippet to download the poster from imdb (large)


search="echo $@ |sed 's/ /+/g'" ; ttlink="curl -s "$search" |grep -oiEm1 "\/title\/tt[0-9]+\/" |grep -m1 tt" ; imagelink="`curl -s "$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]\/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

Hawkee   -  Jun 06, 2011

@zenx Why not add it to the snippet?

zenx   -  Jun 06, 2011

@xbox_gamer1: This isnt mirc and i'm sure everyone knows how to execute this script.
@hawkee: grep -m1 -oE "<span class=\"rating-rating\">(.*)\/10<\/span><\/span>"

Wader   -  Jun 05, 2011

xbox_gamer1 why would you need to close a brace that isnt opened? there is only 1 set of braces and thats on line 6 in the regex pattern.

Also there is only 1 way to execute this script, as with most bash scripts.

xbox_gamer1   -  Jun 05, 2011

at that last line add this:


and in the Description put in how to use this script

Hawkee   -  Jun 05, 2011

Pretty neat, but it doesn't convert HTML special chars back to their ascii equivalents. It'd also be nice to have the average score show up.

Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.