use site_config for video settings

This commit is contained in:
j 2011-08-19 17:37:37 +02:00
commit d9aa4a230b
7 changed files with 39 additions and 71 deletions

View file

@ -17,6 +17,7 @@ import ox
from ox.normalize import canonicalTitle
import chardet
from app.models import site_config
from item import utils
from item.models import Item
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):
if not self.available:
config = site_config()['video']
stream, created = Stream.objects.get_or_create(
file=self,
resolution=settings.VIDEO_RESOLUTIONS[0],
format=settings.VIDEO_FORMATS[0])
resolution=config['resolutions'][0],
format=config['formats'][0])
if created:
stream.video.save(stream.name(), chunk)
else:
@ -489,9 +491,9 @@ class Stream(models.Model):
return self.file.path(name)
def extract_derivatives(self):
self.make_timeline()
for resolution in settings.VIDEO_RESOLUTIONS:
for f in settings.VIDEO_FORMATS:
config = site_config()['video']
for resolution in config['resolutions']:
for f in config['formats']:
derivative, created = Stream.objects.get_or_create(file=self.file,
resolution=resolution, format=f)
if created:

View file

@ -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.views import task_status
from app.models import site_config
from item import utils
from item.models import get_item
from item.views import parse_query
@ -111,7 +112,8 @@ actions.register(update, cache=False)
@login_required_json
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})
return render_to_json_response(response)
actions.register(encodingProfile)
@ -166,13 +168,16 @@ class VideoChunkForm(forms.Form):
def firefogg_upload(request):
profile = request.GET['profile']
oshash = request.GET['id']
config = site_config()['video']
video_profile = "%sp.%s" % (config['resolutions'][0], config['formats'][0])
#handle video upload
if request.method == 'POST':
#post next chunk
if 'chunk' in request.FILES and oshash:
f = get_object_or_404(models.File, oshash=oshash)
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']
chunk_id = form.cleaned_data['chunkId']
response = {
@ -194,7 +199,7 @@ def firefogg_upload(request):
response['done'] = 1
return render_to_json_response(response)
#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
f = get_object_or_404(models.File, oshash=oshash)
if f.editable(request.user):