From 818bd098b2d40914001d21c6d4adfe0f8ff9638c Mon Sep 17 00:00:00 2001 From: Yves Fischer Date: Thu, 4 Dec 2014 22:04:49 +0100 Subject: more data! --- imdb-lookup/imdbinfo.py | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) (limited to 'imdb-lookup') 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: -- cgit v1.2.1