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:
|
info dict with:
|
||||||
imdbId, title, director, episode_title, season, series
|
imdbId, title, director, episode_title, season, series
|
||||||
'''
|
'''
|
||||||
if 'imdbId' in info and info['imdbId']:
|
if settings.USE_IMDB:
|
||||||
try:
|
if 'imdbId' in info and info['imdbId']:
|
||||||
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:
|
|
||||||
try:
|
try:
|
||||||
item = Item.objects.get(itemId=info['oxdbId'])
|
item = Item.objects.get(itemId=info['imdbId'])
|
||||||
except Item.DoesNotExist:
|
except Item.DoesNotExist:
|
||||||
item = Item()
|
item = Item(itemId=info['imdbId'])
|
||||||
item.data = {
|
if 'title' in info and 'director' in info:
|
||||||
'title': info['title'],
|
item.external_data = {
|
||||||
'director': info['director'],
|
'title': info['title'],
|
||||||
'year': info.get('year', '')
|
'director': info['director'],
|
||||||
}
|
'year': info.get('year', '')
|
||||||
item.itemId = info['oxdbId']
|
}
|
||||||
|
#FIXME: this should be done async
|
||||||
for key in ('episode_title', 'series_title', 'season', 'episode'):
|
item.save()
|
||||||
if key in info and info[key]:
|
tasks.update_external.delay(item.itemId)
|
||||||
item.data[key] = info[key]
|
#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:
|
try:
|
||||||
existing_item = Item.objects.get(oxdbId=item.oxdb_id())
|
item = Item.objects.get(itemId=info['oxdbId'])
|
||||||
item = existing_item
|
|
||||||
except Item.DoesNotExist:
|
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
|
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)
|
||||||
|
|
|
@ -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")
|
||||||
|
|
|
@ -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'),
|
||||||
)
|
)
|
||||||
|
|
|
@ -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
|
||||||
|
|
||||||
|
|
|
@ -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)
|
||||||
|
|
|
@ -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"))
|
||||||
|
|
||||||
|
|
|
@ -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
|
||||||
|
|
Loading…
Reference in a new issue