use imdb/icon/expose timeline

This commit is contained in:
j 2011-01-16 18:58:57 +05:30
parent 663eac45cf
commit b43ea828d9
7 changed files with 63 additions and 43 deletions

View file

@ -33,6 +33,7 @@ def get_item(info):
info dict with: info dict with:
imdbId, title, director, episode_title, season, series imdbId, title, director, episode_title, season, series
''' '''
if settings.USE_IMDB:
if 'imdbId' in info and info['imdbId']: if 'imdbId' in info and info['imdbId']:
try: try:
item = Item.objects.get(itemId=info['imdbId']) item = Item.objects.get(itemId=info['imdbId'])
@ -46,8 +47,8 @@ def get_item(info):
} }
#FIXME: this should be done async #FIXME: this should be done async
item.save() item.save()
tasks.update_imdb.delay(item.itemId) tasks.update_external.delay(item.itemId)
#item.update_imdb() #item.update_external()
else: else:
q = Item.objects.filter(find__key='title', find__value=info['title']) q = Item.objects.filter(find__key='title', find__value=info['title'])
if q.count() > 1: if q.count() > 1:
@ -73,6 +74,13 @@ def get_item(info):
item = existing_item item = existing_item
except Item.DoesNotExist: except Item.DoesNotExist:
item.save() item.save()
else:
try:
item = Item.objects.get(itemId=info['itemId'])
except Item.DoesNotExist:
item = Item(itemId=info['itemId'])
item.save()
return item return item
@ -130,7 +138,7 @@ class Item(models.Model):
_reviews[settings.REVIEW_WHITELIST[url]] = r[0] _reviews[settings.REVIEW_WHITELIST[url]] = r[0]
return _reviews return _reviews
def update_imdb(self): def update_external(self):
if len(self.itemId) == 7: if len(self.itemId) == 7:
data = ox.web.imdb.Imdb(self.itemId) data = ox.web.imdb.Imdb(self.itemId)
#FIXME: all this should be in ox.web.imdb.Imdb #FIXME: all this should be in ox.web.imdb.Imdb
@ -343,7 +351,9 @@ class Item(models.Model):
def save(key, value): def save(key, value):
f, created = ItemFind.objects.get_or_create(item=self, key=key) f, created = ItemFind.objects.get_or_create(item=self, key=key)
if value not in ('', '||'): if value not in ('', '||'):
f.value = value.strip() if isinstance(value, basestring):
value = value.strip()
f.value = value
f.save() f.save()
else: else:
f.delete() f.delete()
@ -730,7 +740,7 @@ class Item(models.Model):
'-l', timeline, '-l', timeline,
'-p', poster '-p', poster
] ]
if len(self.itemId) == 7: if settings.USE_IMDB and len(self.itemId) == 7:
cmd += ['-i', self.itemId] cmd += ['-i', self.itemId]
cmd += ['-o', self.oxdbId] cmd += ['-o', self.oxdbId]
p = subprocess.Popen(cmd) p = subprocess.Popen(cmd)

View file

@ -19,9 +19,9 @@ def update_poster(itemId):
@task(ignore_resulsts=True, queue='default') @task(ignore_resulsts=True, queue='default')
def update_imdb(itemId): def update_external(itemId):
item = models.Item.objects.get(itemId=itemId) item = models.Item.objects.get(itemId=itemId)
item.update_imdb() item.update_external()
@task(queue="encoding") @task(queue="encoding")

View file

@ -14,4 +14,5 @@ urlpatterns = patterns("item.views",
(r'^(?P<id>[A-Z0-9].*)/icon\.(?P<size>\d+)\.jpg$', 'icon'), (r'^(?P<id>[A-Z0-9].*)/icon\.(?P<size>\d+)\.jpg$', 'icon'),
(r'^(?P<id>[A-Z0-9].*)/icon\.jpg$', 'icon'), (r'^(?P<id>[A-Z0-9].*)/icon\.jpg$', 'icon'),
(r'^(?P<id>[A-Z0-9].*)/timelines/(?P<timeline>.+)\.(?P<size>\d+)\.(?P<position>\d+)\.png$', 'timeline'), (r'^(?P<id>[A-Z0-9].*)/timelines/(?P<timeline>.+)\.(?P<size>\d+)\.(?P<position>\d+)\.png$', 'timeline'),
(r'^(?P<id>[A-Z0-9].*)/timeline\.(?P<size>\d+)\.png$', 'timeline_overview'),
) )

View file

@ -184,7 +184,7 @@ def parse_path(path):
r['oxdbId'] = oxdb_id(r['title'], r['directors'], r.get('year', ''), r['oxdbId'] = oxdb_id(r['title'], r['directors'], r.get('year', ''),
r.get('season', ''), r.get('episode', ''), r.get('season', ''), r.get('episode', ''),
episode_title=r['episode_title'], episode_title=r['episode_title'],
episode_directors=[], episode_director=[],
episode_year='') episode_year='')
return r return r

View file

@ -491,6 +491,12 @@ def timeline(request, id, timeline, size, position):
return HttpFileResponse(timeline, content_type='image/png') return HttpFileResponse(timeline, content_type='image/png')
def timeline_overview(request, id, size):
item = get_object_or_404(models.Item, itemId=id)
timeline = '%s.%s.png' %(item.timeline_prefix, size)
return HttpFileResponse(timeline, content_type='image/png')
def video(request, id, profile): def video(request, id, profile):
item = get_object_or_404(models.Item, itemId=id) item = get_object_or_404(models.Item, itemId=id)
stream = get_object_or_404(item.streams, profile=profile) stream = get_object_or_404(item.streams, profile=profile)

View file

@ -24,6 +24,7 @@ class List(models.Model):
_status = ['private', 'public', 'featured'] _status = ['private', 'public', 'featured']
query = DictField(default={"static": True}) query = DictField(default={"static": True})
type= models.CharField(max_length=255, default='static') type= models.CharField(max_length=255, default='static')
description = models.TextField(default='')
icon = models.ImageField(default=None, blank=True, upload_to=lambda i, x: i.path("icon.jpg")) icon = models.ImageField(default=None, blank=True, upload_to=lambda i, x: i.path("icon.jpg"))

View file

@ -190,6 +190,8 @@ DEFAULT_LISTS = [
} }
] ]
#0xdb.org #0xdb.org
USE_IMDB = True
#POSTER_SERVICES=['http://data.0xdb.org/poster/'] #POSTER_SERVICES=['http://data.0xdb.org/poster/']
#copy scripts and adjust to customize #copy scripts and adjust to customize