forked from 0x2620/pandora
use imdb/icon/expose timeline
This commit is contained in:
parent
663eac45cf
commit
b43ea828d9
7 changed files with 63 additions and 43 deletions
|
@ -33,46 +33,54 @@ def get_item(info):
|
|||
info dict with:
|
||||
imdbId, title, director, episode_title, season, series
|
||||
'''
|
||||
if 'imdbId' in info and info['imdbId']:
|
||||
try:
|
||||
item = Item.objects.get(itemId=info['imdbId'])
|
||||
except Item.DoesNotExist:
|
||||
item = Item(itemId=info['imdbId'])
|
||||
if 'title' in info and 'director' in info:
|
||||
item.external_data = {
|
||||
'title': info['title'],
|
||||
'director': info['director'],
|
||||
'year': info.get('year', '')
|
||||
}
|
||||
#FIXME: this should be done async
|
||||
item.save()
|
||||
tasks.update_imdb.delay(item.itemId)
|
||||
#item.update_imdb()
|
||||
else:
|
||||
q = Item.objects.filter(find__key='title', find__value=info['title'])
|
||||
if q.count() > 1:
|
||||
print "FIXME: check more than title here!!?"
|
||||
item = q[0]
|
||||
else:
|
||||
if settings.USE_IMDB:
|
||||
if 'imdbId' in info and info['imdbId']:
|
||||
try:
|
||||
item = Item.objects.get(itemId=info['oxdbId'])
|
||||
item = Item.objects.get(itemId=info['imdbId'])
|
||||
except Item.DoesNotExist:
|
||||
item = Item()
|
||||
item.data = {
|
||||
'title': info['title'],
|
||||
'director': info['director'],
|
||||
'year': info.get('year', '')
|
||||
}
|
||||
item.itemId = info['oxdbId']
|
||||
|
||||
for key in ('episode_title', 'series_title', 'season', 'episode'):
|
||||
if key in info and info[key]:
|
||||
item.data[key] = info[key]
|
||||
item = Item(itemId=info['imdbId'])
|
||||
if 'title' in info and 'director' in info:
|
||||
item.external_data = {
|
||||
'title': info['title'],
|
||||
'director': info['director'],
|
||||
'year': info.get('year', '')
|
||||
}
|
||||
#FIXME: this should be done async
|
||||
item.save()
|
||||
tasks.update_external.delay(item.itemId)
|
||||
#item.update_external()
|
||||
else:
|
||||
q = Item.objects.filter(find__key='title', find__value=info['title'])
|
||||
if q.count() > 1:
|
||||
print "FIXME: check more than title here!!?"
|
||||
item = q[0]
|
||||
else:
|
||||
try:
|
||||
existing_item = Item.objects.get(oxdbId=item.oxdb_id())
|
||||
item = existing_item
|
||||
item = Item.objects.get(itemId=info['oxdbId'])
|
||||
except Item.DoesNotExist:
|
||||
item.save()
|
||||
item = Item()
|
||||
item.data = {
|
||||
'title': info['title'],
|
||||
'director': info['director'],
|
||||
'year': info.get('year', '')
|
||||
}
|
||||
item.itemId = info['oxdbId']
|
||||
|
||||
for key in ('episode_title', 'series_title', 'season', 'episode'):
|
||||
if key in info and info[key]:
|
||||
item.data[key] = info[key]
|
||||
try:
|
||||
existing_item = Item.objects.get(oxdbId=item.oxdb_id())
|
||||
item = existing_item
|
||||
except Item.DoesNotExist:
|
||||
item.save()
|
||||
else:
|
||||
try:
|
||||
item = Item.objects.get(itemId=info['itemId'])
|
||||
except Item.DoesNotExist:
|
||||
item = Item(itemId=info['itemId'])
|
||||
item.save()
|
||||
|
||||
return item
|
||||
|
||||
|
||||
|
@ -130,7 +138,7 @@ class Item(models.Model):
|
|||
_reviews[settings.REVIEW_WHITELIST[url]] = r[0]
|
||||
return _reviews
|
||||
|
||||
def update_imdb(self):
|
||||
def update_external(self):
|
||||
if len(self.itemId) == 7:
|
||||
data = ox.web.imdb.Imdb(self.itemId)
|
||||
#FIXME: all this should be in ox.web.imdb.Imdb
|
||||
|
@ -343,7 +351,9 @@ class Item(models.Model):
|
|||
def save(key, value):
|
||||
f, created = ItemFind.objects.get_or_create(item=self, key=key)
|
||||
if value not in ('', '||'):
|
||||
f.value = value.strip()
|
||||
if isinstance(value, basestring):
|
||||
value = value.strip()
|
||||
f.value = value
|
||||
f.save()
|
||||
else:
|
||||
f.delete()
|
||||
|
@ -730,7 +740,7 @@ class Item(models.Model):
|
|||
'-l', timeline,
|
||||
'-p', poster
|
||||
]
|
||||
if len(self.itemId) == 7:
|
||||
if settings.USE_IMDB and len(self.itemId) == 7:
|
||||
cmd += ['-i', self.itemId]
|
||||
cmd += ['-o', self.oxdbId]
|
||||
p = subprocess.Popen(cmd)
|
||||
|
|
|
@ -19,9 +19,9 @@ def update_poster(itemId):
|
|||
|
||||
|
||||
@task(ignore_resulsts=True, queue='default')
|
||||
def update_imdb(itemId):
|
||||
def update_external(itemId):
|
||||
item = models.Item.objects.get(itemId=itemId)
|
||||
item.update_imdb()
|
||||
item.update_external()
|
||||
|
||||
|
||||
@task(queue="encoding")
|
||||
|
|
|
@ -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\.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].*)/timeline\.(?P<size>\d+)\.png$', 'timeline_overview'),
|
||||
)
|
||||
|
|
|
@ -184,7 +184,7 @@ def parse_path(path):
|
|||
r['oxdbId'] = oxdb_id(r['title'], r['directors'], r.get('year', ''),
|
||||
r.get('season', ''), r.get('episode', ''),
|
||||
episode_title=r['episode_title'],
|
||||
episode_directors=[],
|
||||
episode_director=[],
|
||||
episode_year='')
|
||||
return r
|
||||
|
||||
|
|
|
@ -491,6 +491,12 @@ def timeline(request, id, timeline, size, position):
|
|||
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):
|
||||
item = get_object_or_404(models.Item, itemId=id)
|
||||
stream = get_object_or_404(item.streams, profile=profile)
|
||||
|
|
|
@ -24,6 +24,7 @@ class List(models.Model):
|
|||
_status = ['private', 'public', 'featured']
|
||||
query = DictField(default={"static": True})
|
||||
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"))
|
||||
|
||||
|
|
|
@ -190,6 +190,8 @@ DEFAULT_LISTS = [
|
|||
}
|
||||
]
|
||||
#0xdb.org
|
||||
USE_IMDB = True
|
||||
|
||||
#POSTER_SERVICES=['http://data.0xdb.org/poster/']
|
||||
|
||||
#copy scripts and adjust to customize
|
||||
|
|
Loading…
Reference in a new issue