Created
September 7, 2011 00:37
-
-
Save bmaeser/1199425 to your computer and use it in GitHub Desktop.
good movies list with bash, awk and imdb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
MIN_RATING=7 | |
MIN_VOTES=50000 | |
usage="usage: imdb-ratings.sh -r MIN_RATING -v MIN_VOTES" | |
while getopts "r:v:h" options; do | |
case $options in | |
h ) echo $usage | |
exit 0 | |
;; | |
r ) MIN_RATING=$OPTARG | |
;; | |
v ) MIN_VOTES=$OPTARG | |
;; | |
\? ) echo "you are doing it wrong :-(" | |
echo $usage | |
exit 0 | |
;; | |
esac | |
done | |
if [ ! -f ./ratings.list ]; then | |
# get the latest ratings-list from imdb | |
# more mirrors at http://www.imdb.com/interfaces#plain | |
wget ftp://ftp.fu-berlin.de/pub/misc/movies/database/ratings.list.gz | |
gunzip ratings.list.gz | |
fi | |
awk -v r=$MIN_RATING -v v=$MIN_VOTES '$3>=r && $2>=v && $2~/[0-9]+/ && $3~/[0-9]+/ && $NF!="(VG)" && $NF!="(V)" {print $0 } ' ratings.list |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
usage: | |
$ ./imdb.sh -r MINIMUM_RATING -v MINIMUM_VOTES | |
where both parameters are optional and default to: | |
-r 7 | |
-v 50000 | |
$ ./imdb.sh -r 9.2 -v 100000 | |
will give you: | |
0000000125 785610 9.2 The Shawshank Redemption (1994) | |
0000000125 582037 9.2 The Godfather (1972) | |
0000000017 105243 9.6 "Band of Brothers" (2001) | |
0000000016 178326 9.4 "Game of Thrones" (2011) | |
0000000125 582037 9.2 The Godfather (1972) | |
0000000125 785610 9.2 The Shawshank Redemption (1994) | |
(Top 250 movies are listed twice) | |
only the 2011 movies? no problem, grep is your friend: | |
$ ./imdb.sh -r 9.2 -v 100000 | grep 2011 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment