summaryrefslogtreecommitdiff
path: root/imdb-lookup/imdbinfo.py
diff options
context:
space:
mode:
authorYves Fischer <yvesf-git@xapek.org>2014-11-22 17:11:58 +0100
committerYves Fischer <yvesf-git@xapek.org>2014-11-22 17:11:58 +0100
commit835f7491ed7a99f5e4feee474db1aff893751056 (patch)
tree8a9d94ff21b66593c4b22620ba7f8e009e2a068b /imdb-lookup/imdbinfo.py
parentb81bbd0718e7a5b9cd50a3b7465dd9a1b6c523cb (diff)
downloadscripts-835f7491ed7a99f5e4feee474db1aff893751056.tar.gz
scripts-835f7491ed7a99f5e4feee474db1aff893751056.zip
logging
Diffstat (limited to 'imdb-lookup/imdbinfo.py')
-rwxr-xr-ximdb-lookup/imdbinfo.py7
1 files changed, 3 insertions, 4 deletions
diff --git a/imdb-lookup/imdbinfo.py b/imdb-lookup/imdbinfo.py
index 70d2790..bb720ef 100755
--- a/imdb-lookup/imdbinfo.py
+++ b/imdb-lookup/imdbinfo.py
@@ -36,6 +36,7 @@ class TMDBCache(object):
def __enter__(self):
self.db = dbm.open(self._get_db_filename("tmdbmovie.dbm"),"c")
self.db_images = dbm.open(self._get_db_filename("tmdbposter.dbm"), "c")
+ self.logger = logging.getLogger(self.__class__.__module__ + "." + self.__class__.__name__)
return self
def __exit__(self, type, value, traceback):
@@ -51,14 +52,13 @@ class TMDBCache(object):
def _cache(self, key, callable_func):
if key not in self.db:
- logging.info("Load value for key %s", key)
self.db[key] = json.dumps(callable_func())
d = self.db[key].decode('utf-8')
return json.loads(d)
def infos(self, movie_id):
try:
- logging.debug("movie %s", movie_id)
+ self.logger.debug("movie %s", movie_id)
return self._cache(movie_id + "movies.info", tmdb.Movies(movie_id).info)
except Exception as e:
raise Exception("Failed to query movie with id {id}: {reason}".format(id=movie_id, reason=str(e)))
@@ -84,12 +84,11 @@ class TMDBCache(object):
del self.db[key]
def poster(self, poster_path, format="w185"):
- logging.debug("poster %s", poster_path)
+ self.logger.debug("poster %s", poster_path)
key = "poster_{}_{}".format(format, poster_path)
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:
- logging.info("Load poster %s", url)
r = requests.get(url)
self.db_images[key] = r.content
self.db_images[keyContentType] = r.headers['content-type']