summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-ximdb-lookup/imdbinfo.py22
1 files changed, 17 insertions, 5 deletions
diff --git a/imdb-lookup/imdbinfo.py b/imdb-lookup/imdbinfo.py
index e4e2aab..8521e98 100755
--- a/imdb-lookup/imdbinfo.py
+++ b/imdb-lookup/imdbinfo.py
@@ -201,13 +201,25 @@ def do_aka(args, imdb_ids):
print(tmdbcache.alternative_title(imdb_id, locale=args.lang))
def do_data(args, imdb_ids):
+ def print_data(data, io, indent=0):
+ if isinstance(data, dict):
+ for (key, val) in data.items():
+ if val is None:
+ continue
+ else:
+ io.write("\n{}{}: ".format(indent*" ", key))
+ print_data(val, io, indent+1)
+ elif isinstance(data, list) and len(data)>0:
+ for val in data:
+ print_data(val, io, indent+2)
+ elif type(data) in (bool,str,int,float):
+ io.write(str(data))
+
with TMDBCache() as tmdbcache:
for (filename, imdb_id) in imdb_ids:
- selected_properties = ["imdb_id", "revenue", "vote_average", "vote_count", "runtime", "budget", "vote_avarage", "release_date", "popularity", ]
- kv = map(lambda kv: "{}={}".format(*kv),
- filter(lambda kv: kv[0] in selected_properties,
- tmdbcache.infos(imdb_id).items()))
- print(" ".join(kv))
+ print_data({
+ "TMDB" : tmdbcache.infos(imdb_id),
+ "IMDB" : tmdbcache.imdb_movie(imdb_id)}, sys.stdout)
def do_year(args, imdb_ids):
with TMDBCache() as tmdbcache: