merging changes
This commit is contained in:
commit
1096aefdd6
4 changed files with 27 additions and 16 deletions
|
@ -84,7 +84,9 @@ class File(models.Model):
|
||||||
self.folder = self.get_folder()
|
self.folder = self.get_folder()
|
||||||
self.sort_name = utils.sort_string(canonicalTitle(self.name))
|
self.sort_name = utils.sort_string(canonicalTitle(self.name))
|
||||||
|
|
||||||
if self.info:
|
if not os.path.splitext(self.name)[-1] in (
|
||||||
|
'.srt', '.rar', '.sub', '.idx', '.txt', '.jpg', '.png', '.nfo') \
|
||||||
|
and self.info:
|
||||||
for key in ('duration', 'size'):
|
for key in ('duration', 'size'):
|
||||||
setattr(self, key, self.info.get(key, 0))
|
setattr(self, key, self.info.get(key, 0))
|
||||||
|
|
||||||
|
@ -128,12 +130,14 @@ class File(models.Model):
|
||||||
self.pixels = int(self.width * self.height * float(utils.parse_decimal(self.framerate)) * self.duration)
|
self.pixels = int(self.width * self.height * float(utils.parse_decimal(self.framerate)) * self.duration)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
self.is_video = os.path.splitext(self.name)[-1] in ('.avi', '.mkv', '.dv', '.ogv', '.mpeg', '.mov')
|
self.is_video = os.path.splitext(self.name)[-1] in ('.avi', '.mkv', '.dv', '.ogv', '.mpeg', '.mov', '.webm')
|
||||||
self.is_audio = os.path.splitext(self.name)[-1] in ('.mp3', '.wav', '.ogg', '.flac')
|
self.is_audio = os.path.splitext(self.name)[-1] in ('.mp3', '.wav', '.ogg', '.flac', '.oga')
|
||||||
self.is_subtitle = os.path.splitext(self.name)[-1] in ('.srt', )
|
self.is_subtitle = os.path.splitext(self.name)[-1] in ('.srt', )
|
||||||
|
|
||||||
if not self.is_audio and not self.is_video and self.name.endswith('.srt'):
|
if self.name.endswith('.srt'):
|
||||||
self.is_subtitle = True
|
self.is_subtitle = True
|
||||||
|
self.is_audio = False
|
||||||
|
self.is_video = False
|
||||||
else:
|
else:
|
||||||
self.is_subtitle = False
|
self.is_subtitle = False
|
||||||
|
|
||||||
|
@ -147,7 +151,11 @@ class File(models.Model):
|
||||||
def save(self, *args, **kwargs):
|
def save(self, *args, **kwargs):
|
||||||
if self.auto:
|
if self.auto:
|
||||||
self.set_state()
|
self.set_state()
|
||||||
self.available = self.streams.filter(source=None, available=True).count() > 0
|
if self.is_subtitle:
|
||||||
|
self.available = self.data and True or False
|
||||||
|
else:
|
||||||
|
self.available = not self.uploading and \
|
||||||
|
self.streams.filter(source=None, available=True).count() > 0
|
||||||
super(File, self).save(*args, **kwargs)
|
super(File, self).save(*args, **kwargs)
|
||||||
|
|
||||||
#upload and data handling
|
#upload and data handling
|
||||||
|
|
|
@ -101,5 +101,5 @@ def process_stream(fileId):
|
||||||
stream = streams[0]
|
stream = streams[0]
|
||||||
stream.make_timeline()
|
stream.make_timeline()
|
||||||
stream.extract_derivatives()
|
stream.extract_derivatives()
|
||||||
file.item.update_timeline()
|
file.item.update_selected()
|
||||||
return True
|
return True
|
||||||
|
|
|
@ -105,6 +105,7 @@ def update(request):
|
||||||
file__available=False,
|
file__available=False,
|
||||||
file__wanted=True)]
|
file__wanted=True)]
|
||||||
response['data']['file'] = [f.file.oshash for f in files.filter(file__is_subtitle=True,
|
response['data']['file'] = [f.file.oshash for f in files.filter(file__is_subtitle=True,
|
||||||
|
file__available=False,
|
||||||
name__endswith='.srt')]
|
name__endswith='.srt')]
|
||||||
|
|
||||||
return render_to_json_response(response)
|
return render_to_json_response(response)
|
||||||
|
@ -149,9 +150,11 @@ def upload(request):
|
||||||
response = json_response(status=403, text='permissino denied')
|
response = json_response(status=403, text='permissino denied')
|
||||||
if 'file' in request.FILES:
|
if 'file' in request.FILES:
|
||||||
if not f.available:
|
if not f.available:
|
||||||
|
if f.data:
|
||||||
|
f.data.delete()
|
||||||
f.data.save('data.raw', request.FILES['file'])
|
f.data.save('data.raw', request.FILES['file'])
|
||||||
f.available = True
|
|
||||||
f.save()
|
f.save()
|
||||||
|
item.tasks.load_subtitles.delay(f.item.itemId)
|
||||||
response = json_response(text='file saved')
|
response = json_response(text='file saved')
|
||||||
else:
|
else:
|
||||||
response = json_response(status=403, text='permissino denied')
|
response = json_response(status=403, text='permissino denied')
|
||||||
|
@ -188,7 +191,6 @@ def firefogg_upload(request):
|
||||||
if not f.save_chunk(c, chunk_id, form.cleaned_data['done']):
|
if not f.save_chunk(c, chunk_id, form.cleaned_data['done']):
|
||||||
response['result'] = -1
|
response['result'] = -1
|
||||||
elif form.cleaned_data['done']:
|
elif form.cleaned_data['done']:
|
||||||
f.available = True
|
|
||||||
f.uploading = False
|
f.uploading = False
|
||||||
f.save()
|
f.save()
|
||||||
#FIXME: this fails badly if rabbitmq goes down
|
#FIXME: this fails badly if rabbitmq goes down
|
||||||
|
@ -206,7 +208,6 @@ def firefogg_upload(request):
|
||||||
f = get_object_or_404(models.File, oshash=oshash)
|
f = get_object_or_404(models.File, oshash=oshash)
|
||||||
if f.editable(request.user):
|
if f.editable(request.user):
|
||||||
f.streams.all().delete()
|
f.streams.all().delete()
|
||||||
f.available = False
|
|
||||||
f.uploading = True
|
f.uploading = True
|
||||||
f.save()
|
f.save()
|
||||||
response = {
|
response = {
|
||||||
|
|
|
@ -515,6 +515,7 @@ class Item(models.Model):
|
||||||
#FIXME:
|
#FIXME:
|
||||||
qs = Annotation.objects.filter(layer__name='subtitles', item=self).order_by('start')
|
qs = Annotation.objects.filter(layer__name='subtitles', item=self).order_by('start')
|
||||||
save('subtitles', '\n'.join([l.value for l in qs]))
|
save('subtitles', '\n'.join([l.value for l in qs]))
|
||||||
|
save('filename', '\n'.join([u'%s/%s' % (f.folder, f.name) for f in self.files.all()]))
|
||||||
|
|
||||||
def update_sort(self):
|
def update_sort(self):
|
||||||
try:
|
try:
|
||||||
|
@ -660,7 +661,10 @@ class Item(models.Model):
|
||||||
for key in self.facet_keys + ['title']:
|
for key in self.facet_keys + ['title']:
|
||||||
current_values = self.get(key, [])
|
current_values = self.get(key, [])
|
||||||
if key == 'title':
|
if key == 'title':
|
||||||
|
if current_values:
|
||||||
current_values = [current_values]
|
current_values = [current_values]
|
||||||
|
else:
|
||||||
|
current_values = []
|
||||||
ot = self.get('original_title')
|
ot = self.get('original_title')
|
||||||
if ot:
|
if ot:
|
||||||
current_values.append(ot)
|
current_values.append(ot)
|
||||||
|
@ -729,11 +733,11 @@ class Item(models.Model):
|
||||||
users = self.users_with_files()
|
users = self.users_with_files()
|
||||||
if users.filter(is_superuser=True).count()>0:
|
if users.filter(is_superuser=True).count()>0:
|
||||||
files = self.files.filter(instances__volume__user__is_superuser=True)
|
files = self.files.filter(instances__volume__user__is_superuser=True)
|
||||||
users = User.objects.filter(volumes__files__file__item__in=files,
|
users = User.objects.filter(volumes__files__file__in=files,
|
||||||
is_superuser=True).distinct()
|
is_superuser=True).distinct()
|
||||||
elif users.filter(is_staff=True).count()>0:
|
elif users.filter(is_staff=True).count()>0:
|
||||||
files = self.files.filter(instances__volume__user__is_staff=True)
|
files = self.files.filter(instances__volume__user__is_staff=True)
|
||||||
users = User.objects.filter(volumes__files__file__item__in=files,
|
users = User.objects.filter(volumes__files__file__in=files,
|
||||||
is_staff=True).distinct()
|
is_staff=True).distinct()
|
||||||
else:
|
else:
|
||||||
files = self.files.all()
|
files = self.files.all()
|
||||||
|
@ -916,8 +920,7 @@ class Item(models.Model):
|
||||||
poster = os.path.abspath(os.path.join(settings.MEDIA_ROOT, poster))
|
poster = os.path.abspath(os.path.join(settings.MEDIA_ROOT, poster))
|
||||||
|
|
||||||
frame = self.get_poster_frame_path()
|
frame = self.get_poster_frame_path()
|
||||||
timeline = self.path('timeline.64.png')
|
timeline = '%s.64.png' % self.timeline_prefix
|
||||||
timeline = os.path.abspath(os.path.join(settings.MEDIA_ROOT, timeline))
|
|
||||||
|
|
||||||
director = u', '.join(self.get('director', ['Unknown Director']))
|
director = u', '.join(self.get('director', ['Unknown Director']))
|
||||||
cmd = [settings.ITEM_POSTER,
|
cmd = [settings.ITEM_POSTER,
|
||||||
|
@ -985,8 +988,7 @@ class Item(models.Model):
|
||||||
frame = self.get_poster_frame_path()
|
frame = self.get_poster_frame_path()
|
||||||
icon = self.path('icon.jpg')
|
icon = self.path('icon.jpg')
|
||||||
self.icon.name = icon
|
self.icon.name = icon
|
||||||
timeline = self.path('timeline.64.png')
|
timeline = '%s.64.png' % self.timeline_prefix
|
||||||
timeline = os.path.abspath(os.path.join(settings.MEDIA_ROOT, timeline))
|
|
||||||
cmd = [settings.ITEM_ICON,
|
cmd = [settings.ITEM_ICON,
|
||||||
'-i', self.icon.path
|
'-i', self.icon.path
|
||||||
]
|
]
|
||||||
|
|
Loading…
Reference in a new issue