From 2faa1e28e051ba0b3dcfa87305423812f2c7823a Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Tue, 5 Apr 2011 14:56:02 +0200 Subject: [PATCH] always create a local poster --- pandora/item/models.py | 47 +++++++++++++++++++++++-------------- pandora/scripts/oxdb_poster | 13 +++++----- 2 files changed, 36 insertions(+), 24 deletions(-) diff --git a/pandora/item/models.py b/pandora/item/models.py index ec160900d..5c890decd 100644 --- a/pandora/item/models.py +++ b/pandora/item/models.py @@ -631,6 +631,9 @@ class Item(models.Model): elif not os.path.exists(os.path.dirname(stream.video.path)): os.makedirs(os.path.dirname(stream.video.path)) 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): cmd.append('+') cmd.append(files[f]) @@ -724,6 +727,9 @@ class Item(models.Model): timeline = self.path('timeline.64.png') timeline = os.path.abspath(os.path.join(settings.MEDIA_ROOT, 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 if self.poster_frame >= 0: frame = self.get_poster_frame_path() @@ -743,25 +749,30 @@ class Item(models.Model): posters = self.local_posters() timeline = self.path('timeline.64.png') timeline = os.path.abspath(os.path.join(settings.MEDIA_ROOT, timeline)) - if os.path.exists(timeline): - for poster in posters: - frame = posters[poster] - cmd = [settings.ITEM_POSTER, - '-t', self.get('title'), - '-d', ', '.join(self.get('director', ['Unknown Director'])), - '-y', str(self.get('year', '')), - '-f', frame, - '-l', timeline, - '-p', poster - ] - if settings.USE_IMDB: - if len(self.itemId) == 7: - cmd += ['-i', self.itemId] - cmd += ['-o', self.oxdbId] - else: + if not os.path.exists(os.path.join(settings.MEDIA_ROOT,self.path())): + os.makedirs(os.path.join(settings.MEDIA_ROOT,self.path())) + for poster in posters: + frame = posters[poster] + cmd = [settings.ITEM_POSTER, + '-t', self.get('title'), + '-d', ', '.join(self.get('director', ['Unknown Director'])), + '-y', str(self.get('year', '')), + '-p', poster + ] + if frame: + cmd += [ + '-f', frame, + '-l', timeline, + ] + if settings.USE_IMDB: + if len(self.itemId) == 7: cmd += ['-i', self.itemId] - p = subprocess.Popen(cmd) - p.wait() + cmd += ['-o', self.oxdbId] + else: + cmd += ['-i', self.itemId] + print cmd + p = subprocess.Popen(cmd) + p.wait() return posters.keys() def get_poster_frame_path(self): diff --git a/pandora/scripts/oxdb_poster b/pandora/scripts/oxdb_poster index 59eeecb1b..418749f76 100755 --- a/pandora/scripts/oxdb_poster +++ b/pandora/scripts/oxdb_poster @@ -51,10 +51,10 @@ def render_poster(title, director, year, series, oxdb_id, imdb_id, frame, timeli } # frame + frame_width = poster_width + frame_ratio = 4 / 3 + frame_height = int(round(frame_width / frame_ratio)) 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_ratio = frame_image.size[0] / frame_image.size[1] 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_width = poster_width timeline_height = 64 - timeline_image = Image.open(timeline) - timeline_image = timeline_image.resize((timeline_width, timeline_height), Image.ANTIALIAS) - poster_image.paste(timeline_image, (0, frame_height)) + if timeline: + timeline_image = Image.open(timeline) + timeline_image = timeline_image.resize((timeline_width, timeline_height), Image.ANTIALIAS) + poster_image.paste(timeline_image, (0, frame_height)) # text text_width = poster_width