From 31713e5f3b15b86d8e087a2bb36041e2090a489e Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Thu, 16 Feb 2012 23:23:23 +0530 Subject: [PATCH 1/4] s --- pandora/padma.jsonc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandora/padma.jsonc b/pandora/padma.jsonc index d430301c8..3836d1ad4 100644 --- a/pandora/padma.jsonc +++ b/pandora/padma.jsonc @@ -564,7 +564,7 @@ "itemFind": {"conditions": [], "operator": "&"}, "itemSort": [{"key": "position", "operator": "+"}], "itemView": "info", - "listColumns": ["title", "source", "project", "topics", "language", "duration"], + "listColumns": ["title", "source", "project", "topic", "language", "duration"], "listColumnWidth": {}, "listSelection": [], "listSort": [{"key": "title", "operator": "+"}], From 81748afa2d0141332939e184cb3c9210a48d5e4f Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Fri, 17 Feb 2012 13:02:04 +0530 Subject: [PATCH 2/4] use stream height by default --- pandora/archive/extract.py | 2 +- pandora/item/models.py | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/pandora/archive/extract.py b/pandora/archive/extract.py index a5a645257..19c763729 100644 --- a/pandora/archive/extract.py +++ b/pandora/archive/extract.py @@ -241,7 +241,7 @@ def frame(videoFile, frame, position, height=128, redo=False): videoFile input frame output position as float in seconds - width of frame + height of frame redo boolean to extract file even if it exists ''' if exists(videoFile): diff --git a/pandora/item/models.py b/pandora/item/models.py index 939e3aa84..74ee69d89 100644 --- a/pandora/item/models.py +++ b/pandora/item/models.py @@ -850,7 +850,7 @@ class Item(models.Model): ''' Video related functions ''' - def frame(self, position, height=128): + def frame(self, position, height=None): offset = 0 streams = self.streams() for stream in streams: @@ -858,7 +858,10 @@ class Item(models.Model): offset += stream.duration else: position = position - offset - height = min(height, stream.resolution) + if not height: + height = stream.resolution + else: + height = min(height, stream.resolution) path = os.path.join(settings.MEDIA_ROOT, stream.path(), 'frames', "%dp"%height, "%s.jpg"%position) if not os.path.exists(path) and stream.video: From 719056871408fc17933d07122d05086eb1e855f2 Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Fri, 17 Feb 2012 14:27:21 +0530 Subject: [PATCH 3/4] load subtitles/censor data in embeded player --- static/js/embed/pandora.js | 123 ++++++++++++++++++++++++++----------- static/js/pandora/item.js | 5 +- static/js/pandora/utils.js | 2 +- 3 files changed, 90 insertions(+), 40 deletions(-) diff --git a/static/js/embed/pandora.js b/static/js/embed/pandora.js index 9437a4af3..80cd72080 100755 --- a/static/js/embed/pandora.js +++ b/static/js/embed/pandora.js @@ -15,18 +15,13 @@ Ox.load('UI', { user: data.user.level == 'guest' ? Ox.clone(data.site.user) : data.user, ui: {}, clip: function(options) { - var that = Ox.Element(); - pandora.api.get({id: options.item, keys: []}, function(result) { - var video = {}; - pandora.site.video.resolutions.forEach(function(resolution) { - video[resolution] = Ox.range(result.data.parts).map(function(i) { - var part = (i + 1), - prefix = pandora.site.site.videoprefix.replace('PART', part); - return prefix + '/' + options.item + '/' - + resolution + 'p' + part + '.' + pandora.user.videoFormat; - }); - }); + var that = Ox.Element(), + keys = [ 'duration', 'layers', 'parts', 'posterFrame', 'rightslevel', 'size', 'title', 'videoRatio' ]; + pandora.user.ui.item = options.item; + pandora.api.get({id: options.item, keys: keys}, function(result) { + var videoOptions = getVideoOptions(result.data); that.append(pandora.player = Ox.VideoPlayer({ + censored: videoOptions.censored, controlsBottom: ['play', 'volume', 'scale', 'timeline', 'position', 'settings'], enableFind: false, enableFullscreen: true, @@ -40,13 +35,14 @@ Ox.load('UI', { out: options.out, paused: options.paused, position: options['in'], - poster: '/' + options.item + '/' + '128p' + options['in'] +'.jpg', + poster: '/' + options.item + '/' + '96p' + options['in'] +'.jpg', resolution: pandora.user.ui.videoResolution, showMarkers: false, showMilliseconds: 0, + subtitles: videoOptions.subtitles, timeline: '/' + options.item + '/' + 'timeline16p.png', title: result.data.title, - video: video, + video: videoOptions.video, width: document.width }) .bindEvent({ @@ -60,13 +56,13 @@ Ox.load('UI', { Ox.UI.hideLoadingScreen(); function checkRange(data) { - if(data.position < options['in'] + if(data.position < options['in'] - 0.04 || data.position > options.out) { if(!pandora.player.options('paused')) { pandora.player.togglePaused(); } pandora.player.options({ - position: options['in'], + position: options['in'] }); } } @@ -77,28 +73,6 @@ Ox.load('UI', { Ox.extend(pandora.user, { videoFormat: Ox.UI.getVideoFormat(pandora.site.video.formats) }); - - function parseQuery() { - var vars = window.location.search.length - ? window.location.search.substring(1).split('&') - : [], - query = { - item: window.location.pathname.substring(1).split('/')[0] - }, - defaults = { - view: 'video', - 'in': 0, - out: 10, - paused: true, - item: '' - }; - vars.forEach(function(v) { - v= v.split('='); - query[v[0]] = decodeURIComponent(v[1]); - }); - - return Ox.extend({}, defaults, query); - } var options = parseQuery(); if (options.view == 'video') { pandora.ui.info = pandora.clip(options) @@ -107,4 +81,79 @@ Ox.load('UI', { } } }); + + function getVideoOptions(data) { + var canPlayClips = data.editable || pandora.site.capabilities.canPlayClips[pandora.user.level] >= data.rightslevel, + canPlayVideo = data.editable || pandora.site.capabilities.canPlayVideo[pandora.user.level] >= data.rightslevel, + options = {}; + options.subtitles = data.layers.subtitles + ? data.layers.subtitles.map(function(subtitle) { + return {'in': subtitle['in'], out: subtitle.out, text: subtitle.value}; + }) + : []; + options.censored = canPlayVideo ? [] + : canPlayClips ? ( + options.subtitles.length + ? Ox.merge( + options.subtitles.map(function(subtitle, i) { + return { + 'in': i == 0 ? 0 : options.subtitles[i - 1].out, + out: subtitle['in'] + }; + }), + [{'in': Ox.last(options.subtitles).out, out: data.duration}] + ) + : Ox.range(0, data.duration - 5, 60).map(function(position) { + return { + 'in': position + 5, + out: Math.min(position + 60, data.duration) + }; + }) + ) + : [{'in': 0, out: data.duration}]; + options.video = {}; + pandora.site.video.resolutions.forEach(function(resolution) { + options.video[resolution] = Ox.range(data.parts).map(function(i) { + var part = (i + 1), + prefix = pandora.site.site.videoprefix.replace('{part}', part); + return prefix + '/' + (data.item || pandora.user.ui.item) + '/' + + resolution + 'p' + part + '.' + pandora.user.videoFormat; + }); + }); + options.layers = []; + pandora.site.layers.forEach(function(layer, i) { + options.layers[i] = Ox.extend({}, layer, { + items: data.layers[layer.id].map(function(annotation) { + annotation.duration = Math.abs(annotation.out - annotation['in']); + annotation.editable = annotation.editable + || annotation.user == pandora.user.username + || pandora.site.capabilities['canEditAnnotations'][pandora.user.level]; + return annotation; + }) + }); + }); + return options; + } + + function parseQuery() { + var vars = window.location.search.length + ? window.location.search.substring(1).split('&') + : [], + query = { + item: window.location.pathname.substring(1).split('/')[0] + }, + defaults = { + view: 'video', + 'in': 0, + out: 10, + paused: true, + item: '' + }; + vars.forEach(function(v) { + v= v.split('='); + query[v[0]] = decodeURIComponent(v[1]); + }); + + return Ox.extend({}, defaults, query); + } }); diff --git a/static/js/pandora/item.js b/static/js/pandora/item.js index 438de9757..f8089e9be 100644 --- a/static/js/pandora/item.js +++ b/static/js/pandora/item.js @@ -3,7 +3,8 @@ pandora.ui.item = function() { - var that = Ox.Element(); + var that = Ox.Element(), + videoOptions; pandora.api.get({ id: pandora.user.ui.item, @@ -42,7 +43,7 @@ pandora.ui.item = function() { if (['video', 'timeline'].indexOf(pandora.user.ui.itemView) > -1) { // fixme: layers have value, subtitles has text? - var videoOptions = pandora.getVideoOptions(result.data); + videoOptions = pandora.getVideoOptions(result.data); } if (!result.data.rendered && [ diff --git a/static/js/pandora/utils.js b/static/js/pandora/utils.js index 728bd2ee8..2a5a120a3 100644 --- a/static/js/pandora/utils.js +++ b/static/js/pandora/utils.js @@ -794,7 +794,7 @@ pandora.getVideoOptions = function(data) { pandora.site.video.resolutions.forEach(function(resolution) { options.video[resolution] = Ox.range(data.parts).map(function(i) { var part = (i + 1), - prefix = pandora.site.site.videoprefix.replace('PART', part); // fixme: '{part}' would be more consistent + prefix = pandora.site.site.videoprefix.replace('{part}', part); return prefix + '/' + (data.item || pandora.user.ui.item) + '/' + resolution + 'p' + part + '.' + pandora.user.videoFormat; }); From 112b61dc9abb893a68be8f1d4a520c126e1e3ea6 Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Fri, 17 Feb 2012 14:36:06 +0530 Subject: [PATCH 4/4] add canImportAnnotations capability --- pandora/0xdb.jsonc | 1 + pandora/padma.jsonc | 1 + static/js/pandora/item.js | 1 + 3 files changed, 3 insertions(+) diff --git a/pandora/0xdb.jsonc b/pandora/0xdb.jsonc index c5b8ec3d5..f37a0c655 100644 --- a/pandora/0xdb.jsonc +++ b/pandora/0xdb.jsonc @@ -31,6 +31,7 @@ "canEditPlaces": {"staff": true, "admin": true}, "canEditSitePages": {"staff": true, "admin": true}, "canEditUsers": {"admin": true}, + "canImportAnnotations": {"staff": true, "admin": true}, "canPlayClips": {"guest": 2, "member": 2, "friend": 4, "staff": 4, "admin": 4}, "canPlayVideo": {"guest": 1, "member": 1, "friend": 4, "staff": 4, "admin": 4}, "canSeeDebugMenu": {"staff": true, "admin": true}, diff --git a/pandora/padma.jsonc b/pandora/padma.jsonc index 3836d1ad4..c3a2622c2 100644 --- a/pandora/padma.jsonc +++ b/pandora/padma.jsonc @@ -29,6 +29,7 @@ "canEditPlaces": {"staff": true, "admin": true}, "canEditSitePages": {"staff": true, "admin": true}, "canEditUsers": {"admin": true}, + "canImportAnnotations": {"staff": true, "admin": true}, "canPlayClips": {"guest": 1, "member": 1, "staff": 4, "admin": 4}, "canPlayVideo": {"guest": 1, "member": 1, "staff": 4, "admin": 4}, "canSeeDebugMenu": {"staff": true, "admin": true}, diff --git a/static/js/pandora/item.js b/static/js/pandora/item.js index f8089e9be..3facf4b06 100644 --- a/static/js/pandora/item.js +++ b/static/js/pandora/item.js @@ -241,6 +241,7 @@ pandora.ui.item = function() { cuts: result.data.cuts || [], duration: result.data.duration, enableDownload: pandora.site.capabilities.canDownloadVideo[pandora.user.level] >= result.data.rightslevel, + enableImport: pandora.site.capabilities.canImportAnnotations[pandora.user.level], enableSubtitles: pandora.user.ui.videoSubtitles, find: pandora.user.ui.itemFind, getFrameURL: function(position) {