summaryrefslogtreecommitdiff
path: root/imdb-lookup
diff options
context:
space:
mode:
authorThomas Keck <thomas@thinkpad>2014-11-15 23:21:07 +0100
committerThomas Keck <thomas@thinkpad>2014-11-15 23:21:07 +0100
commit578e4c5a98c7178431e2ff641203c81882a4a444 (patch)
tree4f5829a395880079cd77d2ab50ca8c6a2ebf490b /imdb-lookup
parentece9d3b2ed629f384e5b4605f840bb1aebaf071c (diff)
downloadscripts-578e4c5a98c7178431e2ff641203c81882a4a444.tar.gz
scripts-578e4c5a98c7178431e2ff641203c81882a4a444.zip
dateiname als parameter
Diffstat (limited to 'imdb-lookup')
-rwxr-xr-ximdb-lookup/imdbrating.py21
1 files changed, 15 insertions, 6 deletions
diff --git a/imdb-lookup/imdbrating.py b/imdb-lookup/imdbrating.py
index 662b8d9..ff0550b 100755
--- a/imdb-lookup/imdbrating.py
+++ b/imdb-lookup/imdbrating.py
@@ -39,13 +39,22 @@ def get_rating(imdb_id):
return info['movie_results'][0]['vote_average']
return 0
+def print_ratings(files, db):
+ for filename in files:
+ if os.path.basename(filename).startswith('.'):
+ continue
+ elif os.path.isdir(filename):
+ print_ratings(map(lambda p: os.path.join(filename, p), os.listdir(filename)), db)
+ imdb_id = os.path.basename(filename).split('#')[-1]
+ if imdb_id.startswith('tt'):
+ if imdb_id not in db.keys() or db[imdb_id] == 0:
+ db[imdb_id] = str(get_rating(imdb_id))
+ print u"{rating} {filename}".format(rating=db[imdb_id], filename=filename.decode('utf-8'))
+
if __name__ == u"__main__":
tmdb.API_KEY = read_key()
db = dbm.open(get_db_filename(), 'rw')
-
- for filename in sys.argv[1:]:
- imdb_id = filename.split('#')[-1]
- if imdb_id not in db.keys() or db[imdb_id] == 0:
- db[imdb_id] = str(get_rating(imdb_id))
- print u"{rating} {filename}".format(rating=db[imdb_id], filename=filename.decode('utf-8'))
+ files = sum([os.listdir(x) if os.path.isdir(x) else [x] for x in sys.argv[1:]],[])
+ print_ratings(files, db)
db.close()
+