forked from 0x2620/pandora
site.js, cleanup stream names again
This commit is contained in:
parent
fc4285933a
commit
3d36da45af
8 changed files with 90 additions and 52 deletions
|
@ -6,6 +6,9 @@ from django.conf import settings
|
||||||
|
|
||||||
|
|
||||||
def index(request):
|
def index(request):
|
||||||
context = RequestContext(request, {})
|
context = RequestContext(request, {'settings':settings})
|
||||||
return render_to_response('index.html', context)
|
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")
|
||||||
|
|
|
@ -306,9 +306,9 @@ class Movie(models.Model):
|
||||||
#stream related fields
|
#stream related fields
|
||||||
'''
|
'''
|
||||||
'''
|
'''
|
||||||
stream96p = models.FileField(default=None, blank=True, upload_to=lambda f, x: movie_path(f, '96p'))
|
stream_low = models.FileField(default=None, blank=True, upload_to=lambda f, x: movie_path(f, 'low'))
|
||||||
stream320 = models.FileField(default=None, blank=True, upload_to=lambda f, x: movie_path(f, '320'))
|
stream_mid = models.FileField(default=None, blank=True, upload_to=lambda f, x: movie_path(f, 'mid'))
|
||||||
stream640 = models.FileField(default=None, blank=True, upload_to=lambda f, x: movie_path(f, '640'))
|
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???
|
#FIXME: is this still required? should this not be aspect ratio? depends on stream???
|
||||||
scene_height = models.IntegerField(null=True, blank=True)
|
scene_height = models.IntegerField(null=True, blank=True)
|
||||||
|
|
||||||
|
@ -612,10 +612,10 @@ class MovieSort(models.Model):
|
||||||
resolution = models.IntegerField(blank=True)
|
resolution = models.IntegerField(blank=True)
|
||||||
aspectratio = models.IntegerField('Aspect Ratio', blank=True)
|
aspectratio = models.IntegerField('Aspect Ratio', blank=True)
|
||||||
bitrate = models.IntegerField(blank=True)
|
bitrate = models.IntegerField(blank=True)
|
||||||
pixels = models.IntegerField(blank=True)
|
pixels = models.BigIntegerField(blank=True)
|
||||||
filename = models.IntegerField(blank=True)
|
filename = models.IntegerField(blank=True)
|
||||||
files = models.IntegerField(blank=True)
|
files = models.IntegerField(blank=True)
|
||||||
size = models.IntegerField(blank=True)
|
size = models.BigIntegerField(blank=True)
|
||||||
|
|
||||||
_private_fields = ('id', 'movie')
|
_private_fields = ('id', 'movie')
|
||||||
#return available sort fields
|
#return available sort fields
|
||||||
|
@ -923,7 +923,7 @@ class Review(models.Model):
|
||||||
if q.count() > 0:
|
if q.count() > 0:
|
||||||
o = q[0]
|
o = q[0]
|
||||||
else:
|
else:
|
||||||
o = self.objects.create(movie=movie, url=url)
|
o = self.objects.create(movie=movie, url=g)
|
||||||
o.save()
|
o.save()
|
||||||
return o
|
return o
|
||||||
get_or_create = classmethod(get_or_create)
|
get_or_create = classmethod(get_or_create)
|
||||||
|
@ -1044,17 +1044,17 @@ class File(models.Model):
|
||||||
|
|
||||||
#stream related fields
|
#stream related fields
|
||||||
available = models.BooleanField(default=False)
|
available = models.BooleanField(default=False)
|
||||||
stream96p = models.FileField(default=None, upload_to=lambda f, x: stream_path(f, '96p'))
|
stream_low = models.FileField(default=None, upload_to=lambda f, x: stream_path(f, 'low'))
|
||||||
stream320 = models.FileField(default=None, upload_to=lambda f, x: stream_path(f, '320'))
|
stream_mid = models.FileField(default=None, upload_to=lambda f, x: stream_path(f, 'mid'))
|
||||||
stream640 = models.FileField(default=None, upload_to=lambda f, x: stream_path(f, '640'))
|
stream_high = models.FileField(default=None, upload_to=lambda f, x: stream_path(f, 'high'))
|
||||||
|
|
||||||
def timeline_base_url(self):
|
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'):
|
def save_chunk(self, chunk, name='video.ogv'):
|
||||||
if not self.available:
|
if not self.available:
|
||||||
#FIXME: this should use stream96p or stream640 depending on configuration
|
#FIXME: this should use stream_low or stream_high depending on configuration
|
||||||
video = getattr(self, 'stream96p')
|
video = getattr(self, 'stream_%s'%settings.VIDEO_PROFILE)
|
||||||
if not video:
|
if not video:
|
||||||
video.save(name, chunk)
|
video.save(name, chunk)
|
||||||
self.save()
|
self.save()
|
||||||
|
@ -1116,12 +1116,12 @@ class File(models.Model):
|
||||||
self.save()
|
self.save()
|
||||||
|
|
||||||
def extract_timeline(self):
|
def extract_timeline(self):
|
||||||
if self.stream640:
|
if self.stream_high:
|
||||||
video = self.stream640.path
|
video = self.stream_high.path
|
||||||
elif stream320:
|
elif self.stream_mid:
|
||||||
video = self.stream320.path
|
video = self.stream_mid.path
|
||||||
elif stream96p:
|
elif self.stream_low:
|
||||||
video = self.stream96p.path
|
video = self.stream_low.path
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
prefix = os.path.join(os.path.dirname(video), 'timeline')
|
prefix = os.path.join(os.path.dirname(video), 'timeline')
|
||||||
|
@ -1132,19 +1132,19 @@ class File(models.Model):
|
||||||
|
|
||||||
def extract_video(self):
|
def extract_video(self):
|
||||||
ogg = Firefogg()
|
ogg = Firefogg()
|
||||||
if self.stream640:
|
if self.stream_high:
|
||||||
#320 stream
|
#mid stream
|
||||||
self.stream320.name = stream_path(self, '320')
|
self.stream_mid.name = stream_path(self, 'mid')
|
||||||
self.stream320.save()
|
self.stream_mid.save()
|
||||||
ogg.encode(self.stream640.path, self.stream320.path, settings.VIDEO320)
|
ogg.encode(self.stream_height.path, self.stream_mid.path, settings.VIDEO_MID)
|
||||||
#96p stream
|
#low stream
|
||||||
self.stream96p.name = stream_path(self, '96p')
|
self.stream_low.name = stream_path(self, 'low')
|
||||||
self.stream96p.save()
|
self.stream_low.save()
|
||||||
ogg.encode(self.stream640.path, self.stream96p.path, settings.VIDEO96P)
|
ogg.encode(self.stream_high.path, self.stream_low.path, settings.VIDEO_LOW)
|
||||||
elif self.stream320:
|
elif self.stream_mid:
|
||||||
self.stream96p.name = stream_path(self, '96p')
|
self.stream_low.name = stream_path(self, 'low')
|
||||||
self.stream96p.save()
|
self.stream_low.save()
|
||||||
ogg.encode(self.stream320.path, self.stream96p.path, settings.VIDEO96P)
|
ogg.encode(self.stream_mid.path, self.stream_low.path, settings.VIDEO_LOW)
|
||||||
|
|
||||||
def extract(self):
|
def extract(self):
|
||||||
#FIXME: do stuff, like create timeline or create smaller videos etc
|
#FIXME: do stuff, like create timeline or create smaller videos etc
|
||||||
|
|
|
@ -14,6 +14,7 @@ from django.db.models import Q, Avg, Count
|
||||||
from django.http import HttpResponse
|
from django.http import HttpResponse
|
||||||
from django.shortcuts import render_to_response, get_object_or_404, get_list_or_404
|
from django.shortcuts import render_to_response, get_object_or_404, get_list_or_404
|
||||||
from django.template import RequestContext
|
from django.template import RequestContext
|
||||||
|
from django.conf import settings
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import simplejson as json
|
import simplejson as json
|
||||||
|
@ -62,7 +63,7 @@ def api_hello(request):
|
||||||
if request.user.is_authenticated():
|
if request.user.is_authenticated():
|
||||||
response['data']['user'] = getUserJSON(request.user)
|
response['data']['user'] = getUserJSON(request.user)
|
||||||
else:
|
else:
|
||||||
response['data']['user'] = {'name': 'Guest'}
|
response['data']['user'] = {'name': 'Guest', 'group': 'guest', 'preferences': {}}
|
||||||
return render_to_json_response(response)
|
return render_to_json_response(response)
|
||||||
|
|
||||||
def api_error(request):
|
def api_error(request):
|
||||||
|
@ -463,7 +464,7 @@ def api_encodingSettings(request):
|
||||||
'data': {'options': {'videoQuality':...}}}
|
'data': {'options': {'videoQuality':...}}}
|
||||||
'''
|
'''
|
||||||
response = {'status': {'code': 200, 'text': 'ok'}}
|
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)
|
return render_to_json_response(response)
|
||||||
|
|
||||||
class UploadForm(forms.Form):
|
class UploadForm(forms.Form):
|
||||||
|
@ -515,8 +516,9 @@ def firefogg_upload(request):
|
||||||
#FIXME: what to do if requested oshash is not in db?
|
#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
|
#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'])
|
f = get_object_or_404(models.File, oshash=request.POST['oshash'])
|
||||||
if f.stream96p:
|
stream = getattr(f, 'stream_%s'%settings.VIDEO_UPLOAD)
|
||||||
f.stream96p.delete()
|
if stream:
|
||||||
|
stream.delete()
|
||||||
f.available = False
|
f.available = False
|
||||||
f.save()
|
f.save()
|
||||||
response = {
|
response = {
|
||||||
|
|
|
@ -28,6 +28,11 @@ def getUserJSON(user):
|
||||||
json = {}
|
json = {}
|
||||||
for key in ('username', ):
|
for key in ('username', ):
|
||||||
json[key] = getattr(user, key)
|
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)
|
json['preferences'] = getPreferences(user)
|
||||||
return json
|
return json
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,9 @@
|
||||||
import os
|
import os
|
||||||
from os.path import join
|
from os.path import join
|
||||||
|
|
||||||
SITENAME = 'Pad.ma'
|
SITENAME = 'Oxdb'
|
||||||
|
URL = 'Oxdb.org'
|
||||||
|
|
||||||
PROJECT_ROOT = os.path.normpath(os.path.dirname(__file__))
|
PROJECT_ROOT = os.path.normpath(os.path.dirname(__file__))
|
||||||
|
|
||||||
DEBUG = True
|
DEBUG = True
|
||||||
|
@ -109,11 +111,14 @@ BROKER_PASSWORD = "0xdb"
|
||||||
BROKER_VHOST = "/oxdb"
|
BROKER_VHOST = "/oxdb"
|
||||||
|
|
||||||
#Video encoding settings
|
#Video encoding settings
|
||||||
VIDEO96P = {'height': 96, 'videoBitrate': 180, 'softTarget': True,
|
VIDEO_PROFILE = 'low' # possible values low, mid or high
|
||||||
'samplerate': 44100, 'audioQuality': -1, 'channels': 1, 'noUpscaling': True}
|
VIDEO_ENCODING = {
|
||||||
VIDEO320 = {'maxSize': 320, 'videoBitrate': 500,
|
'low': {'height': 96, 'videoBitrate': 180, 'softTarget': True,
|
||||||
'samplerate': 44100, 'audioQuality': 0, 'channels': 1, 'noUpscaling': True}
|
'samplerate': 44100, 'audioQuality': -1, 'channels': 1, 'noUpscaling': True},
|
||||||
VIDEO640 = {'profile': 'padma'}
|
'mid': {'maxSize': 320, 'videoBitrate': 500,
|
||||||
|
'samplerate': 44100, 'audioQuality': 0, 'channels': 1, 'noUpscaling': True},
|
||||||
|
'high': {'profile': 'padma'}
|
||||||
|
}
|
||||||
|
|
||||||
#overwrite default settings with local settings
|
#overwrite default settings with local settings
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -1,6 +1,29 @@
|
||||||
$(function() {
|
$(function() {
|
||||||
Ox.initLoading();
|
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 = {
|
var user = {
|
||||||
username: "",
|
username: "",
|
||||||
|
|
|
@ -1,16 +1,15 @@
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>0xdb.org</title>
|
<title>{{settings.SITENAME}}</title>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
|
||||||
<script type="text/javascript" src="/static/js/jquery/jquery.js"></script>
|
<link rel="stylesheet" type="text/css" href="/static/oxjs/build/css/ox.ui.css"/>
|
||||||
<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/build/js/jquery-1.4.js"></script>
|
||||||
<script type="text/javascript" src="/static/oxjs/js/ox.iso.js"></script>
|
<script type="text/javascript" src="/static/oxjs/build/js/ox.js"></script>
|
||||||
<script type="text/javascript" src="/static/oxjs/js/ox.unicode.js"></script>
|
<script type="text/javascript" src="/static/oxjs/build/js/ox.ui.js"></script>
|
||||||
<script type="text/javascript" src="/static/js/ui.js"></script>
|
<script type="text/javascript" src="/site.js"></script>
|
||||||
<link rel="stylesheet" type="text/css" href="/static/oxjs/css/ox.css"/>
|
<script type="text/javascript" src="/static/js/oxdb.js"></script>
|
||||||
<link rel="stylesheet" type="text/css" href="/static/css/ui.css"/>
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
</body>
|
</body>
|
||||||
|
|
|
@ -11,6 +11,7 @@ urlpatterns = patterns('',
|
||||||
# Example:
|
# Example:
|
||||||
(r'^ajax_filtered_fields/', include('ajax_filtered_fields.urls')),
|
(r'^ajax_filtered_fields/', include('ajax_filtered_fields.urls')),
|
||||||
(r'^api/', include('backend.urls')),
|
(r'^api/', include('backend.urls')),
|
||||||
|
(r'^site.js$', 'app.views.site_js'),
|
||||||
(r'^$', 'app.views.index'),
|
(r'^$', 'app.views.index'),
|
||||||
(r'^r/(?P<key>.*)$', 'oxuser.views.recover'),
|
(r'^r/(?P<key>.*)$', 'oxuser.views.recover'),
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue