diff options
Diffstat (limited to 'imdb-lookup/imdbinfo.py')
-rwxr-xr-x | imdb-lookup/imdbinfo.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/imdb-lookup/imdbinfo.py b/imdb-lookup/imdbinfo.py index 5c88fc1..eeea947 100755 --- a/imdb-lookup/imdbinfo.py +++ b/imdb-lookup/imdbinfo.py @@ -167,6 +167,18 @@ class TMDBCache(object): key = "imdb_maindetails_{}".format(movie_id) return self._cache(key, do_request) + def omdb_movie(self, movie_id): + def do_request(): + BASE_URI="http://www.omdbapi.com/" + params={'i':movie_id, 'plot':'short', 'r':'json', 'tomatoes':'true'} + r = requests.get(BASE_URI, params=params) + assert r.status_code == 200, "Request must return status-code 200" + data = json.loads(r.text) + assert data is not None and data['Response'] == 'True', "Data must not be empty" + return data + key = "omdb_{}".format(movie_id) + return self._cache(key, do_request) + def weight_rating(infos): """ add 'rating' to all infos""" |