failed images can have with/height of None
This commit is contained in:
parent
e5dd8aaab7
commit
1348916ba1
1 changed files with 11 additions and 0 deletions
|
@ -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:
|
if p.site not in posters:
|
||||||
posters[p.site] = []
|
posters[p.site] = []
|
||||||
poster = p.get()
|
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:
|
if poster:
|
||||||
pjson = {}
|
pjson = {}
|
||||||
pjson['url'] = url_prefix + poster._get_url()
|
pjson['url'] = url_prefix + poster._get_url()
|
||||||
|
@ -101,9 +107,14 @@ class PosterCache(models.Model):
|
||||||
self.failed = True
|
self.failed = True
|
||||||
self.save()
|
self.save()
|
||||||
if self.image:
|
if self.image:
|
||||||
|
failed = False
|
||||||
try:
|
try:
|
||||||
self.image.width
|
self.image.width
|
||||||
|
if not self.image.width or not self.image.width:
|
||||||
|
failed = True
|
||||||
except:
|
except:
|
||||||
|
failed = True
|
||||||
|
if failed:
|
||||||
self.failed = True
|
self.failed = True
|
||||||
self.status = "invalid image"
|
self.status = "invalid image"
|
||||||
self.image.delete()
|
self.image.delete()
|
||||||
|
|
Loading…
Reference in a new issue