forked from 0x2620/pandora
better item detection of existing items, sort steams by part and fallback to path
This commit is contained in:
parent
ca5bf80763
commit
d1b210d06a
4 changed files with 9 additions and 5 deletions
|
@ -160,6 +160,8 @@ class File(models.Model):
|
|||
for type in ox.movie.EXTENSIONS:
|
||||
if data['extension'] in ox.movie.EXTENSIONS[type]:
|
||||
data['type'] = type
|
||||
if 'part' in data and not data['part']:
|
||||
del data['part']
|
||||
return data
|
||||
|
||||
def normalize_path(self):
|
||||
|
@ -181,7 +183,7 @@ class File(models.Model):
|
|||
data = self.get_path_info()
|
||||
self.extension = data.get('extension')
|
||||
self.language = data.get('language')
|
||||
self.part = ox.sort_string(unicode(data.get('part')) or '')
|
||||
self.part = ox.sort_string(unicode(data.get('part', '')))
|
||||
self.part_title = ox.sort_string(unicode(data.get('partTitle')) or '')
|
||||
self.type = data.get('type') or 'unknown'
|
||||
self.version = data.get('version')
|
||||
|
|
|
@ -19,7 +19,7 @@ def get_or_create_item(volume, info, user):
|
|||
item_info = ox.parse_movie_path(info['path'])
|
||||
if item_info.get('director') and item_info.get('directorSort'):
|
||||
for name, sortname in zip(item_info['director'], item_info['directorSort']):
|
||||
get_name_sort(name, sortname)
|
||||
get_name_sort(name, sortname)
|
||||
return get_item(item_info, user)
|
||||
|
||||
def get_or_create_file(volume, f, user, item=None):
|
||||
|
|
|
@ -123,7 +123,7 @@ def get_item(info, user=None, async=False):
|
|||
if not p:
|
||||
tasks.update_poster.delay(item.itemId)
|
||||
else:
|
||||
qs = Item.objects.filter(find__key='title', find__value=info['title'])
|
||||
qs = Item.objects.filter(find__key='title', find__value__iexact=info['title'])
|
||||
if qs.count() == 1:
|
||||
item = qs[0]
|
||||
else:
|
||||
|
@ -1055,7 +1055,9 @@ class Item(models.Model):
|
|||
def streams(self):
|
||||
return archive.models.Stream.objects.filter(
|
||||
source=None, available=True, file__item=self, file__selected=True
|
||||
).filter(Q(file__is_audio=True)|Q(file__is_video=True)).order_by('file__part')
|
||||
).filter(
|
||||
Q(file__is_audio=True)|Q(file__is_video=True)
|
||||
).order_by('file__part', 'file__sort_path')
|
||||
|
||||
def update_timeline(self, force=False):
|
||||
streams = self.streams()
|
||||
|
|
|
@ -802,7 +802,7 @@ def video(request, id, resolution, format, index=None):
|
|||
#if streams.count() != 1:
|
||||
# reise Http404
|
||||
streams = Stream.objects.filter(file__item__itemId=item.itemId,
|
||||
resolution=resolution, format=format).order_by('file__part')
|
||||
resolution=resolution, format=format).order_by('file__part', 'file__sort_path')
|
||||
if index + 1 > streams.count():
|
||||
raise Http404
|
||||
stream = streams[index]
|
||||
|
|
Loading…
Reference in a new issue