From 0e47d5c4bc285129693e579fe9f7128ff7df7b5b Mon Sep 17 00:00:00 2001 From: Nofre Date: Tue, 2 Feb 2016 18:47:53 +0100 Subject: [PATCH 1/2] Dirble's token fix --- htdocs/js/mpd.js | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/htdocs/js/mpd.js b/htdocs/js/mpd.js index 51e8fdc..ceb523b 100644 --- a/htdocs/js/mpd.js +++ b/htdocs/js/mpd.js @@ -16,6 +16,8 @@ Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ +var TOKEN = ""; + var socket; var last_state; var last_outputs; @@ -106,6 +108,9 @@ var app = $.sammy(function() { this.get(/\#\/dirble\/(\d+)\/(\d+)/, function() { + + if (TOKEN === "") context.redirect("#/0"); + prepare(); current_app = 'dirble'; $('#breadcrump').removeClass('hide').empty().append("
  • Categories
  • "+dirble_selected_cat+"
  • "); @@ -131,6 +136,9 @@ var app = $.sammy(function() { this.get(/\#\/dirble\//, function() { + + if (TOKEN === "") context.redirect("#/0"); + prepare(); current_app = 'dirble'; $('#breadcrump').removeClass('hide').empty().append("
  • Categories
  • "); @@ -177,6 +185,9 @@ $(document).ready(function(){ else if ($.cookie("notification") === "true") $('#btnnotify').addClass("active") + + if (TOKEN === "") $('#dirble').addClass('hide'); + }); @@ -764,7 +775,7 @@ function dirble_load_categories() { dirble_page = 1; - $.getJSON( "http://api.dirble.com/v2/categories?token=2e223c9909593b94fc6577361a", function( data ) { + $.getJSON( "http://api.dirble.com/v2/categories?token="+TOKEN, function( data ) { $('#dirble_loading').addClass('hide'); @@ -812,7 +823,7 @@ function dirble_load_categories() { function dirble_load_stations() { - $.getJSON( "http://api.dirble.com/v2/category/"+dirble_catid+"/stations?page="+dirble_page+"&per_page=20&token=2e223c9909593b94fc6577361a", function( data ) { + $.getJSON( "http://api.dirble.com/v2/category/"+dirble_catid+"/stations?page="+dirble_page+"&per_page=20&token="+TOKEN, function( data ) { $('#dirble_loading').addClass('hide'); if (data.length == 20) $('#next').removeClass('hide'); @@ -839,7 +850,7 @@ function dirble_load_stations() { click: function() { var _this = $(this); - $.getJSON( "http://api.dirble.com/v2/station/"+$(this).attr("radioid")+"?token=2e223c9909593b94fc6577361a", function( data ) { + $.getJSON( "http://api.dirble.com/v2/station/"+$(this).attr("radioid")+"?token="+TOKEN, function( data ) { socket.send("MPD_API_ADD_TRACK," + data.streams[0].stream); $('.top-right').notify({ @@ -857,7 +868,7 @@ function dirble_load_stations() { "").find('a').click(function(e) { e.stopPropagation(); - $.getJSON( "http://api.dirble.com/v2/station/"+_this.attr("radioid")+"?token=2e223c9909593b94fc6577361a", function( data ) { + $.getJSON( "http://api.dirble.com/v2/station/"+_this.attr("radioid")+"?token="+TOKEN, function( data ) { socket.send("MPD_API_ADD_PLAY_TRACK," + data.streams[0].stream); $('.top-right').notify({ @@ -878,7 +889,7 @@ function dirble_load_stations() { click: function() { var _this = $(this); - $.getJSON( "http://api.dirble.com/v2/station/"+$(this).attr("radioid")+"?token=2e223c9909593b94fc6577361a", function( data ) { + $.getJSON( "http://api.dirble.com/v2/station/"+$(this).attr("radioid")+"?token="+TOKEN, function( data ) { socket.send("MPD_API_ADD_TRACK," + data.streams[0].stream); $('.top-right').notify({ @@ -896,7 +907,7 @@ function dirble_load_stations() { "").find('a').click(function(e) { e.stopPropagation(); - $.getJSON( "http://api.dirble.com/v2/station/"+_this.attr("radioid")+"?token=2e223c9909593b94fc6577361a", function( data ) { + $.getJSON( "http://api.dirble.com/v2/station/"+_this.attr("radioid")+"?token="+TOKEN, function( data ) { socket.send("MPD_API_ADD_PLAY_TRACK," + data.streams[0].stream); $('.top-right').notify({ From 8ef9e58ab00bd27777125efbd6fe2415d2aaafa0 Mon Sep 17 00:00:00 2001 From: Nofre Date: Wed, 3 Feb 2016 18:51:44 +0100 Subject: [PATCH 2/2] README.md updated --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index 9561a80..28e3732 100644 --- a/README.md +++ b/README.md @@ -36,6 +36,11 @@ Usage: ./ympd [OPTION]... --help this help ``` +Dirble support +-------------- + +1. Get an API-key from http://dirble.com +2. Add the key at ```var TOKEN = "";```, in ```mpd.js```. Copyright ---------