From df3ba1c04cc76b22b7a17ab49635b19f46fb5420 Mon Sep 17 00:00:00 2001 From: LaClaro Date: Thu, 20 Nov 2014 20:17:16 +0100 Subject: [PATCH] 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\":"); -- 2.20.1