From ab2c8f7d0f4cd82d8b0ff51bc69b785837925beb Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Sat, 3 Mar 2012 14:56:35 +0100 Subject: [PATCH] cleanup video url construction, add uid to prefix --- static/js/pandora/clipList.js | 4 +--- static/js/pandora/clipPlayer.js | 4 +--- static/js/pandora/itemClips.js | 4 +--- static/js/pandora/utils.js | 12 ++++++++---- 4 files changed, 11 insertions(+), 13 deletions(-) diff --git a/static/js/pandora/clipList.js b/static/js/pandora/clipList.js index 4faa16d67..5e7d793e3 100644 --- a/static/js/pandora/clipList.js +++ b/static/js/pandora/clipList.js @@ -179,9 +179,7 @@ pandora.ui.clipList = function(videoRatio) { poster: '/' + item + '/' + height + 'p' + points[0] + '.jpg', rewind: true, video: partsAndPoints.parts.map(function(i) { - var part = (i + 1), - prefix = pandora.site.site.videoprefix.replace('{part}', part); - return prefix + '/' + item + '/96p' + part + '.' + pandora.user.videoFormat; + return pandora.getVideoUrl(item, 96, i + 1); }), width: width }) diff --git a/static/js/pandora/clipPlayer.js b/static/js/pandora/clipPlayer.js index 808a9c10f..10861fc73 100644 --- a/static/js/pandora/clipPlayer.js +++ b/static/js/pandora/clipPlayer.js @@ -43,9 +43,7 @@ pandora.ui.clipPlayer = function() { partsAndPoints = pandora.getVideoPartsAndPoints(result.data.durations, points); data[i] = { parts: partsAndPoints.parts.map(function(i) { - var part = (i + 1), - prefix = pandora.site.site.videoprefix.replace('{part}', part); - return prefix + '/' + id + '/96p' + part + '.' + pandora.user.videoFormat; + return pandora.getVideoUrl(item, 96, i + 1); }), points: partsAndPoints.points }; diff --git a/static/js/pandora/itemClips.js b/static/js/pandora/itemClips.js index 6d3d62d76..0360d9749 100644 --- a/static/js/pandora/itemClips.js +++ b/static/js/pandora/itemClips.js @@ -107,9 +107,7 @@ pandora.ui.itemClips = function(options) { poster: '/' + self.options.id + '/' + self.height + 'p' + points[0] + '.jpg', rewind: true, video: partsAndPoints.parts.map(function(i) { - var part = (i + 1), - prefix = pandora.site.site.videoprefix.replace('{part}', part); - return prefix + '/' + self.options.id + '/96p' + part + '.' + pandora.user.videoFormat; + return pandora.getVideoUrl(item, 96, i + 1); }), width: self.width }) diff --git a/static/js/pandora/utils.js b/static/js/pandora/utils.js index 2c6e178d7..d0fdeefcf 100644 --- a/static/js/pandora/utils.js +++ b/static/js/pandora/utils.js @@ -792,6 +792,13 @@ pandora.getSortOperator = function(key) { ) > -1 ? '+' : '-'; }; +pandora.getVideoUrl = function(id, resolution, part) { + var pandora.site.site.videoprefix + .replace('{uid}', Ox.uid()) + .replace('{part}', part); + return prefix + '/' + id + '/' + resolution + 'p' + part + '.' + pandora.user.videoFormat; +} + pandora.getVideoOptions = function(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, @@ -828,10 +835,7 @@ pandora.getVideoOptions = function(data) { 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; + return pandora.getVideoUrl(data.item || pandora.user.ui.item, resolution, i + 1); }); }); options.layers = [];