better item detection of existing items, sort steams by part and fallback to path

This commit is contained in:
j 2013-02-08 11:05:35 +00:00
parent ca5bf80763
commit d1b210d06a
4 changed files with 9 additions and 5 deletions

View file

@ -160,6 +160,8 @@ class File(models.Model):
for type in ox.movie.EXTENSIONS: for type in ox.movie.EXTENSIONS:
if data['extension'] in ox.movie.EXTENSIONS[type]: if data['extension'] in ox.movie.EXTENSIONS[type]:
data['type'] = type data['type'] = type
if 'part' in data and not data['part']:
del data['part']
return data return data
def normalize_path(self): def normalize_path(self):
@ -181,7 +183,7 @@ class File(models.Model):
data = self.get_path_info() data = self.get_path_info()
self.extension = data.get('extension') self.extension = data.get('extension')
self.language = data.get('language') 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.part_title = ox.sort_string(unicode(data.get('partTitle')) or '')
self.type = data.get('type') or 'unknown' self.type = data.get('type') or 'unknown'
self.version = data.get('version') self.version = data.get('version')

View file

@ -123,7 +123,7 @@ def get_item(info, user=None, async=False):
if not p: if not p:
tasks.update_poster.delay(item.itemId) tasks.update_poster.delay(item.itemId)
else: 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: if qs.count() == 1:
item = qs[0] item = qs[0]
else: else:
@ -1055,7 +1055,9 @@ class Item(models.Model):
def streams(self): def streams(self):
return archive.models.Stream.objects.filter( return archive.models.Stream.objects.filter(
source=None, available=True, file__item=self, file__selected=True 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): def update_timeline(self, force=False):
streams = self.streams() streams = self.streams()

View file

@ -802,7 +802,7 @@ def video(request, id, resolution, format, index=None):
#if streams.count() != 1: #if streams.count() != 1:
# reise Http404 # reise Http404
streams = Stream.objects.filter(file__item__itemId=item.itemId, 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(): if index + 1 > streams.count():
raise Http404 raise Http404
stream = streams[index] stream = streams[index]