From 139825168f81ee0a0082a397800546cbbf8533bc Mon Sep 17 00:00:00 2001 From: calzoneman Date: Sun, 11 Jan 2015 12:10:09 -0600 Subject: [PATCH] Fix for private, but embeddable soundcloud tracks --- lib/database.js | 3 ++- lib/database/channels.js | 3 ++- lib/get-info.js | 6 +++++- lib/media.js | 3 ++- www/js/player.js | 8 +++++--- 5 files changed, 16 insertions(+), 7 deletions(-) diff --git a/lib/database.js b/lib/database.js index b77b68f8..ac4e0678 100644 --- a/lib/database.js +++ b/lib/database.js @@ -409,7 +409,8 @@ module.exports.saveUserPlaylist = function (pl, username, plname, callback) { type: pl[i].media.type, meta: { codec: pl[i].media.meta.codec, - bitrate: pl[i].media.meta.bitrate + bitrate: pl[i].media.meta.bitrate, + scuri: pl[i].media.meta.scuri } }; time += pl[i].media.seconds || 0; diff --git a/lib/database/channels.js b/lib/database/channels.js index dd68f083..30e99b31 100644 --- a/lib/database/channels.js +++ b/lib/database/channels.js @@ -426,7 +426,8 @@ module.exports = { var meta = JSON.stringify({ bitrate: media.meta.bitrate, - codec: media.meta.codec + codec: media.meta.codec, + scuri: media.meta.scuri }); db.query("INSERT INTO `channel_libraries` " + diff --git a/lib/get-info.js b/lib/get-info.js index 186809be..504427d9 100644 --- a/lib/get-info.js +++ b/lib/get-info.js @@ -552,7 +552,11 @@ var Getters = { data = JSON.parse(data); var seconds = data.duration / 1000; var title = data.title; - var media = new Media(id, title, seconds, "sc"); + var meta = {}; + if (data.sharing === "private" && data.embeddable_by === "all") { + meta.scuri = data.uri; + } + var media = new Media(id, title, seconds, "sc", meta); callback(false, media); } catch(e) { callback(e, null); diff --git a/lib/media.js b/lib/media.js index 442481c1..4faec19e 100644 --- a/lib/media.js +++ b/lib/media.js @@ -36,7 +36,8 @@ Media.prototype = { gpdirect: this.meta.gpdirect, restricted: this.meta.restricted, codec: this.meta.codec, - bitrate: this.meta.bitrate + bitrate: this.meta.bitrate, + scuri: this.meta.scuri } }; }, diff --git a/www/js/player.js b/www/js/player.js index 7431bb59..9ab9fe9a 100644 --- a/www/js/player.js +++ b/www/js/player.js @@ -441,6 +441,7 @@ var SoundcloudPlayer = function (data) { // Go figure self.soundcloudIsSeriouslyFuckingBroken = VOLUME; self.videoId = data.id; + self.scuri = data.meta.scuri || self.videoId; self.videoLength = data.seconds; waitUntilDefined(window, "SC", function () { unfixSoundcloudShit(); @@ -449,7 +450,7 @@ var SoundcloudPlayer = function (data) { iframe.appendTo($("#ytapiplayer")); iframe.attr("id", "scplayer"); - iframe.attr("src", "https://w.soundcloud.com/player/?url="+self.videoId); + iframe.attr("src", "https://w.soundcloud.com/player/?url="+self.scuri); iframe.css("height", "166px"); iframe.css("border", "none"); @@ -469,7 +470,7 @@ var SoundcloudPlayer = function (data) { self.player = SC.Widget("scplayer"); self.player.bind(SC.Widget.Events.READY, function () { - self.player.load(self.videoId, { auto_play: true }); + self.player.load(self.scuri, { auto_play: true }); self.player.bind(SC.Widget.Events.PAUSE, function () { PLAYER.paused = true; @@ -500,9 +501,10 @@ var SoundcloudPlayer = function (data) { self.load = function (data) { self.videoId = data.id; + self.scuri = data.meta.scuri || self.videoId; self.videoLength = data.seconds; if(self.player && self.player.load) { - self.player.load(data.id, { auto_play: true }); + self.player.load(self.scuri, { auto_play: true }); var soundcloudNeedsToFuckingFixTheirPlayer = function () { self.setVolume(VOLUME); self.player.unbind(SC.Widget.Events.PLAY_PROGRESS);