diff --git a/htdocs/js/mympd.js b/htdocs/js/mympd.js
index 8b2baae..d776ad5 100644
--- a/htdocs/js/mympd.js
+++ b/htdocs/js/mympd.js
@@ -1131,9 +1131,9 @@ function parseQueue(obj) {
row.setAttribute('data-duration', duration);
row.setAttribute('data-uri', obj.data[i].uri);
row.innerHTML = '
' + (obj.data[i].pos + 1) + ' | ' +
- '' + obj.data[i].title + ' | ' +
- '' + obj.data[i].artist + ' | ' +
- '' + obj.data[i].album + ' | ' +
+ '' + obj.data[i].Title + ' | ' +
+ '' + obj.data[i].Artist + ' | ' +
+ '' + obj.data[i].Album + ' | ' +
'' + duration + ' | ' +
'playlist_add | ';
if (i < tr.length)
@@ -1198,9 +1198,9 @@ function parseFilesystem(obj) {
var minutes = Math.floor(obj.data[i].duration / 60);
var seconds = obj.data[i].duration - minutes * 60;
row.innerHTML = 'music_note | ' +
- '' + obj.data[i].title + ' | ' +
- '' + obj.data[i].artist + ' | ' +
- '' + obj.data[i].album + ' | ' +
+ '' + obj.data[i].Title + ' | ' +
+ '' + obj.data[i].Artist + ' | ' +
+ '' + obj.data[i].Album + ' | ' +
'' + minutes + ':' + (seconds < 10 ? '0' : '') + seconds +
' | playlist_add | ';
break;
@@ -1300,9 +1300,9 @@ function parsePlaylists(obj) {
var minutes = Math.floor(obj.data[i].duration / 60);
var seconds = obj.data[i].duration - minutes * 60;
row.innerHTML = '' + songpos + ' | ' +
- '' + obj.data[i].title + ' | ' +
- '' + obj.data[i].artist + ' | ' +
- '' + obj.data[i].album + ' | ' +
+ '' + obj.data[i].Title + ' | ' +
+ '' + obj.data[i].Artist + ' | ' +
+ '' + obj.data[i].Album + ' | ' +
'' + minutes + ':' + (seconds < 10 ? '0' : '') + seconds +
' | playlist_add | ';
if (i < tr.length)
@@ -1444,15 +1444,15 @@ function getListTitles(changes, observer) {
}
function parseListTitles(obj) {
- var id = genId(obj.album);
+ var id = genId(obj.Album);
var card = document.getElementById('card' + id)
var tbody = card.getElementsByTagName('tbody')[0];
var img = card.getElementsByTagName('a')[0];
img.style.backgroundImage = 'url("' + obj.cover + '")';
img.setAttribute('data-uri', encodeURI(obj.data[0].uri.replace(/\/[^\/]+$/, '')));
- img.setAttribute('data-name', obj.album);
+ img.setAttribute('data-name', obj.Album);
img.setAttribute('data-type', 'dir');
- document.getElementById('albumartist' + id).innerText = obj.albumartist;
+ document.getElementById('albumartist' + id).innerText = obj.AlbumArtist;
var titleTable = document.getElementById('collapseLink' + id);
var myCollapseInit = new Collapse(titleTable);
@@ -1467,8 +1467,8 @@ function parseListTitles(obj) {
var titleList = '';
var nrItems = obj.data.length;
for (var i = 0; i < nrItems; i++) {
- titleList += '' +
- '' + obj.data[i].track + ' | ' + obj.data[i].title + ' | ' +
+ titleList += '
' +
+ '' + obj.data[i].Track + ' | ' + obj.data[i].Title + ' | ' +
'playlist_add | ' +
'
';
}
@@ -1591,18 +1591,17 @@ function songDetails(uri) {
function parseSongDetails(obj) {
var modal = document.getElementById('modalSongDetails');
modal.getElementsByClassName('album-cover')[0].style.backgroundImage = 'url("' + obj.data.cover + '")';
- modal.getElementsByTagName('h1')[0].innerText = obj.data.title;
+ modal.getElementsByTagName('h1')[0].innerText = obj.data.Title;
var songDetails = '';
for (var i = 0; i < settings.tags.length; i++) {
- var value = obj.data[settings.tags[i].toLowerCase()];
- if (settings.tags[i] == 'duration') {
- var minutes = Math.floor(value / 60);
- var seconds = value - minutes * 60;
- value = minutes + ':' + (seconds < 10 ? '0' : '') + seconds;
- }
- songDetails += '' + settings.tags[i] + ' | ' + value + ' |
';
+ songDetails += '' + settings.tags[i] + ' | ' + obj.data[settings.tags[i]] + ' |
';
}
+ var duration = obj.data.duration;
+ var minutes = Math.floor(duration / 60);
+ var seconds = duration - minutes * 60;
+ duration = minutes + ':' + (seconds < 10 ? '0' : '') + seconds;
+ songDetails += 'Duration | ' + duration + ' |
';
songDetails += 'Uri | ' + obj.data.uri + ' |
';
@@ -2349,7 +2348,7 @@ function notificationsSupported() {
function songChange(obj) {
if (obj.type == 'error' || obj.type == 'result')
return;
- var curSong = obj.data.title + obj.data.artist + obj.data.album + obj.data.uri + obj.data.currentSongId;
+ var curSong = obj.data.Title + obj.data.Artist + obj.data.Album + obj.data.uri + obj.data.currentSongId;
if (lastSong == curSong)
return;
var textNotification = '';
@@ -2358,27 +2357,27 @@ function songChange(obj) {
domCache.currentCover.style.backgroundImage = 'url("' + obj.data.cover + '")';
- if (typeof obj.data.artist != 'undefined' && obj.data.artist.length > 0 && obj.data.artist != '-') {
- textNotification += obj.data.artist;
- htmlNotification += obj.data.artist;
- pageTitle += obj.data.artist + ' - ';
- domCache.currentArtist.innerText = obj.data.artist;
- domCache.currentArtist.setAttribute('data-albumartist', obj.data.albumartist);
+ if (typeof obj.data.Artist != 'undefined' && obj.data.Artist.length > 0 && obj.data.Artist != '-') {
+ textNotification += obj.data.Artist;
+ htmlNotification += obj.data.Artist;
+ pageTitle += obj.data.Artist + ' - ';
+ domCache.currentArtist.innerText = obj.data.Artist;
+ domCache.currentArtist.setAttribute('data-albumartist', obj.data.AlbumArtist);
} else
domCache.currentArtist.innerText = '';
- if (typeof obj.data.album != 'undefined' && obj.data.album.length > 0 && obj.data.album != '-') {
- textNotification += ' - ' + obj.data.album;
- htmlNotification += '
' + obj.data.album;
- domCache.currentAlbum.innerText = obj.data.album;
- domCache.currentAlbum.setAttribute('data-album', obj.data.album);
+ if (typeof obj.data.Album != 'undefined' && obj.data.Album.length > 0 && obj.data.Album != '-') {
+ textNotification += ' - ' + obj.data.Album;
+ htmlNotification += '
' + obj.data.Album;
+ domCache.currentAlbum.innerText = obj.data.Album;
+ domCache.currentAlbum.setAttribute('data-album', obj.data.Album);
}
else
domCache.currentAlbum.innerText = '';
- if (typeof obj.data.title != 'undefined' && obj.data.title.length > 0) {
- pageTitle += obj.data.title;
- domCache.currentTrack.innerText = obj.data.title;
+ if (typeof obj.data.Title != 'undefined' && obj.data.Title.length > 0) {
+ pageTitle += obj.data.Title;
+ domCache.currentTrack.innerText = obj.data.Title;
domCache.currentTrack.setAttribute('data-uri', obj.data.uri);
} else {
domCache.currentTrack.innerText = '';
@@ -2394,9 +2393,9 @@ function songChange(obj) {
//Update Artist in queue view for http streams
var playingTr = document.getElementById('queueTrackId' + obj.data.currentSongId);
if (playingTr)
- playingTr.getElementsByTagName('td')[1].innerText = obj.data.title;
+ playingTr.getElementsByTagName('td')[1].innerText = obj.data.Title;
- showNotification(obj.data.title, textNotification, htmlNotification, 'success');
+ showNotification(obj.data.Title, textNotification, htmlNotification, 'success');
lastSong = curSong;
}
diff --git a/src/mpd_client.c b/src/mpd_client.c
index 02596b2..626f229 100644
--- a/src/mpd_client.c
+++ b/src/mpd_client.c
@@ -1412,19 +1412,14 @@ int mympd_put_current_song(char *buffer) {
mympd_get_cover(mpd_song_get_uri(song), cover, 500);
- len = json_printf(&out, "{type: song_change, data: {pos: %d, title: %Q, "
- "artist: %Q, album: %Q, uri: %Q, currentSongId: %d, albumartist: %Q, "
- "duration: %d, cover: %Q",
+ len = json_printf(&out, "{type: song_change, data: {pos: %d, uri: %Q, currentSongId: %d, duration: %d, cover: %Q, ",
mpd_song_get_pos(song),
- mympd_get_tag(song, MPD_TAG_TITLE),
- mympd_get_tag(song, MPD_TAG_ARTIST),
- mympd_get_tag(song, MPD_TAG_ALBUM),
mpd_song_get_uri(song),
mpd.song_id,
- mympd_get_tag(song, MPD_TAG_ALBUM_ARTIST),
mpd_song_get_duration(song),
cover
);
+ PUT_SONG_TAGS();
mpd_response_finish(mpd.conn);
@@ -1457,23 +1452,13 @@ int mympd_put_songdetails(char *buffer, char *uri) {
mpd_send_list_all_meta(mpd.conn, uri);
if ((entity = mpd_recv_entity(mpd.conn)) != NULL) {
song = mpd_entity_get_song(entity);
-
mympd_get_cover(uri, cover, 500);
- len += json_printf(&out, "duration: %d, artist: %Q, album: %Q, title: %Q, albumartist: %Q, cover: %Q, uri: %Q, "
- "genre: %Q, track: %Q, date: %Q, composer: %Q, performer: %Q",
+ len += json_printf(&out, "duration: %d, cover: %Q, uri: %Q, ",
mpd_song_get_duration(song),
- mympd_get_tag(song, MPD_TAG_ARTIST),
- mympd_get_tag(song, MPD_TAG_ALBUM),
- mympd_get_tag(song, MPD_TAG_TITLE),
- mympd_get_tag(song, MPD_TAG_ALBUM_ARTIST),
cover,
- uri,
- mympd_get_tag(song, MPD_TAG_GENRE),
- mympd_get_tag(song, MPD_TAG_TRACK),
- mympd_get_tag(song, MPD_TAG_DATE),
- mympd_get_tag(song, MPD_TAG_COMPOSER),
- mympd_get_tag(song, MPD_TAG_PERFORMER)
+ uri
);
+ PUT_SONG_TAGS();
mpd_entity_free(entity);
}
mpd_response_finish(mpd.conn);
@@ -1522,15 +1507,14 @@ int mympd_put_queue(char *buffer, unsigned int offset, unsigned *queue_version,
entity_count ++;
if (entities_returned ++)
len += json_printf(&out, ",");
- len += json_printf(&out, "{id: %d, pos: %d, duration: %d, artist: %Q, album: %Q, title: %Q, uri: %Q}",
+ len += json_printf(&out, "{id: %d, pos: %d, duration: %d, uri: %Q, ",
mpd_song_get_id(song),
mpd_song_get_pos(song),
mpd_song_get_duration(song),
- mympd_get_tag(song, MPD_TAG_ARTIST),
- mympd_get_tag(song, MPD_TAG_ALBUM),
- mympd_get_tag(song, MPD_TAG_TITLE),
mpd_song_get_uri(song)
);
+ PUT_SONG_TAGS();
+ len += json_printf(&out, "}");
}
mpd_entity_free(entity);
}
@@ -1584,14 +1568,13 @@ int mympd_put_browse(char *buffer, char *path, unsigned int offset, char *filter
) {
if (entities_returned ++)
len += json_printf(&out, ",");
- len += json_printf(&out, "{type: song, uri: %Q, album: %Q, artist: %Q, duration: %d, title: %Q, name: %Q}",
+ len += json_printf(&out, "{type: song, uri: %Q, duration: %d, name: %Q, ",
mpd_song_get_uri(song),
- mympd_get_tag(song, MPD_TAG_ALBUM),
- mympd_get_tag(song, MPD_TAG_ARTIST),
mpd_song_get_duration(song),
- entityName,
entityName
);
+ PUT_SONG_TAGS();
+ len += json_printf(&out, "}");
} else {
entity_count --;
}
@@ -1759,7 +1742,7 @@ int mympd_put_songs_in_album(char *buffer, char *album, char *search, char *tag)
mympd_get_cover(mpd_song_get_uri(song), cover, 500);
albumartist = strdup(mympd_get_tag(song, MPD_TAG_ALBUM_ARTIST));
}
- len += json_printf(&out, "{type: song, uri: %Q, duration: %d, title: %Q, track: %Q}",
+ len += json_printf(&out, "{type: song, uri: %Q, duration: %d, Title: %Q, Track: %Q}",
mpd_song_get_uri(song),
mpd_song_get_duration(song),
mympd_get_tag(song, MPD_TAG_TITLE),
@@ -1769,7 +1752,7 @@ int mympd_put_songs_in_album(char *buffer, char *album, char *search, char *tag)
mpd_song_free(song);
}
- len += json_printf(&out, "], totalEntities: %d, returnedEntities: %d, album: %Q, search: %Q, tag: %Q, cover: %Q, albumartist: %Q}",
+ len += json_printf(&out, "], totalEntities: %d, returnedEntities: %d, Album: %Q, search: %Q, tag: %Q, cover: %Q, AlbumArtist: %Q}",
entity_count,
entities_returned,
album,
@@ -1863,14 +1846,13 @@ int mympd_put_playlist_list(char *buffer, char *uri, unsigned int offset, char *
) {
if (entities_returned ++)
len += json_printf(&out, ",");
- len += json_printf(&out, "{type: song, uri: %Q, album: %Q, artist: %Q, duration: %d, title: %Q, name: %Q}",
+ len += json_printf(&out, "{type: song, uri: %Q, duration: %d, name: %Q, ",
mpd_song_get_uri(song),
- mympd_get_tag(song, MPD_TAG_ALBUM),
- mympd_get_tag(song, MPD_TAG_ARTIST),
mpd_song_get_duration(song),
- entityName,
entityName
);
+ PUT_SONG_TAGS();
+ len += json_printf(&out, "}");
} else {
entity_count --;
}
@@ -1922,14 +1904,13 @@ int mympd_search(char *buffer, char *searchstr, char *filter, char *plist, unsig
if (entity_count > offset && entity_count <= offset + config.max_elements_per_page) {
if (entities_returned ++)
len += json_printf(&out, ", ");
- len += json_printf(&out, "{type: song, uri: %Q, album: %Q, artist: %Q, duration: %d, title: %Q, name: %Q}",
+ len += json_printf(&out, "{type: song, uri: %Q, duration: %d, name: %Q, ",
mpd_song_get_uri(song),
- mympd_get_tag(song, MPD_TAG_ALBUM),
- mympd_get_tag(song, MPD_TAG_ARTIST),
mpd_song_get_duration(song),
- mympd_get_tag(song, MPD_TAG_TITLE),
mympd_get_tag(song, MPD_TAG_TITLE)
);
+ PUT_SONG_TAGS();
+ len += json_printf(&out, "}");
}
mpd_song_free(song);
}
@@ -2010,14 +1991,13 @@ int mympd_search_queue(char *buffer, char *mpdtagtype, unsigned int offset, char
if (entity_count > offset && entity_count <= offset + config.max_elements_per_page) {
if (entities_returned ++)
len += json_printf(&out, ", ");
- len += json_printf(&out, "{type: song, id: %d, pos: %d, album: %Q, artist: %Q, duration: %d, title: %Q}",
+ len += json_printf(&out, "{type: song, id: %d, pos: %d, duration: %d, ",
mpd_song_get_id(song),
mpd_song_get_pos(song),
- mympd_get_tag(song, MPD_TAG_ALBUM),
- mympd_get_tag(song, MPD_TAG_ARTIST),
- mpd_song_get_duration(song),
- mympd_get_tag(song, MPD_TAG_TITLE)
+ mpd_song_get_duration(song)
);
+ PUT_SONG_TAGS();
+ len += json_printf(&out, "}");
mpd_song_free(song);
}
}
diff --git a/src/mpd_client.h b/src/mpd_client.h
index b3f1119..d0c38ae 100644
--- a/src/mpd_client.h
+++ b/src/mpd_client.h
@@ -50,6 +50,18 @@
return len; \
} while (0)
+#define PUT_SONG_TAGS() do { \
+ struct node *current = mympd_tags.list; \
+ int tagnr = 0; \
+ while (current != NULL) { \
+ if (tagnr ++) \
+ len += json_printf(&out, ","); \
+ len += json_printf(&out, "%Q: %Q", current->data, mympd_get_tag(song, mpd_tag_name_parse(current->data))); \
+ current = current->next; \
+ } \
+} while (0)
+
+
#define MAX_SIZE 2048 * 400
#define MAX_ELEMENTS_PER_PAGE 400