Added more columns also to the search
authorLaClaro <laclaro@mail.com>
Thu, 20 Nov 2014 19:17:16 +0000 (20:17 +0100)
committerLaClaro <laclaro@mail.com>
Thu, 20 Nov 2014 19:17:16 +0000 (20:17 +0100)
src/mpd_client.c

index 76b079d..2fcc16f 100644 (file)
@@ -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\":");