forked from 0x2620/pandora
use site_config for video settings
This commit is contained in:
parent
ad38fa019e
commit
ce912b59be
7 changed files with 39 additions and 71 deletions
|
@ -346,6 +346,13 @@
|
||||||
"columnWidth": 60,
|
"columnWidth": 60,
|
||||||
"format": {"type": "unit", "args": ["kbps"]}
|
"format": {"type": "unit", "args": ["kbps"]}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"id": "parts",
|
||||||
|
"title": "Parts",
|
||||||
|
"type": "integer",
|
||||||
|
"columnWidth": 60,
|
||||||
|
"rightsLevel": 1
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"id": "numberoffiles",
|
"id": "numberoffiles",
|
||||||
"title": "Number of Files",
|
"title": "Number of Files",
|
||||||
|
|
|
@ -17,6 +17,7 @@ import ox
|
||||||
from ox.normalize import canonicalTitle
|
from ox.normalize import canonicalTitle
|
||||||
import chardet
|
import chardet
|
||||||
|
|
||||||
|
from app.models import site_config
|
||||||
from item import utils
|
from item import utils
|
||||||
from item.models import Item
|
from item.models import Item
|
||||||
from person.models import get_name_sort
|
from person.models import get_name_sort
|
||||||
|
@ -248,10 +249,11 @@ class File(models.Model):
|
||||||
|
|
||||||
def save_chunk(self, chunk, chunk_id=-1, done=False):
|
def save_chunk(self, chunk, chunk_id=-1, done=False):
|
||||||
if not self.available:
|
if not self.available:
|
||||||
|
config = site_config()['video']
|
||||||
stream, created = Stream.objects.get_or_create(
|
stream, created = Stream.objects.get_or_create(
|
||||||
file=self,
|
file=self,
|
||||||
resolution=settings.VIDEO_RESOLUTIONS[0],
|
resolution=config['resolutions'][0],
|
||||||
format=settings.VIDEO_FORMATS[0])
|
format=config['formats'][0])
|
||||||
if created:
|
if created:
|
||||||
stream.video.save(stream.name(), chunk)
|
stream.video.save(stream.name(), chunk)
|
||||||
else:
|
else:
|
||||||
|
@ -489,9 +491,9 @@ class Stream(models.Model):
|
||||||
return self.file.path(name)
|
return self.file.path(name)
|
||||||
|
|
||||||
def extract_derivatives(self):
|
def extract_derivatives(self):
|
||||||
self.make_timeline()
|
config = site_config()['video']
|
||||||
for resolution in settings.VIDEO_RESOLUTIONS:
|
for resolution in config['resolutions']:
|
||||||
for f in settings.VIDEO_FORMATS:
|
for f in config['formats']:
|
||||||
derivative, created = Stream.objects.get_or_create(file=self.file,
|
derivative, created = Stream.objects.get_or_create(file=self.file,
|
||||||
resolution=resolution, format=f)
|
resolution=resolution, format=f)
|
||||||
if created:
|
if created:
|
||||||
|
|
|
@ -14,6 +14,7 @@ from ox.django.decorators import login_required_json
|
||||||
from ox.django.shortcuts import render_to_json_response, get_object_or_404_json, json_response
|
from ox.django.shortcuts import render_to_json_response, get_object_or_404_json, json_response
|
||||||
from ox.django.views import task_status
|
from ox.django.views import task_status
|
||||||
|
|
||||||
|
from app.models import site_config
|
||||||
from item import utils
|
from item import utils
|
||||||
from item.models import get_item
|
from item.models import get_item
|
||||||
from item.views import parse_query
|
from item.views import parse_query
|
||||||
|
@ -111,7 +112,8 @@ actions.register(update, cache=False)
|
||||||
|
|
||||||
@login_required_json
|
@login_required_json
|
||||||
def encodingProfile(request):
|
def encodingProfile(request):
|
||||||
profile = "%sp.%s" % (settings.VIDEO_RESOLUTIONS[0], settings.VIDEO_FORMATS[0])
|
config = site_config()['video']
|
||||||
|
profile = "%sp.%s" % (config['resolutions'][0], config['formats'][0])
|
||||||
response = json_response({'profile': profile})
|
response = json_response({'profile': profile})
|
||||||
return render_to_json_response(response)
|
return render_to_json_response(response)
|
||||||
actions.register(encodingProfile)
|
actions.register(encodingProfile)
|
||||||
|
@ -166,13 +168,16 @@ class VideoChunkForm(forms.Form):
|
||||||
def firefogg_upload(request):
|
def firefogg_upload(request):
|
||||||
profile = request.GET['profile']
|
profile = request.GET['profile']
|
||||||
oshash = request.GET['id']
|
oshash = request.GET['id']
|
||||||
|
config = site_config()['video']
|
||||||
|
video_profile = "%sp.%s" % (config['resolutions'][0], config['formats'][0])
|
||||||
|
|
||||||
#handle video upload
|
#handle video upload
|
||||||
if request.method == 'POST':
|
if request.method == 'POST':
|
||||||
#post next chunk
|
#post next chunk
|
||||||
if 'chunk' in request.FILES and oshash:
|
if 'chunk' in request.FILES and oshash:
|
||||||
f = get_object_or_404(models.File, oshash=oshash)
|
f = get_object_or_404(models.File, oshash=oshash)
|
||||||
form = VideoChunkForm(request.POST, request.FILES)
|
form = VideoChunkForm(request.POST, request.FILES)
|
||||||
if form.is_valid() and profile == settings.VIDEO_PROFILE and f.editable(request.user):
|
if form.is_valid() and profile == video_profile and f.editable(request.user):
|
||||||
c = form.cleaned_data['chunk']
|
c = form.cleaned_data['chunk']
|
||||||
chunk_id = form.cleaned_data['chunkId']
|
chunk_id = form.cleaned_data['chunkId']
|
||||||
response = {
|
response = {
|
||||||
|
@ -194,7 +199,7 @@ def firefogg_upload(request):
|
||||||
response['done'] = 1
|
response['done'] = 1
|
||||||
return render_to_json_response(response)
|
return render_to_json_response(response)
|
||||||
#init upload
|
#init upload
|
||||||
elif oshash and profile == settings.VIDEO_PROFILE:
|
elif oshash and profile == video_profile:
|
||||||
#404 if oshash is not know, files must be registered via update api first
|
#404 if oshash is not know, files must be registered via update api first
|
||||||
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):
|
||||||
|
|
|
@ -792,48 +792,15 @@ class Item(models.Model):
|
||||||
return [video.streams.filter(source=None)[0] for video in self.main_videos()]
|
return [video.streams.filter(source=None)[0] for video in self.main_videos()]
|
||||||
|
|
||||||
def update_streams(self, force=False):
|
def update_streams(self, force=False):
|
||||||
files = {}
|
streams = self.streams()
|
||||||
for f in self.main_videos():
|
|
||||||
files[utils.sort_title(f.name)] = f.video.path
|
|
||||||
if force or self.stream_info != files:
|
|
||||||
self.stream_info = files
|
|
||||||
stream, created = Stream.objects.get_or_create(item=self,
|
|
||||||
profile=settings.VIDEO_PROFILE)
|
|
||||||
stream.video.name = stream.path()
|
|
||||||
cmd = []
|
|
||||||
if os.path.exists(stream.video.path):
|
|
||||||
os.unlink(stream.video.path)
|
|
||||||
ox.makedirs(os.path.dirname(stream.video.path))
|
|
||||||
if len(files.values()) > 1:
|
|
||||||
if len(files.values()) > 4:
|
|
||||||
print "FIXME: to many files for this item, not merging entire tv shows"
|
|
||||||
return
|
|
||||||
for f in sorted(files):
|
|
||||||
cmd.append('+')
|
|
||||||
cmd.append(files[f])
|
|
||||||
cmd = [ 'mkvmerge', '-o', stream.video.path ] + cmd[1:]
|
|
||||||
#print cmd
|
|
||||||
p = subprocess.Popen(cmd, stdin=subprocess.PIPE,
|
|
||||||
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
|
||||||
#p = subprocess.Popen(cmd, stdin=subprocess.PIPE)
|
|
||||||
p.wait()
|
|
||||||
else:
|
|
||||||
os.symlink(files.values()[0], stream.video.path)
|
|
||||||
stream.save()
|
|
||||||
|
|
||||||
self.make_timeline()
|
self.make_timeline()
|
||||||
if 'video' in stream.info and stream.info['video']:
|
|
||||||
v = stream.info['video'][0]
|
|
||||||
self.stream_aspect = v['width']/v['height']
|
|
||||||
self.data['cuts'] = extract.cuts(self.timeline_prefix)
|
self.data['cuts'] = extract.cuts(self.timeline_prefix)
|
||||||
self.data['color'] = extract.average_color(self.timeline_prefix)
|
self.data['color'] = extract.average_color(self.timeline_prefix)
|
||||||
#extract.timeline_strip(self, self.data['cuts'], stream.info, self.timeline_prefix[:-8])
|
#extract.timeline_strip(self, self.data['cuts'], stream.info, self.timeline_prefix[:-8])
|
||||||
|
|
||||||
stream.extract_derivatives()
|
|
||||||
self.make_local_poster()
|
self.make_local_poster()
|
||||||
self.make_poster()
|
self.make_poster()
|
||||||
self.make_icon()
|
self.make_icon()
|
||||||
self.rendered = files != {}
|
self.rendered = streams != []
|
||||||
self.save()
|
self.save()
|
||||||
|
|
||||||
'''
|
'''
|
||||||
|
@ -886,6 +853,8 @@ class Item(models.Model):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def make_timeline(self):
|
def make_timeline(self):
|
||||||
|
streams = self.streams()
|
||||||
|
if len(streams) > 1:
|
||||||
print "FIXME, needs to build timeline from parts"
|
print "FIXME, needs to build timeline from parts"
|
||||||
|
|
||||||
def make_poster(self, force=False):
|
def make_poster(self, force=False):
|
||||||
|
@ -963,7 +932,7 @@ class Item(models.Model):
|
||||||
if frames and len(frames) > int(self.poster_frame):
|
if frames and len(frames) > int(self.poster_frame):
|
||||||
return frames[int(self.poster_frame)]['path']
|
return frames[int(self.poster_frame)]['path']
|
||||||
else:
|
else:
|
||||||
size = int(settings.VIDEO_PROFILE.split('.')[0][:-1])
|
size = site_config()['video']['resolutions'][0]
|
||||||
return self.frame(self.poster_frame, size)
|
return self.frame(self.poster_frame, size)
|
||||||
|
|
||||||
if frames:
|
if frames:
|
||||||
|
|
|
@ -697,4 +697,6 @@ def video(request, id, resolution, format, index=None):
|
||||||
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
|
||||||
|
if not settings.XSENDFILE and not settings.XACCELREDIRECT:
|
||||||
|
return redirect(stream.video.url)
|
||||||
return HttpFileResponse(path)
|
return HttpFileResponse(path)
|
||||||
|
|
|
@ -437,7 +437,7 @@
|
||||||
"showSidebar": true,
|
"showSidebar": true,
|
||||||
"sidebarSize": 256,
|
"sidebarSize": 256,
|
||||||
"sitePage": "home",
|
"sitePage": "home",
|
||||||
"theme": "modern",
|
"theme": "classic",
|
||||||
"videoPosition": {},
|
"videoPosition": {},
|
||||||
"videoScreen": "fit",
|
"videoScreen": "fit",
|
||||||
"videoSize": "small"
|
"videoSize": "small"
|
||||||
|
|
|
@ -169,26 +169,9 @@ SITE_CONFIG = join(PROJECT_ROOT, '0xdb.json')
|
||||||
DEFAULT_SORT = [{"key": "director", "operator": ""}]
|
DEFAULT_SORT = [{"key": "director", "operator": ""}]
|
||||||
DEFAULT_THEME = "classic"
|
DEFAULT_THEME = "classic"
|
||||||
|
|
||||||
VIDEO_PROFILE = '96p.webm'
|
|
||||||
VIDEO_DERIVATIVES = []
|
|
||||||
|
|
||||||
TRACKER_URL="http://url2torrent.net:6970/announce"
|
TRACKER_URL="http://url2torrent.net:6970/announce"
|
||||||
|
|
||||||
VIDEO_FORMATS=['webm']
|
|
||||||
VIDEO_RESOLUTIONS=[96]
|
|
||||||
|
|
||||||
#0xdb
|
|
||||||
'''
|
|
||||||
VIDEO_FORMATS=['webm', 'mp4']
|
|
||||||
VIDEO_RESOLUTIONS=[96]
|
|
||||||
'''
|
|
||||||
|
|
||||||
#Pad.ma
|
|
||||||
'''
|
|
||||||
VIDEO_FORMATS=['webm', 'mp4']
|
|
||||||
VIDEO_RESOLUTIONS=[480, 240, 96]
|
|
||||||
'''
|
|
||||||
|
|
||||||
TRANSMISSON_HOST = 'localhost'
|
TRANSMISSON_HOST = 'localhost'
|
||||||
TRANSMISSON_PORT = 9091
|
TRANSMISSON_PORT = 9091
|
||||||
TRANSMISSON_USER = 'transmission'
|
TRANSMISSON_USER = 'transmission'
|
||||||
|
|
Loading…
Reference in a new issue