update static location in scripts, fix poster generation

This commit is contained in:
j 2010-11-18 18:33:46 +01:00
parent 86c5e3cc6a
commit fc2951eb06
5 changed files with 12 additions and 6 deletions

View file

@ -239,6 +239,7 @@ def getItem(info):
#item.save() #item.save()
#tasks.updateImdb.delay(item.itemId) #tasks.updateImdb.delay(item.itemId)
item.updateImdb() item.updateImdb()
tasks.updatePoster.delay(item.itemId)
else: else:
q = Item.objects.filter(find__title=info['title']) q = Item.objects.filter(find__title=info['title'])
if q.count() > 1: if q.count() > 1:
@ -776,10 +777,14 @@ class Item(models.Model):
posters = self.local_posters() posters = self.local_posters()
for poster in posters: for poster in posters:
frame = posters[poster] frame = posters[poster]
timeline = os.path.join(itemid_path(self.itemId), 'timeline.64.png')
timeline = os.path.abspath(os.path.join(settings.MEDIA_ROOT, timeline))
cmd = [settings.ITEM_POSTER, cmd = [settings.ITEM_POSTER,
'-t', self.get('title'), '-t', self.get('title'),
'-d', ', '.join(self.get('directors', ['Unknown Director'])), '-d', ', '.join(self.get('directors', ['Unknown Director'])),
'-y', str(self.get('year', '')),
'-f', frame, '-f', frame,
'-l', timeline,
'-p', poster '-p', poster
] ]
if len(self.itemId) == 7: if len(self.itemId) == 7:

View file

@ -10,7 +10,7 @@ from ox.image import drawText, wrapText
import sys import sys
static_root = os.path.join(os.path.dirname(__file__), '..', 'static') static_root = os.path.join(os.path.dirname(__file__), '..', '..', 'static')
def render_icon(frame, timeline, icon): def render_icon(frame, timeline, icon):
icon_width = 256 icon_width = 256

View file

@ -10,7 +10,7 @@ from ox.image import drawText, wrapText
import sys import sys
static_root = os.path.join(os.path.dirname(__file__), '..', 'static') static_root = os.path.join(os.path.dirname(__file__), '..', '..', 'static')
def render_list_icon(frames, icon): def render_list_icon(frames, icon):
icon_width = 256 icon_width = 256

View file

@ -10,7 +10,7 @@ from ox.image import drawText, wrapText
import sys import sys
static_root = os.path.join(os.path.dirname(__file__), '..', 'static') static_root = os.path.join(os.path.dirname(__file__), '..', '..', 'static')
def render_poster(title, director, year, series, oxdb_id, imdb_id, frame, timeline, poster): def render_poster(title, director, year, series, oxdb_id, imdb_id, frame, timeline, poster):
def get_oxdb_color(oxdb_id, series=False): def get_oxdb_color(oxdb_id, series=False):
@ -37,6 +37,7 @@ def render_poster(title, director, year, series, oxdb_id, imdb_id, frame, timeli
poster_image = Image.new('RGB', (poster_width, poster_height)) poster_image = Image.new('RGB', (poster_width, poster_height))
draw = ImageDraw.Draw(poster_image) draw = ImageDraw.Draw(poster_image)
font_file = os.path.join(static_root, 'ttf', 'DejaVuSansCondensedBold.ttf') font_file = os.path.join(static_root, 'ttf', 'DejaVuSansCondensedBold.ttf')
font_size = { font_size = {
'small': 28, 'small': 28,
'large': 42, 'large': 42,
@ -109,9 +110,9 @@ def render_poster(title, director, year, series, oxdb_id, imdb_id, frame, timeli
logo_color = logo_image.getpixel((x, y))[0] logo_color = logo_image.getpixel((x, y))[0]
alpha = logo_image.getpixel((x, y))[3] alpha = logo_image.getpixel((x, y))[3]
if series: if series:
poster_color = tuple(map(lambda x: x - (logo_color - 16) * alpha / 255, poster_color)) poster_color = tuple(map(lambda x: int(x - (logo_color - 16) * alpha / 255), poster_color))
else: else:
poster_color = tuple(map(lambda x: x + (logo_color - 16) * alpha / 255, poster_color)) poster_color = tuple(map(lambda x: int(x + (logo_color - 16) * alpha / 255), poster_color))
poster_image.putpixel((logo_left + x, logo_top + y), poster_color) poster_image.putpixel((logo_left + x, logo_top + y), poster_color)
poster_image.save(poster) poster_image.save(poster)

View file

@ -9,7 +9,7 @@ import os
from ox.image import drawText, wrapText from ox.image import drawText, wrapText
import sys import sys
static_root = os.path.join(os.path.dirname(__file__), '..', 'static') static_root = os.path.join(os.path.dirname(__file__), '..', '..', 'static')
def render_poster(id, title, frame, timeline, poster): def render_poster(id, title, frame, timeline, poster):
poster_width = 640 poster_width = 640