site.js, cleanup stream names again

This commit is contained in:
j 2010-02-08 15:56:25 +05:30
parent fc4285933a
commit 3d36da45af
8 changed files with 90 additions and 52 deletions

View file

@ -6,6 +6,9 @@ from django.conf import settings
def index(request):
context = RequestContext(request, {})
context = RequestContext(request, {'settings':settings})
return render_to_response('index.html', context)
def site_js(request):
context = RequestContext(request, {'settings':settings})
return render_to_response('site.js', context, mimetype="application/javascript")

View file

@ -306,9 +306,9 @@ class Movie(models.Model):
#stream related fields
'''
'''
stream96p = models.FileField(default=None, blank=True, upload_to=lambda f, x: movie_path(f, '96p'))
stream320 = models.FileField(default=None, blank=True, upload_to=lambda f, x: movie_path(f, '320'))
stream640 = models.FileField(default=None, blank=True, upload_to=lambda f, x: movie_path(f, '640'))
stream_low = models.FileField(default=None, blank=True, upload_to=lambda f, x: movie_path(f, 'low'))
stream_mid = models.FileField(default=None, blank=True, upload_to=lambda f, x: movie_path(f, 'mid'))
stream_high = models.FileField(default=None, blank=True, upload_to=lambda f, x: movie_path(f, 'high'))
#FIXME: is this still required? should this not be aspect ratio? depends on stream???
scene_height = models.IntegerField(null=True, blank=True)
@ -612,10 +612,10 @@ class MovieSort(models.Model):
resolution = models.IntegerField(blank=True)
aspectratio = models.IntegerField('Aspect Ratio', blank=True)
bitrate = models.IntegerField(blank=True)
pixels = models.IntegerField(blank=True)
pixels = models.BigIntegerField(blank=True)
filename = models.IntegerField(blank=True)
files = models.IntegerField(blank=True)
size = models.IntegerField(blank=True)
size = models.BigIntegerField(blank=True)
_private_fields = ('id', 'movie')
#return available sort fields
@ -923,7 +923,7 @@ class Review(models.Model):
if q.count() > 0:
o = q[0]
else:
o = self.objects.create(movie=movie, url=url)
o = self.objects.create(movie=movie, url=g)
o.save()
return o
get_or_create = classmethod(get_or_create)
@ -1044,17 +1044,17 @@ class File(models.Model):
#stream related fields
available = models.BooleanField(default=False)
stream96p = models.FileField(default=None, upload_to=lambda f, x: stream_path(f, '96p'))
stream320 = models.FileField(default=None, upload_to=lambda f, x: stream_path(f, '320'))
stream640 = models.FileField(default=None, upload_to=lambda f, x: stream_path(f, '640'))
stream_low = models.FileField(default=None, upload_to=lambda f, x: stream_path(f, 'low'))
stream_mid = models.FileField(default=None, upload_to=lambda f, x: stream_path(f, 'mid'))
stream_high = models.FileField(default=None, upload_to=lambda f, x: stream_path(f, 'high'))
def timeline_base_url(self):
return '%s/timeline' % os.path.dirname(self.stream96p.url)
return '%s/timeline' % os.path.dirname(self.stream_low.url)
def save_chunk(self, chunk, name='video.ogv'):
if not self.available:
#FIXME: this should use stream96p or stream640 depending on configuration
video = getattr(self, 'stream96p')
#FIXME: this should use stream_low or stream_high depending on configuration
video = getattr(self, 'stream_%s'%settings.VIDEO_PROFILE)
if not video:
video.save(name, chunk)
self.save()
@ -1116,12 +1116,12 @@ class File(models.Model):
self.save()
def extract_timeline(self):
if self.stream640:
video = self.stream640.path
elif stream320:
video = self.stream320.path
elif stream96p:
video = self.stream96p.path
if self.stream_high:
video = self.stream_high.path
elif self.stream_mid:
video = self.stream_mid.path
elif self.stream_low:
video = self.stream_low.path
else:
return False
prefix = os.path.join(os.path.dirname(video), 'timeline')
@ -1132,19 +1132,19 @@ class File(models.Model):
def extract_video(self):
ogg = Firefogg()
if self.stream640:
#320 stream
self.stream320.name = stream_path(self, '320')
self.stream320.save()
ogg.encode(self.stream640.path, self.stream320.path, settings.VIDEO320)
#96p stream
self.stream96p.name = stream_path(self, '96p')
self.stream96p.save()
ogg.encode(self.stream640.path, self.stream96p.path, settings.VIDEO96P)
elif self.stream320:
self.stream96p.name = stream_path(self, '96p')
self.stream96p.save()
ogg.encode(self.stream320.path, self.stream96p.path, settings.VIDEO96P)
if self.stream_high:
#mid stream
self.stream_mid.name = stream_path(self, 'mid')
self.stream_mid.save()
ogg.encode(self.stream_height.path, self.stream_mid.path, settings.VIDEO_MID)
#low stream
self.stream_low.name = stream_path(self, 'low')
self.stream_low.save()
ogg.encode(self.stream_high.path, self.stream_low.path, settings.VIDEO_LOW)
elif self.stream_mid:
self.stream_low.name = stream_path(self, 'low')
self.stream_low.save()
ogg.encode(self.stream_mid.path, self.stream_low.path, settings.VIDEO_LOW)
def extract(self):
#FIXME: do stuff, like create timeline or create smaller videos etc

View file

@ -14,6 +14,7 @@ from django.db.models import Q, Avg, Count
from django.http import HttpResponse
from django.shortcuts import render_to_response, get_object_or_404, get_list_or_404
from django.template import RequestContext
from django.conf import settings
try:
import simplejson as json
@ -62,7 +63,7 @@ def api_hello(request):
if request.user.is_authenticated():
response['data']['user'] = getUserJSON(request.user)
else:
response['data']['user'] = {'name': 'Guest'}
response['data']['user'] = {'name': 'Guest', 'group': 'guest', 'preferences': {}}
return render_to_json_response(response)
def api_error(request):
@ -463,7 +464,7 @@ def api_encodingSettings(request):
'data': {'options': {'videoQuality':...}}}
'''
response = {'status': {'code': 200, 'text': 'ok'}}
response['data'] = {'options': {'preset': 'padma'}}
response['data'] = {'options': settings.VIDEO_ENCODING[settings.VIDEO_PROFILE]}
return render_to_json_response(response)
class UploadForm(forms.Form):
@ -515,8 +516,9 @@ def firefogg_upload(request):
#FIXME: what to do if requested oshash is not in db?
#FIXME: should existing data be reset here? or better, should this fail if an upload was there
f = get_object_or_404(models.File, oshash=request.POST['oshash'])
if f.stream96p:
f.stream96p.delete()
stream = getattr(f, 'stream_%s'%settings.VIDEO_UPLOAD)
if stream:
stream.delete()
f.available = False
f.save()
response = {

View file

@ -28,6 +28,11 @@ def getUserJSON(user):
json = {}
for key in ('username', ):
json[key] = getattr(user, key)
json['group'] = 'user'
if user.is_staff:
json['group'] = 'admin'
elif user.has_perm('0x.vip'): #FIXME: permissions
json['group'] = 'vip'
json['preferences'] = getPreferences(user)
return json

View file

@ -4,7 +4,9 @@
import os
from os.path import join
SITENAME = 'Pad.ma'
SITENAME = 'Oxdb'
URL = 'Oxdb.org'
PROJECT_ROOT = os.path.normpath(os.path.dirname(__file__))
DEBUG = True
@ -109,11 +111,14 @@ BROKER_PASSWORD = "0xdb"
BROKER_VHOST = "/oxdb"
#Video encoding settings
VIDEO96P = {'height': 96, 'videoBitrate': 180, 'softTarget': True,
'samplerate': 44100, 'audioQuality': -1, 'channels': 1, 'noUpscaling': True}
VIDEO320 = {'maxSize': 320, 'videoBitrate': 500,
'samplerate': 44100, 'audioQuality': 0, 'channels': 1, 'noUpscaling': True}
VIDEO640 = {'profile': 'padma'}
VIDEO_PROFILE = 'low' # possible values low, mid or high
VIDEO_ENCODING = {
'low': {'height': 96, 'videoBitrate': 180, 'softTarget': True,
'samplerate': 44100, 'audioQuality': -1, 'channels': 1, 'noUpscaling': True},
'mid': {'maxSize': 320, 'videoBitrate': 500,
'samplerate': 44100, 'audioQuality': 0, 'channels': 1, 'noUpscaling': True},
'high': {'profile': 'padma'}
}
#overwrite default settings with local settings
try:

View file

@ -1,6 +1,29 @@
$(function() {
Ox.initLoading();
oxdb = {};
var oxdb = new Ox.App({
requestURL: "/api/"
}),
$dialog = new Ox.Dialog({
title: "Application Error",
buttons: [
{
value: "Change Title",
click: function() {
Ox.print("click to change title")
$dialog.options({
title: "New Title"
});
$dialog.$buttons[0].toggleDisabled();
}
},
{
value: "Close",
click: function() {
$dialog.close();
}
}
]
});
var user = {
username: "",

View file

@ -1,16 +1,15 @@
<!DOCTYPE html>
<html>
<head>
<title>0xdb.org</title>
<title>{{settings.SITENAME}}</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<script type="text/javascript" src="/static/js/jquery/jquery.js"></script>
<script type="text/javascript" src="/static/oxjs/js/ox.js"></script>
<script type="text/javascript" src="/static/oxjs/js/ox.ui.js"></script>
<script type="text/javascript" src="/static/oxjs/js/ox.iso.js"></script>
<script type="text/javascript" src="/static/oxjs/js/ox.unicode.js"></script>
<script type="text/javascript" src="/static/js/ui.js"></script>
<link rel="stylesheet" type="text/css" href="/static/oxjs/css/ox.css"/>
<link rel="stylesheet" type="text/css" href="/static/css/ui.css"/>
<link rel="stylesheet" type="text/css" href="/static/oxjs/build/css/ox.ui.css"/>
<script type="text/javascript" src="/static/oxjs/build/js/jquery-1.4.js"></script>
<script type="text/javascript" src="/static/oxjs/build/js/ox.js"></script>
<script type="text/javascript" src="/static/oxjs/build/js/ox.ui.js"></script>
<script type="text/javascript" src="/site.js"></script>
<script type="text/javascript" src="/static/js/oxdb.js"></script>
</head>
<body>
</body>

View file

@ -11,6 +11,7 @@ urlpatterns = patterns('',
# Example:
(r'^ajax_filtered_fields/', include('ajax_filtered_fields.urls')),
(r'^api/', include('backend.urls')),
(r'^site.js$', 'app.views.site_js'),
(r'^$', 'app.views.index'),
(r'^r/(?P<key>.*)$', 'oxuser.views.recover'),