poster update

This commit is contained in:
j 2011-10-24 22:04:14 +02:00
parent bb33e8b277
commit ea6092e35f

View file

@ -267,7 +267,7 @@ class Item(models.Model):
q[0].merge_with(self, save=False) q[0].merge_with(self, save=False)
else: else:
self.oxdbId = oxdbId self.oxdbId = oxdbId
self.make_local_poster() self.make_poster(True)
#id changed, what about existing item with new id? #id changed, what about existing item with new id?
if settings.USE_IMDB and len(self.itemId) != 7 and self.oxdbId != self.itemId: if settings.USE_IMDB and len(self.itemId) != 7 and self.oxdbId != self.itemId:
@ -872,7 +872,6 @@ class Item(models.Model):
self.data['color'] = ox.image.getHSL(color) self.data['color'] = ox.image.getHSL(color)
#extract.timeline_strip(self, self.data['cuts'], stream.info, self.timeline_prefix[:-8]) #extract.timeline_strip(self, self.data['cuts'], stream.info, self.timeline_prefix[:-8])
self.select_frame() self.select_frame()
self.make_local_poster()
self.make_poster() self.make_poster()
self.make_icon() self.make_icon()
if settings.CONFIG['video']['download']: if settings.CONFIG['video']['download']:
@ -911,6 +910,7 @@ class Item(models.Model):
def make_poster(self, force=False): def make_poster(self, force=False):
if not self.poster or force: if not self.poster or force:
url = self.prefered_poster_url() url = self.prefered_poster_url()
poster = self.make_siteposter()
if url: if url:
data = ox.net.readUrl(url) data = ox.net.readUrl(url)
self.delete_poster() self.delete_poster()
@ -918,11 +918,10 @@ class Item(models.Model):
self.save() self.save()
else: else:
self.delete_poster() self.delete_poster()
poster = self.make_local_poster()
with open(poster) as f: with open(poster) as f:
self.poster.save('poster.jpg', ContentFile(f.read())) self.poster.save('poster.jpg', ContentFile(f.read()))
def make_local_poster(self): def make_siteposter(self):
poster = self.path('siteposter.jpg') poster = self.path('siteposter.jpg')
poster = os.path.abspath(os.path.join(settings.MEDIA_ROOT, poster)) poster = os.path.abspath(os.path.join(settings.MEDIA_ROOT, poster))