From 838237d854fa614d60cf7ee227ecfdcd0e299614 Mon Sep 17 00:00:00 2001 From: LaClaro Date: Tue, 11 Nov 2014 18:41:39 +0100 Subject: [PATCH 1/4] Patched files to include more columns in browsing and queue mode --- htdocs/js/mpd.js | 15 +++++++++++---- src/mpd_client.c | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 4 deletions(-) diff --git a/htdocs/js/mpd.js b/htdocs/js/mpd.js index b6db9af..08e08a9 100644 --- a/htdocs/js/mpd.js +++ b/htdocs/js/mpd.js @@ -137,6 +137,7 @@ function webSocketConnect() { return; var obj = JSON.parse(msg.data); + switch (obj.type) { case "queue": @@ -150,7 +151,9 @@ function webSocketConnect() { $('#salamisandwich > tbody').append( "" + (obj.data[song].pos + 1) + "" + - ""+ obj.data[song].title +"" + + ""+ obj.data[song].title +"" + + ""+ obj.data[song].album +"" + + ""+ obj.data[song].artist +"" + ""+ minutes + ":" + (seconds < 10 ? '0' : '') + seconds + ""); } @@ -192,6 +195,7 @@ function webSocketConnect() { "" + "" + "" + basename(obj.data[item].dir) + "" + + "" + "" ); break; @@ -199,7 +203,8 @@ function webSocketConnect() { $('#salamisandwich > tbody').append( "" + "" + - "" + basename(obj.data[item].plist) + "" + + "" + basename(obj.data[item].plist) + "" + + "" + "" ); break; @@ -210,8 +215,10 @@ function webSocketConnect() { $('#salamisandwich > tbody').append( "" + "" + - "" + obj.data[item].title +"" + - ""+ minutes + ":" + (seconds < 10 ? '0' : '') + seconds + + "" + obj.data[item].title + "" + + "" + obj.data[item].album + "" + + "" + obj.data[item].artist + "" + + "" + minutes + ":" + (seconds < 10 ? '0' : '') + seconds + "" ); break; diff --git a/src/mpd_client.c b/src/mpd_client.c index ea10178..76b079d 100644 --- a/src/mpd_client.c +++ b/src/mpd_client.c @@ -320,6 +320,30 @@ char* mpd_get_title(struct mpd_song const *song) return str; } +char* mpd_get_album(struct mpd_song const *song) +{ + char *str; + + str = (char *)mpd_song_get_tag(song, MPD_TAG_ALBUM, 0); + if(str == NULL){ + str = basename((char *)mpd_song_get_uri(song)); + } + + return str; +} + +char* mpd_get_artist(struct mpd_song const *song) +{ + char *str; + + str = (char *)mpd_song_get_tag(song, MPD_TAG_ARTIST, 0); + if(str == NULL){ + str = basename((char *)mpd_song_get_uri(song)); + } + + return str; +} + int mpd_put_state(char *buffer, int *current_song_id, unsigned *queue_version) { struct mpd_status *status; @@ -413,6 +437,10 @@ int mpd_put_queue(char *buffer, unsigned int offset) cur += json_emit_int(cur, end - cur, mpd_song_get_pos(song)); cur += json_emit_raw_str(cur, end - cur, ",\"duration\":"); cur += json_emit_int(cur, end - cur, mpd_song_get_duration(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, ",\"title\":"); cur += json_emit_quoted_str(cur, end - cur, mpd_get_title(song)); cur += json_emit_raw_str(cur, end - cur, "},"); @@ -469,6 +497,10 @@ int mpd_put_browse(char *buffer, char *path, unsigned int offset) cur += json_emit_quoted_str(cur, end - cur, mpd_song_get_uri(song)); cur += json_emit_raw_str(cur, end - cur, ",\"duration\":"); cur += json_emit_int(cur, end - cur, mpd_song_get_duration(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, ",\"title\":"); cur += json_emit_quoted_str(cur, end - cur, mpd_get_title(song)); cur += json_emit_raw_str(cur, end - cur, "},"); From f3aef08a7a53dd2dfb9ee261a60496dd2397052f Mon Sep 17 00:00:00 2001 From: LaClaro Date: Tue, 11 Nov 2014 18:50:21 +0100 Subject: [PATCH 2/4] Patched files to include more columns in browsing and queue mode --- htdocs/index.html | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/index.html b/htdocs/index.html index 0149a87..0b6717c 100644 --- a/htdocs/index.html +++ b/htdocs/index.html @@ -107,7 +107,9 @@ # - Title + Titel + Album + Artist Duration From 8b29d444968cfd613d08feb64113768136f4da9a Mon Sep 17 00:00:00 2001 From: LaClaro Date: Tue, 11 Nov 2014 18:52:05 +0100 Subject: [PATCH 3/4] Patched files to include more columns in browsing and queue mode --- htdocs/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/index.html b/htdocs/index.html index 0b6717c..776b40d 100644 --- a/htdocs/index.html +++ b/htdocs/index.html @@ -107,7 +107,7 @@ # - Titel + Title Album Artist Duration From df3ba1c04cc76b22b7a17ab49635b19f46fb5420 Mon Sep 17 00:00:00 2001 From: LaClaro Date: Thu, 20 Nov 2014 20:17:16 +0100 Subject: [PATCH 4/4] Added more columns also to the search --- src/mpd_client.c | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/src/mpd_client.c b/src/mpd_client.c index 76b079d..2fcc16f 100644 --- a/src/mpd_client.c +++ b/src/mpd_client.c @@ -344,6 +344,18 @@ char* mpd_get_artist(struct mpd_song const *song) return str; } +char* mpd_get_year(struct mpd_song const *song) +{ + char *str; + + str = (char *)mpd_song_get_tag(song, MPD_TAG_DATE, 0); + if(str == NULL){ + str = basename((char *)mpd_song_get_uri(song)); + } + + return str; +} + int mpd_put_state(char *buffer, int *current_song_id, unsigned *queue_version) { struct mpd_status *status; @@ -495,12 +507,12 @@ int mpd_put_browse(char *buffer, char *path, unsigned int offset) song = mpd_entity_get_song(entity); cur += json_emit_raw_str(cur, end - cur, "{\"type\":\"song\",\"uri\":"); cur += json_emit_quoted_str(cur, end - cur, mpd_song_get_uri(song)); - cur += json_emit_raw_str(cur, end - cur, ",\"duration\":"); - cur += json_emit_int(cur, end - cur, mpd_song_get_duration(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, ",\"artist\":"); + cur += json_emit_quoted_str(cur, end - cur, mpd_get_artist(song)); + cur += json_emit_raw_str(cur, end - cur, ",\"duration\":"); + 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, "},"); @@ -557,6 +569,10 @@ int mpd_search(char *buffer, char *searchstr) while((song = mpd_recv_song(mpd.conn)) != NULL) { cur += json_emit_raw_str(cur, end - cur, "{\"type\":\"song\",\"uri\":"); cur += json_emit_quoted_str(cur, end - cur, mpd_song_get_uri(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, ",\"artist\":"); + cur += json_emit_quoted_str(cur, end - cur, mpd_get_artist(song)); cur += json_emit_raw_str(cur, end - cur, ",\"duration\":"); cur += json_emit_int(cur, end - cur, mpd_song_get_duration(song)); cur += json_emit_raw_str(cur, end - cur, ",\"title\":");