forked from 0x2620/pandora
expose parts
This commit is contained in:
parent
4f71992f2b
commit
1d38cede3b
3 changed files with 13 additions and 8 deletions
|
@ -589,7 +589,7 @@ class Item(models.Model):
|
||||||
def main_videos(self):
|
def main_videos(self):
|
||||||
#FIXME: needs to check if more than one user has main files and only
|
#FIXME: needs to check if more than one user has main files and only
|
||||||
# take from "higher" user
|
# take from "higher" user
|
||||||
videos = self.files.filter(is_main=True, is_video=True, available=True).order_by('part')
|
videos = self.files.filter(is_main=True, is_video=True, available=True, instances__gt=0).order_by('part')
|
||||||
if videos.count()>0:
|
if videos.count()>0:
|
||||||
first = videos[0]
|
first = videos[0]
|
||||||
user = first.instances.all()[0].volume.user
|
user = first.instances.all()[0].volume.user
|
||||||
|
|
|
@ -6,8 +6,8 @@ from django.conf.urls.defaults import *
|
||||||
|
|
||||||
urlpatterns = patterns("item.views",
|
urlpatterns = patterns("item.views",
|
||||||
(r'^(?P<id>[A-Z0-9].*)/frame/(?P<size>\d+)/(?P<position>[0-9\.,]+).jpg$', 'frame'),
|
(r'^(?P<id>[A-Z0-9].*)/frame/(?P<size>\d+)/(?P<position>[0-9\.,]+).jpg$', 'frame'),
|
||||||
(r'^(?P<id>[A-Z0-9].*)/(?P<profile>.*.webm)$', 'video'),
|
(r'^(?P<id>[A-Z0-9].*)/(?P<oshash>[a-f0-9]+)/(?P<profile>.*.[webm|ogv|mp4])$', 'video'),
|
||||||
(r'^(?P<id>[A-Z0-9].*)/(?P<profile>.*.mp4)$', 'video'),
|
(r'^(?P<id>[A-Z0-9].*)/(?P<profile>.*.[webm|ogv|mp4])$', 'video'),
|
||||||
(r'^(?P<id>[A-Z0-9].*)/poster\.(?P<size>\d+)\.jpg$', 'poster'),
|
(r'^(?P<id>[A-Z0-9].*)/poster\.(?P<size>\d+)\.jpg$', 'poster'),
|
||||||
(r'^(?P<id>[A-Z0-9].*)/poster\.(?P<size>large)\.jpg$', 'poster'),
|
(r'^(?P<id>[A-Z0-9].*)/poster\.(?P<size>large)\.jpg$', 'poster'),
|
||||||
(r'^(?P<id>[A-Z0-9].*)/poster\.jpg$', 'poster'),
|
(r'^(?P<id>[A-Z0-9].*)/poster\.jpg$', 'poster'),
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
from __future__ import division
|
from __future__ import division
|
||||||
import os.path
|
import os.path
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
import mimetypes
|
||||||
|
|
||||||
from django.db.models import Count, Sum, Max
|
from django.db.models import Count, Sum, Max
|
||||||
from django.http import HttpResponse, Http404
|
from django.http import HttpResponse, Http404
|
||||||
|
@ -581,16 +582,20 @@ def timeline_overview(request, id, size):
|
||||||
return HttpFileResponse(timeline, content_type='image/png')
|
return HttpFileResponse(timeline, content_type='image/png')
|
||||||
|
|
||||||
|
|
||||||
def video(request, id, profile):
|
def video(request, id, profile, oshash=None):
|
||||||
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)
|
if oshash:
|
||||||
path = stream.video.path
|
stream = get_object_or_404(item.files, oshash=oshash)
|
||||||
content_type = path.endswith('.mp4') and 'video/mp4' or 'video/webm'
|
path = stream.video.path
|
||||||
|
else:
|
||||||
|
stream = get_object_or_404(item.streams, profile=profile)
|
||||||
|
path = stream.video.path
|
||||||
#server side cutting
|
#server side cutting
|
||||||
t = request.GET.get('t')
|
t = request.GET.get('t')
|
||||||
if t:
|
if t:
|
||||||
t = map(float, t.split(','))
|
t = map(float, t.split(','))
|
||||||
ext = os.path.splitext(profile)[1]
|
ext = os.path.splitext(profile)[1]
|
||||||
|
content_type = mimetypes.guess_type(path)[0]
|
||||||
if len(t) == 2 and t[1] > t[0] and stream.info['duration']>=t[1]:
|
if len(t) == 2 and t[1] > t[0] and stream.info['duration']>=t[1]:
|
||||||
response = HttpResponse(extract.chop(path, t[0], t[1]), content_type=content_type)
|
response = HttpResponse(extract.chop(path, t[0], t[1]), content_type=content_type)
|
||||||
filename = "Clip of %s - %s-%s - %s %s%s" % (
|
filename = "Clip of %s - %s-%s - %s %s%s" % (
|
||||||
|
@ -613,4 +618,4 @@ def video(request, id, profile):
|
||||||
response = HttpFileResponse(path, content_type=content_type)
|
response = HttpFileResponse(path, content_type=content_type)
|
||||||
response['Content-Disposition'] = 'attachment; filename="%s"' % filename
|
response['Content-Disposition'] = 'attachment; filename="%s"' % filename
|
||||||
return response
|
return response
|
||||||
return HttpFileResponse(path, content_type=content_type)
|
return HttpFileResponse(path)
|
||||||
|
|
Loading…
Reference in a new issue