diff options
author | Yves Fischer <yvesf-git@xapek.org> | 2014-11-22 16:34:08 +0100 |
---|---|---|
committer | Yves Fischer <yvesf-git@xapek.org> | 2014-11-22 16:34:08 +0100 |
commit | 808bd6e9cb9e07e2ae1d1f116b6b540e36bd64bc (patch) | |
tree | 03efd3c2d4f3f536731d12428da50123e73da256 /imdb-lookup/imdbinfo.py | |
parent | 01c94a1d87c0874a45c4b80bfb9e6a86cbbbcb82 (diff) | |
download | scripts-808bd6e9cb9e07e2ae1d1f116b6b540e36bd64bc.tar.gz scripts-808bd6e9cb9e07e2ae1d1f116b6b540e36bd64bc.zip |
handle no poster
Diffstat (limited to 'imdb-lookup/imdbinfo.py')
-rwxr-xr-x | imdb-lookup/imdbinfo.py | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/imdb-lookup/imdbinfo.py b/imdb-lookup/imdbinfo.py index 196b6ad..f5efe17 100755 --- a/imdb-lookup/imdbinfo.py +++ b/imdb-lookup/imdbinfo.py @@ -85,13 +85,18 @@ class TMDBCache(object): keyContentType = "poster_{}_{}_content_type".format(format, poster_path) url = "http://image.tmdb.org/t/p/{}/{}".format(format, poster_path) if key not in self.db_images: - r = requests.get(url) - self.db_images[key] = r.content - self.db_images[keyContentType] = r.headers['content-type'] + try: + r = requests.get(url) + self.db_images[key] = r.content + self.db_images[keyContentType] = r.headers['content-type'] + except: + return None return (self.db_images[keyContentType], self.db_images[key]) def poster_base64(self, poster_path, format="w185"): - contentType, data = self.poster(poster_path, format) + p = self.poster(poster_path, format) + if not p: return None + contentType, data = p data64 = "".join(map(lambda c: isinstance(c,int) and chr(c) or c, filter(lambda c: c!='\n', base64.encodestring(data)))) return "data:{};base64,{}".format(contentType, data64) |