From d74a264a6a407d1956bbe14ceeb6f3aa65c4ab30 Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Mon, 18 Nov 2013 09:52:44 +0000 Subject: [PATCH] use direct download for private items. Torrents only work if item is public --- static/js/editor.js | 4 ++-- static/js/player.js | 4 ++-- static/js/utils.js | 10 ++++++++-- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/static/js/editor.js b/static/js/editor.js index e3c6666a..ad6b9c85 100644 --- a/static/js/editor.js +++ b/static/js/editor.js @@ -127,8 +127,8 @@ pandora.ui.editor = function(data) { pandora.$ui[dialog] && pandora.$ui[dialog].remove(); pandora.$ui[dialog] = pandora.ui[dialog](data).open(); }, - downloadvideo: function(data) { - document.location.href = pandora.getDownloadLink(ui.item); + downloadvideo: function() { + document.location.href = pandora.getDownloadLink(ui.item, data.rightslevel); }, downloadselection: function(data) { document.location.href = '/' + ui.item diff --git a/static/js/player.js b/static/js/player.js index b93c7e82..26b4c7f4 100644 --- a/static/js/player.js +++ b/static/js/player.js @@ -83,8 +83,8 @@ pandora.ui.player = function(data) { return clip.annotation || ui.item + '/' + clip['in'] + '-' + clip.out; }), 'clip'); }, - downloadvideo: function(data) { - document.location.href = pandora.getDownloadLink(ui.item); + downloadvideo: function() { + document.location.href = pandora.getDownloadLink(ui.item, data.rightslevel); }, find: function(data) { pandora.UI.set({itemFind: data.find}); diff --git a/static/js/utils.js b/static/js/utils.js index 68a3d204..1661077a 100644 --- a/static/js/utils.js +++ b/static/js/utils.js @@ -928,8 +928,14 @@ pandora.getClipVideos = function(clip, resolution) { }; }()); -pandora.getDownloadLink = function(item) { - return '/' + item + (pandora.site.video.torrent ? '/torrent/' : '/download/'); +pandora.getDownloadLink = function(item, rightslevel) { + console.log('pandora.getDownloadLink', item, rightslevel); + var torrent = pandora.site.video.torrent; + if (arguments.length == 2 && torrent && + pandora.site.capabilities.canSeeItem.guest < rightslevel) { + torrent = false; + } + return '/' + item + (torrent ? '/torrent/' : '/download/'); } pandora.getEditTooltip = function(title) {