always create a local poster

This commit is contained in:
j 2011-04-05 14:56:02 +02:00
parent b34add3f99
commit 2faa1e28e0
2 changed files with 36 additions and 24 deletions

View file

@ -631,6 +631,9 @@ class Item(models.Model):
elif not os.path.exists(os.path.dirname(stream.video.path)): elif not os.path.exists(os.path.dirname(stream.video.path)):
os.makedirs(os.path.dirname(stream.video.path)) os.makedirs(os.path.dirname(stream.video.path))
if len(files.values()) > 1: if len(files.values()) > 1:
if len(files.values()) > 4:
print "FIXME: to many files for this item, not merging entire tv shows"
return
for f in sorted(files): for f in sorted(files):
cmd.append('+') cmd.append('+')
cmd.append(files[f]) cmd.append(files[f])
@ -724,6 +727,9 @@ class Item(models.Model):
timeline = self.path('timeline.64.png') timeline = self.path('timeline.64.png')
timeline = os.path.abspath(os.path.join(settings.MEDIA_ROOT, timeline)) timeline = os.path.abspath(os.path.join(settings.MEDIA_ROOT, timeline))
if not os.path.exists(timeline): if not os.path.exists(timeline):
path = self.path('poster.pandora.jpg')
path = os.path.abspath(os.path.join(settings.MEDIA_ROOT, path))
posters[path] = False
return posters return posters
if self.poster_frame >= 0: if self.poster_frame >= 0:
frame = self.get_poster_frame_path() frame = self.get_poster_frame_path()
@ -743,25 +749,30 @@ class Item(models.Model):
posters = self.local_posters() posters = self.local_posters()
timeline = self.path('timeline.64.png') timeline = self.path('timeline.64.png')
timeline = os.path.abspath(os.path.join(settings.MEDIA_ROOT, timeline)) timeline = os.path.abspath(os.path.join(settings.MEDIA_ROOT, timeline))
if os.path.exists(timeline): if not os.path.exists(os.path.join(settings.MEDIA_ROOT,self.path())):
for poster in posters: os.makedirs(os.path.join(settings.MEDIA_ROOT,self.path()))
frame = posters[poster] for poster in posters:
cmd = [settings.ITEM_POSTER, frame = posters[poster]
'-t', self.get('title'), cmd = [settings.ITEM_POSTER,
'-d', ', '.join(self.get('director', ['Unknown Director'])), '-t', self.get('title'),
'-y', str(self.get('year', '')), '-d', ', '.join(self.get('director', ['Unknown Director'])),
'-f', frame, '-y', str(self.get('year', '')),
'-l', timeline, '-p', poster
'-p', poster ]
] if frame:
if settings.USE_IMDB: cmd += [
if len(self.itemId) == 7: '-f', frame,
cmd += ['-i', self.itemId] '-l', timeline,
cmd += ['-o', self.oxdbId] ]
else: if settings.USE_IMDB:
if len(self.itemId) == 7:
cmd += ['-i', self.itemId] cmd += ['-i', self.itemId]
p = subprocess.Popen(cmd) cmd += ['-o', self.oxdbId]
p.wait() else:
cmd += ['-i', self.itemId]
print cmd
p = subprocess.Popen(cmd)
p.wait()
return posters.keys() return posters.keys()
def get_poster_frame_path(self): def get_poster_frame_path(self):

View file

@ -51,10 +51,10 @@ def render_poster(title, director, year, series, oxdb_id, imdb_id, frame, timeli
} }
# frame # frame
frame_width = poster_width
frame_ratio = 4 / 3
frame_height = int(round(frame_width / frame_ratio))
if frame: if frame:
frame_width = poster_width
frame_ratio = 4 / 3
frame_height = int(round(frame_width / frame_ratio))
frame_image = Image.open(frame) frame_image = Image.open(frame)
frame_image_ratio = frame_image.size[0] / frame_image.size[1] frame_image_ratio = frame_image.size[0] / frame_image.size[1]
if frame_ratio < frame_image_ratio: if frame_ratio < frame_image_ratio:
@ -70,9 +70,10 @@ def render_poster(title, director, year, series, oxdb_id, imdb_id, frame, timeli
# timeline # timeline
timeline_width = poster_width timeline_width = poster_width
timeline_height = 64 timeline_height = 64
timeline_image = Image.open(timeline) if timeline:
timeline_image = timeline_image.resize((timeline_width, timeline_height), Image.ANTIALIAS) timeline_image = Image.open(timeline)
poster_image.paste(timeline_image, (0, frame_height)) timeline_image = timeline_image.resize((timeline_width, timeline_height), Image.ANTIALIAS)
poster_image.paste(timeline_image, (0, frame_height))
# text # text
text_width = poster_width text_width = poster_width