failed images can have with/height of None

This commit is contained in:
j 2016-04-23 14:52:52 +02:00
parent e5dd8aaab7
commit 1348916ba1
1 changed files with 11 additions and 0 deletions

View File

@ -29,6 +29,12 @@ def getPosters(movie_id, url_prefix='', limit=lambda x, y: 0.3 < x/y < 1):
if p.site not in posters:
posters[p.site] = []
poster = p.get()
if poster and not poster.width or not poster.height:
p.failed = True
p.status = "invalid image"
p.image.delete()
p.save()
poster = None
if poster:
pjson = {}
pjson['url'] = url_prefix + poster._get_url()
@ -101,9 +107,14 @@ class PosterCache(models.Model):
self.failed = True
self.save()
if self.image:
failed = False
try:
self.image.width
if not self.image.width or not self.image.width:
failed = True
except:
failed = True
if failed:
self.failed = True
self.status = "invalid image"
self.image.delete()