fix posters

This commit is contained in:
j 2016-09-07 15:32:37 +02:00
parent 7991849d44
commit b5a88e0a7e

View file

@ -86,9 +86,9 @@ class PosterCache(models.Model):
name = hashlib.sha1(url).hexdigest()
try:
data = ox.net.read_url(url)
self.image.name = poster_path(self.url, os.path.basename(url))
self.image.name = poster_path(self.url, os.path.basename(self.url))
ox.makedirs(os.path.dirname(self.image.path))
with open(self.image.path, 'w') as f:
with open(self.image.path, 'wb') as f:
f.write(data)
self.save()
except urllib.error.HTTPError as e:
@ -135,7 +135,6 @@ def get_poster_urls(m):
poster = ox.web.imdb.get_movie_poster(m.imdb_id)
if poster:
addPoster(poster, 'imdb.com', m.imdb_id)
#site is sometimes down
#for poster in ox.web.movieposterdb.get_data(m.imdb_id)['posters']:
# addPoster(poster, 'movieposterdb.com', m.imdb_id)
@ -171,4 +170,3 @@ def get_poster_urls(m):
addPoster(data['poster'], 'apple.com', m.imdb_id)
'''
#fixme: get 0xdb still, possibly imdb still as fallback?