LAPINPT

IMDb from MKVs

Aug 15th, 2013
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.75 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. # to use with WinSCP
  4. # screen -d -m imdb !&
  5.  
  6. for f in "$@"; do
  7.    SOURCE=$f
  8.    if [ "${SOURCE##*.}" = "mkv" ]; then
  9.  
  10.       # get name from file #
  11.       MOVIENAME=$(echo $SOURCE | tr -s '.' ' ' | sed -e 's/\(.*\)\([0-9][0-9][0-9][0-9]\)\( .*$\)/\1\2/')
  12.  
  13.       # get IMDb ID from duckduckgo #
  14.       IMDbID=$(lynx -dump -nonumbers -nolist "https://duckduckgo.com/?q=$MOVIENAME imdb" | sed -n '/imdb.com/{p;q;}' | cut -d "/" -f3)
  15.  
  16.       # Scrape IMDb with OMDb API #
  17.       curl http://www.omdbapi.com/?i=$IMDbID | sed 's/\",\"/\n/g' | sed 's/\":\"/: /g' | sed 's/{\"//g' | sed -nr '/Title:|Year:|Genre:|imdbRating:|imdbVotes:|Actors:|Director:/p' >> "imdb.nfo"
  18.       echo -e "URL: www.imdb.com/title/$IMDbID\n\n" >> "imdb.nfo"
  19.  
  20.    fi  
  21. done
Advertisement
Add Comment
Please, Sign In to add comment