export layers as srt
This commit is contained in:
parent
7757582aaf
commit
9cc90ec245
4 changed files with 24 additions and 0 deletions
|
@ -203,3 +203,4 @@ def editAnnotation(request):
|
||||||
response = json_response(status=403, text='permission denied')
|
response = json_response(status=403, text='permission denied')
|
||||||
return render_to_json_response(response)
|
return render_to_json_response(response)
|
||||||
actions.register(editAnnotation, cache=False)
|
actions.register(editAnnotation, cache=False)
|
||||||
|
|
||||||
|
|
|
@ -1166,6 +1166,13 @@ class Item(models.Model):
|
||||||
Clip.objects.filter(item=self, annotations__id=None).delete()
|
Clip.objects.filter(item=self, annotations__id=None).delete()
|
||||||
self.update_find()
|
self.update_find()
|
||||||
|
|
||||||
|
def srt(self, layer):
|
||||||
|
return ox.srt.encode([{
|
||||||
|
'in': a.start,
|
||||||
|
'out': a.end,
|
||||||
|
'value': a.value
|
||||||
|
} for a in self.annotations.filter(layer=layer).order_by('start')])
|
||||||
|
|
||||||
def delete_item(sender, **kwargs):
|
def delete_item(sender, **kwargs):
|
||||||
i = kwargs['instance']
|
i = kwargs['instance']
|
||||||
i.delete_files()
|
i.delete_files()
|
||||||
|
|
|
@ -18,6 +18,9 @@ urlpatterns = patterns("item.views",
|
||||||
#torrent
|
#torrent
|
||||||
(r'^(?P<id>[A-Z0-9].*)/torrent/(?P<filename>.*?)$', 'torrent'),
|
(r'^(?P<id>[A-Z0-9].*)/torrent/(?P<filename>.*?)$', 'torrent'),
|
||||||
|
|
||||||
|
#srt export
|
||||||
|
(r'^(?P<id>[A-Z0-9].*)/(?P<layer>.+)\.srt$', 'srt'),
|
||||||
|
|
||||||
#icon
|
#icon
|
||||||
(r'^(?P<id>[A-Z0-9].*)/icon(?P<size>\d*)\.jpg$', 'icon'),
|
(r'^(?P<id>[A-Z0-9].*)/icon(?P<size>\d*)\.jpg$', 'icon'),
|
||||||
|
|
||||||
|
|
|
@ -784,6 +784,18 @@ def video(request, id, resolution, format, index=None):
|
||||||
response['Cache-Control'] = 'public'
|
response['Cache-Control'] = 'public'
|
||||||
return response
|
return response
|
||||||
|
|
||||||
|
def srt(request, id, layer, index=None):
|
||||||
|
item = get_object_or_404(models.Item, itemId=id)
|
||||||
|
if not item.access(request.user):
|
||||||
|
response = HttpResponseForbidden()
|
||||||
|
else:
|
||||||
|
response = HttpResponse()
|
||||||
|
filename = "%s.srt" % item.get('title')
|
||||||
|
response['Content-Disposition'] = 'attachment; filename="%s"' % filename
|
||||||
|
response['Content-Type'] = 'text/x-srt'
|
||||||
|
response.write(item.srt(layer))
|
||||||
|
return response
|
||||||
|
|
||||||
def random_annotation(request):
|
def random_annotation(request):
|
||||||
n = models.Item.objects.all().count()
|
n = models.Item.objects.all().count()
|
||||||
pos = random.randint(0, n)
|
pos = random.randint(0, n)
|
||||||
|
@ -792,3 +804,4 @@ def random_annotation(request):
|
||||||
pos = random.randint(0, n)
|
pos = random.randint(0, n)
|
||||||
clip = item.annotations.all()[pos]
|
clip = item.annotations.all()[pos]
|
||||||
return redirect('/%s'% clip.public_id)
|
return redirect('/%s'% clip.public_id)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue