+
diff --git a/htdocs/js/mpd.js b/htdocs/js/mpd.js
index 03fe6ab..db738d1 100644
--- a/htdocs/js/mpd.js
+++ b/htdocs/js/mpd.js
@@ -112,7 +112,6 @@ var app = $.sammy(function() {
$('#panel-heading').text("Search: "+searchstr);
});
-
this.get(/\#\/dirble\/(\d+)\/(\d+)/, function() {
if (TOKEN === "") context.redirect("#/0");
@@ -139,14 +138,9 @@ var app = $.sammy(function() {
dirble_stations = true;
- if(dirble_api_token) {
- dirble_load_stations();
- } else {
- getDirbleApiToken();
- }
+ if (dirble_api_token) { dirble_load_stations(); }
});
-
this.get(/\#\/dirble\//, function() {
if (TOKEN === "") context.redirect("#/0");
@@ -165,11 +159,7 @@ var app = $.sammy(function() {
dirble_stations = false;
- if(dirble_api_token) {
- dirble_load_categories();
- } else {
- getDirbleApiToken();
- }
+ if (dirble_api_token) { dirble_load_categories(); }
});
this.get("/", function(context) {
@@ -268,7 +258,6 @@ $(document).ready(function(){
if (TOKEN === "") $('#dirble').addClass('hide');
});
-
function webSocketConnect() {
if (typeof MozWebSocket != "undefined") {
socket = new MozWebSocket(get_appropriate_ws_url());
@@ -286,7 +275,9 @@ function webSocketConnect() {
app.run();
/* emit initial request for output names */
- socket.send("MPD_API_GET_OUTPUTS");
+ socket.send('MPD_API_GET_OUTPUTS');
+ /* emit initial request for dirble api token */
+ socket.send('MPD_API_GET_DIRBLEAPITOKEN');
}
socket.onmessage = function got_packet(msg) {
@@ -297,7 +288,7 @@ function webSocketConnect() {
switch (obj.type) {
- case "queue":
+ case 'queue':
if(current_app !== 'queue')
break;
@@ -371,14 +362,14 @@ function webSocketConnect() {
};
//Make queue table sortable
- $("#salamisandwich > tbody").sortable({
+ $('#salamisandwich > tbody').sortable({
helper: fixHelperModified,
stop: function(event,ui) {renumber_table('#salamisandwich',ui.item)}
}).disableSelection();
break;
- case "search":
+ case 'search':
$('#wait').modal('hide');
- case "browse":
+ case 'browse':
if(current_app !== 'browse' && current_app !== 'search')
break;
@@ -391,7 +382,7 @@ function webSocketConnect() {
}
for (var item in obj.data) {
switch(obj.data[item].type) {
- case "directory":
+ case 'directory':
var clazz = 'dir';
if (filter !== undefined) {
var first = obj.data[item].dir[0];
@@ -406,12 +397,11 @@ function webSocketConnect() {
$('#salamisandwich > tbody').append(
"
" +
" | " +
- "" + basename(obj.data[item].dir) + " | " +
- " | | " +
+ "" + basename(obj.data[item].dir) + " | " +
" | |
"
);
break;
- case "playlist":
+ case 'playlist':
var clazz = 'plist';
if (filter !== "||") {
clazz += ' hide';
@@ -419,16 +409,21 @@ function webSocketConnect() {
$('#salamisandwich > tbody').append(
"
" +
" | " +
- "" + basename(obj.data[item].plist) + " | " +
- " | | " +
+ "" + basename(obj.data[item].plist) + " | " +
" | |
"
);
break;
- case "song":
+ case 'song':
var minutes = Math.floor(obj.data[item].duration / 60);
var seconds = obj.data[item].duration - minutes * 60;
- $('#salamisandwich > tbody').append(
+ if (typeof obj.data[item].artist === 'undefined') {
+ var details = "
" + obj.data[item].title + " | ";
+ } else {
+ var details = "
" + obj.data[item].artist + " " + obj.data[item].album + " | " + obj.data[item].title + " | ";
+ }
+
+ $('#salamisandwich > tbody').append(
"
" +
" | " +
"" + obj.data[item].title + " | " +
@@ -438,14 +433,13 @@ function webSocketConnect() {
" |
"
);
break;
- case "wrap":
+ case 'wrap':
if(current_app == 'browse') {
$('#next').removeClass('hide');
} else {
$('#salamisandwich > tbody').append(
- "
| " +
- "Too many results, please refine your search! | " +
- " | | " +
+ "
| " +
+ "Too many results, please refine your search! | " +
" | |
"
);
}
@@ -466,7 +460,7 @@ function webSocketConnect() {
socket.send(onClickAction + "," + decodeURI($(this).parents("tr").attr("uri")));
$('.top-right').notify({
message:{
- text: $('td:nth-child(2)', $(this).parents("tr")).text() + " added"
+ text: "\"" + $('td:nth-last-child(3)', $(this).parents("tr")).text() + "\" added"
} }).show();
}).fadeTo('fast',1);
}
@@ -500,7 +494,7 @@ function webSocketConnect() {
socket.send("MPD_API_ADD_TRACK," + decodeURI($(this).attr("uri")));
$('.top-right').notify({
message:{
- text: $('td:nth-child(2)', this).text() + " added"
+ text: "\"" + $('td:nth-last-child(3)', this).text() + "\" added"
}
}).show();
break;
@@ -508,7 +502,7 @@ function webSocketConnect() {
socket.send("MPD_API_ADD_PLAYLIST," + decodeURI($(this).attr("uri")));
$('.top-right').notify({
message:{
- text: "Playlist " + $('td:nth-child(2)', this).text() + " added"
+ text: "\"" + $('td:nth-last-child(3)', this).text() + "\" added"
}
}).show();
break;
@@ -517,7 +511,7 @@ function webSocketConnect() {
});
break;
- case "state":
+ case 'state':
updatePlayIcon(obj.data.state);
updateVolumeIcon(obj.data.volume);
@@ -571,16 +565,20 @@ function webSocketConnect() {
last_state = obj;
break;
- case "outputnames":
+ case 'outputnames':
$('#btn-outputs-block button').remove();
- $.each(obj.data, function(id, name){
- var btn = $('
');
- btn.appendTo($('#btn-outputs-block'));
- });
+ if (obj.data.length > 1) {
+ $.each(obj.data, function(id, name){
+ var btn = $('
');
+ btn.appendTo($('#btn-outputs-block'));
+ });
+ } else {
+ $('#btn-outputs-block').addClass('hide');
+ }
/* remove cache, since the buttons have been recreated */
last_outputs = '';
break;
- case "outputs":
+ case 'outputs':
if(JSON.stringify(obj) === JSON.stringify(last_outputs))
break;
$.each(obj.data, function(id, enabled){
@@ -591,7 +589,7 @@ function webSocketConnect() {
});
last_outputs = obj;
break;
- case "disconnected":
+ case 'disconnected':
if($('.top-right').has('div').length == 0)
$('.top-right').notify({
message:{text:"ympd lost connection to MPD "},
@@ -599,11 +597,11 @@ function webSocketConnect() {
fadeOut: { enabled: true, delay: 1000 },
}).show();
break;
- case "update_queue":
+ case 'update_queue':
if(current_app === 'queue')
socket.send('MPD_API_GET_QUEUE,'+pagination);
break;
- case "song_change":
+ case 'song_change':
$('#album').text("");
$('#artist').text("");
@@ -631,23 +629,27 @@ function webSocketConnect() {
}).show();
break;
- case "mpdhost":
+ case 'mpdhost':
$('#mpdhost').val(obj.data.host);
setLocalStream(obj.data.host);
$('#mpdport').val(obj.data.port);
if(obj.data.passwort_set)
$('#mpd_password_set').removeClass('hide');
break;
- case "dirbleapitoken":
+ case 'dirbleapitoken':
dirble_api_token = obj.data;
- if(dirble_stations) {
- dirble_load_stations();
+ if (dirble_api_token) {
+ $('#dirble').removeClass('hide');
+
+ if (dirble_stations) { dirble_load_stations(); }
+ else { dirble_load_categories(); }
+
} else {
- dirble_load_categories();
- }
+ $('#dirble').addClass('hide');
+ }
break;
- case "error":
+ case 'error':
$('.top-right').notify({
message:{text: obj.data},
type: "danger",
@@ -655,9 +657,8 @@ function webSocketConnect() {
default:
break;
}
-
-
}
+
socket.onclose = function(){
console.log("disconnected");
$('.top-right').notify({
@@ -898,10 +899,6 @@ function getHost() {
$('#mpd_pw_con').keypress(onEnter);
}
-function getDirbleApiToken() {
- socket.send('MPD_API_GET_DIRBLEAPITOKEN');
-}
-
$('#search').submit(function () {
app.setLocation("#/search/"+$('#search > div > input').val());
$('#wait').modal('show');
diff --git a/src/mpd_client.c b/src/mpd_client.c
index 80f15e1..a5ebf28 100644
--- a/src/mpd_client.c
+++ b/src/mpd_client.c
@@ -595,18 +595,10 @@ int mpd_put_current_song(char *buffer)
cur += json_emit_int(cur, end - cur, mpd_song_get_pos(song));
cur += json_emit_raw_str(cur, end - cur, ",\"title\":");
cur += json_emit_quoted_str(cur, end - cur, mpd_get_title(song));
-
- if(mpd_song_get_tag(song, MPD_TAG_ARTIST, 0) != NULL)
- {
- cur += json_emit_raw_str(cur, end - cur, ",\"artist\":");
- cur += json_emit_quoted_str(cur, end - cur, mpd_song_get_tag(song, MPD_TAG_ARTIST, 0));
- }
-
- if(mpd_song_get_tag(song, MPD_TAG_ALBUM, 0) != NULL)
- {
- cur += json_emit_raw_str(cur, end - cur, ",\"album\":");
- cur += json_emit_quoted_str(cur, end - cur, mpd_song_get_tag(song, MPD_TAG_ALBUM, 0));
- }
+ cur += json_emit_raw_str(cur, end - cur, ",\"artist\":");
+ cur += json_emit_quoted_str(cur, end - cur, mpd_get_artist(song));
+ cur += json_emit_raw_str(cur, end - cur, ",\"album\":");
+ cur += json_emit_quoted_str(cur, end - cur, mpd_get_album(song));
cur += json_emit_raw_str(cur, end - cur, "}}");
mpd_song_free(song);
@@ -644,6 +636,10 @@ int mpd_put_queue(char *buffer, unsigned int offset)
cur += json_emit_quoted_str(cur, end - cur, mpd_get_album(song));
cur += json_emit_raw_str(cur, end - cur, ",\"title\":");
cur += json_emit_quoted_str(cur, end - cur, mpd_get_title(song));
+ cur += json_emit_raw_str(cur, end - cur, ",\"artist\":");
+ cur += json_emit_quoted_str(cur, end - cur, mpd_get_artist(song));
+ cur += json_emit_raw_str(cur, end - cur, ",\"album\":");
+ cur += json_emit_quoted_str(cur, end - cur, mpd_get_album(song));
cur += json_emit_raw_str(cur, end - cur, "},");
}
mpd_entity_free(entity);
@@ -766,6 +762,10 @@ int mpd_search(char *buffer, char *searchstr)
cur += json_emit_int(cur, end - cur, mpd_song_get_duration(song));
cur += json_emit_raw_str(cur, end - cur, ",\"title\":");
cur += json_emit_quoted_str(cur, end - cur, mpd_get_title(song));
+ cur += json_emit_raw_str(cur, end - cur, ",\"artist\":");
+ cur += json_emit_quoted_str(cur, end - cur, mpd_get_artist(song));
+ cur += json_emit_raw_str(cur, end - cur, ",\"album\":");
+ cur += json_emit_quoted_str(cur, end - cur, mpd_get_album(song));
cur += json_emit_raw_str(cur, end - cur, "},");
mpd_song_free(song);
diff --git a/src/ympd.c b/src/ympd.c
index 81e28b0..8d3f90d 100644
--- a/src/ympd.c
+++ b/src/ympd.c
@@ -95,8 +95,6 @@ int main(int argc, char **argv)
mpd.gpass = NULL;
strcpy(mpd.host, "127.0.0.1");
- strcpy(dirble_api_token, "2e223c9909593b94fc6577361a");
-
static struct option long_options[] = {
{"digest", required_argument, 0, 'D'},
{"host", required_argument, 0, 'h'},