mirror of
https://github.com/SuperBFG7/ympd
synced 2025-05-04 08:24:07 +00:00
Feat: put all configured mympd_tags in json response for list and detail views
This commit is contained in:
parent
c471b37d78
commit
d7c9d549be
@ -1131,9 +1131,9 @@ function parseQueue(obj) {
|
|||||||
row.setAttribute('data-duration', duration);
|
row.setAttribute('data-duration', duration);
|
||||||
row.setAttribute('data-uri', obj.data[i].uri);
|
row.setAttribute('data-uri', obj.data[i].uri);
|
||||||
row.innerHTML = '<td>' + (obj.data[i].pos + 1) + '</td>' +
|
row.innerHTML = '<td>' + (obj.data[i].pos + 1) + '</td>' +
|
||||||
'<td>' + obj.data[i].title + '</td>' +
|
'<td>' + obj.data[i].Title + '</td>' +
|
||||||
'<td>' + obj.data[i].artist + '</td>' +
|
'<td>' + obj.data[i].Artist + '</td>' +
|
||||||
'<td>' + obj.data[i].album + '</td>' +
|
'<td>' + obj.data[i].Album + '</td>' +
|
||||||
'<td>' + duration + '</td>' +
|
'<td>' + duration + '</td>' +
|
||||||
'<td><a href="#" class="material-icons color-darkgrey">playlist_add</a></td>';
|
'<td><a href="#" class="material-icons color-darkgrey">playlist_add</a></td>';
|
||||||
if (i < tr.length)
|
if (i < tr.length)
|
||||||
@ -1198,9 +1198,9 @@ function parseFilesystem(obj) {
|
|||||||
var minutes = Math.floor(obj.data[i].duration / 60);
|
var minutes = Math.floor(obj.data[i].duration / 60);
|
||||||
var seconds = obj.data[i].duration - minutes * 60;
|
var seconds = obj.data[i].duration - minutes * 60;
|
||||||
row.innerHTML = '<td><span class="material-icons">music_note</span></td>' +
|
row.innerHTML = '<td><span class="material-icons">music_note</span></td>' +
|
||||||
'<td>' + obj.data[i].title + '</td>' +
|
'<td>' + obj.data[i].Title + '</td>' +
|
||||||
'<td>' + obj.data[i].artist + '</td>' +
|
'<td>' + obj.data[i].Artist + '</td>' +
|
||||||
'<td>' + obj.data[i].album + '</td>' +
|
'<td>' + obj.data[i].Album + '</td>' +
|
||||||
'<td>' + minutes + ':' + (seconds < 10 ? '0' : '') + seconds +
|
'<td>' + minutes + ':' + (seconds < 10 ? '0' : '') + seconds +
|
||||||
'</td><td><a href="#" class="material-icons color-darkgrey">playlist_add</a></td>';
|
'</td><td><a href="#" class="material-icons color-darkgrey">playlist_add</a></td>';
|
||||||
break;
|
break;
|
||||||
@ -1300,9 +1300,9 @@ function parsePlaylists(obj) {
|
|||||||
var minutes = Math.floor(obj.data[i].duration / 60);
|
var minutes = Math.floor(obj.data[i].duration / 60);
|
||||||
var seconds = obj.data[i].duration - minutes * 60;
|
var seconds = obj.data[i].duration - minutes * 60;
|
||||||
row.innerHTML = '<td>' + songpos + '</td>' +
|
row.innerHTML = '<td>' + songpos + '</td>' +
|
||||||
'<td>' + obj.data[i].title + '</td>' +
|
'<td>' + obj.data[i].Title + '</td>' +
|
||||||
'<td>' + obj.data[i].artist + '</td>' +
|
'<td>' + obj.data[i].Artist + '</td>' +
|
||||||
'<td>' + obj.data[i].album + '</td>' +
|
'<td>' + obj.data[i].Album + '</td>' +
|
||||||
'<td>' + minutes + ':' + (seconds < 10 ? '0' : '') + seconds +
|
'<td>' + minutes + ':' + (seconds < 10 ? '0' : '') + seconds +
|
||||||
'</td><td><a href="#" class="material-icons color-darkgrey">playlist_add</a></td>';
|
'</td><td><a href="#" class="material-icons color-darkgrey">playlist_add</a></td>';
|
||||||
if (i < tr.length)
|
if (i < tr.length)
|
||||||
@ -1444,15 +1444,15 @@ function getListTitles(changes, observer) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function parseListTitles(obj) {
|
function parseListTitles(obj) {
|
||||||
var id = genId(obj.album);
|
var id = genId(obj.Album);
|
||||||
var card = document.getElementById('card' + id)
|
var card = document.getElementById('card' + id)
|
||||||
var tbody = card.getElementsByTagName('tbody')[0];
|
var tbody = card.getElementsByTagName('tbody')[0];
|
||||||
var img = card.getElementsByTagName('a')[0];
|
var img = card.getElementsByTagName('a')[0];
|
||||||
img.style.backgroundImage = 'url("' + obj.cover + '")';
|
img.style.backgroundImage = 'url("' + obj.cover + '")';
|
||||||
img.setAttribute('data-uri', encodeURI(obj.data[0].uri.replace(/\/[^\/]+$/, '')));
|
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');
|
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 titleTable = document.getElementById('collapseLink' + id);
|
||||||
var myCollapseInit = new Collapse(titleTable);
|
var myCollapseInit = new Collapse(titleTable);
|
||||||
@ -1467,8 +1467,8 @@ function parseListTitles(obj) {
|
|||||||
var titleList = '';
|
var titleList = '';
|
||||||
var nrItems = obj.data.length;
|
var nrItems = obj.data.length;
|
||||||
for (var i = 0; i < nrItems; i++) {
|
for (var i = 0; i < nrItems; i++) {
|
||||||
titleList += '<tr data-type="song" data-name="' + obj.data[i].title + '" data-uri="' + encodeURI(obj.data[i].uri) + '">' +
|
titleList += '<tr data-type="song" data-name="' + obj.data[i].Title + '" data-uri="' + encodeURI(obj.data[i].uri) + '">' +
|
||||||
'<td>' + obj.data[i].track + '</td><td>' + obj.data[i].title + '</td>' +
|
'<td>' + obj.data[i].Track + '</td><td>' + obj.data[i].Title + '</td>' +
|
||||||
'<td><a href="#" class="material-icons color-darkgrey">playlist_add</a></td>' +
|
'<td><a href="#" class="material-icons color-darkgrey">playlist_add</a></td>' +
|
||||||
'</tr>';
|
'</tr>';
|
||||||
}
|
}
|
||||||
@ -1591,18 +1591,17 @@ function songDetails(uri) {
|
|||||||
function parseSongDetails(obj) {
|
function parseSongDetails(obj) {
|
||||||
var modal = document.getElementById('modalSongDetails');
|
var modal = document.getElementById('modalSongDetails');
|
||||||
modal.getElementsByClassName('album-cover')[0].style.backgroundImage = 'url("' + obj.data.cover + '")';
|
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 = '';
|
var songDetails = '';
|
||||||
for (var i = 0; i < settings.tags.length; i++) {
|
for (var i = 0; i < settings.tags.length; i++) {
|
||||||
var value = obj.data[settings.tags[i].toLowerCase()];
|
songDetails += '<tr><th>' + settings.tags[i] + '</th><td>' + obj.data[settings.tags[i]] + '</td></tr>';
|
||||||
if (settings.tags[i] == 'duration') {
|
|
||||||
var minutes = Math.floor(value / 60);
|
|
||||||
var seconds = value - minutes * 60;
|
|
||||||
value = minutes + ':' + (seconds < 10 ? '0' : '') + seconds;
|
|
||||||
}
|
|
||||||
songDetails += '<tr><th>' + settings.tags[i] + '</th><td>' + value + '</td></tr>';
|
|
||||||
}
|
}
|
||||||
|
var duration = obj.data.duration;
|
||||||
|
var minutes = Math.floor(duration / 60);
|
||||||
|
var seconds = duration - minutes * 60;
|
||||||
|
duration = minutes + ':' + (seconds < 10 ? '0' : '') + seconds;
|
||||||
|
songDetails += '<tr><th>Duration</th><td>' + duration + '</td></tr>';
|
||||||
|
|
||||||
songDetails += '<tr><th>Uri</th><td><a class="text-success" href="/library/' + obj.data.uri + '">' + obj.data.uri + '</a></td></tr>';
|
songDetails += '<tr><th>Uri</th><td><a class="text-success" href="/library/' + obj.data.uri + '">' + obj.data.uri + '</a></td></tr>';
|
||||||
|
|
||||||
@ -2349,7 +2348,7 @@ function notificationsSupported() {
|
|||||||
function songChange(obj) {
|
function songChange(obj) {
|
||||||
if (obj.type == 'error' || obj.type == 'result')
|
if (obj.type == 'error' || obj.type == 'result')
|
||||||
return;
|
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)
|
if (lastSong == curSong)
|
||||||
return;
|
return;
|
||||||
var textNotification = '';
|
var textNotification = '';
|
||||||
@ -2358,27 +2357,27 @@ function songChange(obj) {
|
|||||||
|
|
||||||
domCache.currentCover.style.backgroundImage = 'url("' + obj.data.cover + '")';
|
domCache.currentCover.style.backgroundImage = 'url("' + obj.data.cover + '")';
|
||||||
|
|
||||||
if (typeof obj.data.artist != 'undefined' && obj.data.artist.length > 0 && obj.data.artist != '-') {
|
if (typeof obj.data.Artist != 'undefined' && obj.data.Artist.length > 0 && obj.data.Artist != '-') {
|
||||||
textNotification += obj.data.artist;
|
textNotification += obj.data.Artist;
|
||||||
htmlNotification += obj.data.artist;
|
htmlNotification += obj.data.Artist;
|
||||||
pageTitle += obj.data.artist + ' - ';
|
pageTitle += obj.data.Artist + ' - ';
|
||||||
domCache.currentArtist.innerText = obj.data.artist;
|
domCache.currentArtist.innerText = obj.data.Artist;
|
||||||
domCache.currentArtist.setAttribute('data-albumartist', obj.data.albumartist);
|
domCache.currentArtist.setAttribute('data-albumartist', obj.data.AlbumArtist);
|
||||||
} else
|
} else
|
||||||
domCache.currentArtist.innerText = '';
|
domCache.currentArtist.innerText = '';
|
||||||
|
|
||||||
if (typeof obj.data.album != 'undefined' && obj.data.album.length > 0 && obj.data.album != '-') {
|
if (typeof obj.data.Album != 'undefined' && obj.data.Album.length > 0 && obj.data.Album != '-') {
|
||||||
textNotification += ' - ' + obj.data.album;
|
textNotification += ' - ' + obj.data.Album;
|
||||||
htmlNotification += '<br/>' + obj.data.album;
|
htmlNotification += '<br/>' + obj.data.Album;
|
||||||
domCache.currentAlbum.innerText = obj.data.album;
|
domCache.currentAlbum.innerText = obj.data.Album;
|
||||||
domCache.currentAlbum.setAttribute('data-album', obj.data.album);
|
domCache.currentAlbum.setAttribute('data-album', obj.data.Album);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
domCache.currentAlbum.innerText = '';
|
domCache.currentAlbum.innerText = '';
|
||||||
|
|
||||||
if (typeof obj.data.title != 'undefined' && obj.data.title.length > 0) {
|
if (typeof obj.data.Title != 'undefined' && obj.data.Title.length > 0) {
|
||||||
pageTitle += obj.data.title;
|
pageTitle += obj.data.Title;
|
||||||
domCache.currentTrack.innerText = obj.data.title;
|
domCache.currentTrack.innerText = obj.data.Title;
|
||||||
domCache.currentTrack.setAttribute('data-uri', obj.data.uri);
|
domCache.currentTrack.setAttribute('data-uri', obj.data.uri);
|
||||||
} else {
|
} else {
|
||||||
domCache.currentTrack.innerText = '';
|
domCache.currentTrack.innerText = '';
|
||||||
@ -2394,9 +2393,9 @@ function songChange(obj) {
|
|||||||
//Update Artist in queue view for http streams
|
//Update Artist in queue view for http streams
|
||||||
var playingTr = document.getElementById('queueTrackId' + obj.data.currentSongId);
|
var playingTr = document.getElementById('queueTrackId' + obj.data.currentSongId);
|
||||||
if (playingTr)
|
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;
|
lastSong = curSong;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1412,19 +1412,14 @@ int mympd_put_current_song(char *buffer) {
|
|||||||
|
|
||||||
mympd_get_cover(mpd_song_get_uri(song), cover, 500);
|
mympd_get_cover(mpd_song_get_uri(song), cover, 500);
|
||||||
|
|
||||||
len = json_printf(&out, "{type: song_change, data: {pos: %d, title: %Q, "
|
len = json_printf(&out, "{type: song_change, data: {pos: %d, uri: %Q, currentSongId: %d, duration: %d, cover: %Q, ",
|
||||||
"artist: %Q, album: %Q, uri: %Q, currentSongId: %d, albumartist: %Q, "
|
|
||||||
"duration: %d, cover: %Q",
|
|
||||||
mpd_song_get_pos(song),
|
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_get_uri(song),
|
||||||
mpd.song_id,
|
mpd.song_id,
|
||||||
mympd_get_tag(song, MPD_TAG_ALBUM_ARTIST),
|
|
||||||
mpd_song_get_duration(song),
|
mpd_song_get_duration(song),
|
||||||
cover
|
cover
|
||||||
);
|
);
|
||||||
|
PUT_SONG_TAGS();
|
||||||
|
|
||||||
mpd_response_finish(mpd.conn);
|
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);
|
mpd_send_list_all_meta(mpd.conn, uri);
|
||||||
if ((entity = mpd_recv_entity(mpd.conn)) != NULL) {
|
if ((entity = mpd_recv_entity(mpd.conn)) != NULL) {
|
||||||
song = mpd_entity_get_song(entity);
|
song = mpd_entity_get_song(entity);
|
||||||
|
|
||||||
mympd_get_cover(uri, cover, 500);
|
mympd_get_cover(uri, cover, 500);
|
||||||
len += json_printf(&out, "duration: %d, artist: %Q, album: %Q, title: %Q, albumartist: %Q, cover: %Q, uri: %Q, "
|
len += json_printf(&out, "duration: %d, cover: %Q, uri: %Q, ",
|
||||||
"genre: %Q, track: %Q, date: %Q, composer: %Q, performer: %Q",
|
|
||||||
mpd_song_get_duration(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),
|
|
||||||
mympd_get_tag(song, MPD_TAG_ALBUM_ARTIST),
|
|
||||||
cover,
|
cover,
|
||||||
uri,
|
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)
|
|
||||||
);
|
);
|
||||||
|
PUT_SONG_TAGS();
|
||||||
mpd_entity_free(entity);
|
mpd_entity_free(entity);
|
||||||
}
|
}
|
||||||
mpd_response_finish(mpd.conn);
|
mpd_response_finish(mpd.conn);
|
||||||
@ -1522,15 +1507,14 @@ int mympd_put_queue(char *buffer, unsigned int offset, unsigned *queue_version,
|
|||||||
entity_count ++;
|
entity_count ++;
|
||||||
if (entities_returned ++)
|
if (entities_returned ++)
|
||||||
len += json_printf(&out, ",");
|
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_id(song),
|
||||||
mpd_song_get_pos(song),
|
mpd_song_get_pos(song),
|
||||||
mpd_song_get_duration(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)
|
mpd_song_get_uri(song)
|
||||||
);
|
);
|
||||||
|
PUT_SONG_TAGS();
|
||||||
|
len += json_printf(&out, "}");
|
||||||
}
|
}
|
||||||
mpd_entity_free(entity);
|
mpd_entity_free(entity);
|
||||||
}
|
}
|
||||||
@ -1584,14 +1568,13 @@ int mympd_put_browse(char *buffer, char *path, unsigned int offset, char *filter
|
|||||||
) {
|
) {
|
||||||
if (entities_returned ++)
|
if (entities_returned ++)
|
||||||
len += json_printf(&out, ",");
|
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),
|
mpd_song_get_uri(song),
|
||||||
mympd_get_tag(song, MPD_TAG_ALBUM),
|
|
||||||
mympd_get_tag(song, MPD_TAG_ARTIST),
|
|
||||||
mpd_song_get_duration(song),
|
mpd_song_get_duration(song),
|
||||||
entityName,
|
|
||||||
entityName
|
entityName
|
||||||
);
|
);
|
||||||
|
PUT_SONG_TAGS();
|
||||||
|
len += json_printf(&out, "}");
|
||||||
} else {
|
} else {
|
||||||
entity_count --;
|
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);
|
mympd_get_cover(mpd_song_get_uri(song), cover, 500);
|
||||||
albumartist = strdup(mympd_get_tag(song, MPD_TAG_ALBUM_ARTIST));
|
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_uri(song),
|
||||||
mpd_song_get_duration(song),
|
mpd_song_get_duration(song),
|
||||||
mympd_get_tag(song, MPD_TAG_TITLE),
|
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);
|
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,
|
entity_count,
|
||||||
entities_returned,
|
entities_returned,
|
||||||
album,
|
album,
|
||||||
@ -1863,14 +1846,13 @@ int mympd_put_playlist_list(char *buffer, char *uri, unsigned int offset, char *
|
|||||||
) {
|
) {
|
||||||
if (entities_returned ++)
|
if (entities_returned ++)
|
||||||
len += json_printf(&out, ",");
|
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),
|
mpd_song_get_uri(song),
|
||||||
mympd_get_tag(song, MPD_TAG_ALBUM),
|
|
||||||
mympd_get_tag(song, MPD_TAG_ARTIST),
|
|
||||||
mpd_song_get_duration(song),
|
mpd_song_get_duration(song),
|
||||||
entityName,
|
|
||||||
entityName
|
entityName
|
||||||
);
|
);
|
||||||
|
PUT_SONG_TAGS();
|
||||||
|
len += json_printf(&out, "}");
|
||||||
} else {
|
} else {
|
||||||
entity_count --;
|
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 (entity_count > offset && entity_count <= offset + config.max_elements_per_page) {
|
||||||
if (entities_returned ++)
|
if (entities_returned ++)
|
||||||
len += json_printf(&out, ", ");
|
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),
|
mpd_song_get_uri(song),
|
||||||
mympd_get_tag(song, MPD_TAG_ALBUM),
|
|
||||||
mympd_get_tag(song, MPD_TAG_ARTIST),
|
|
||||||
mpd_song_get_duration(song),
|
mpd_song_get_duration(song),
|
||||||
mympd_get_tag(song, MPD_TAG_TITLE),
|
|
||||||
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);
|
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 (entity_count > offset && entity_count <= offset + config.max_elements_per_page) {
|
||||||
if (entities_returned ++)
|
if (entities_returned ++)
|
||||||
len += json_printf(&out, ", ");
|
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_id(song),
|
||||||
mpd_song_get_pos(song),
|
mpd_song_get_pos(song),
|
||||||
mympd_get_tag(song, MPD_TAG_ALBUM),
|
mpd_song_get_duration(song)
|
||||||
mympd_get_tag(song, MPD_TAG_ARTIST),
|
|
||||||
mpd_song_get_duration(song),
|
|
||||||
mympd_get_tag(song, MPD_TAG_TITLE)
|
|
||||||
);
|
);
|
||||||
|
PUT_SONG_TAGS();
|
||||||
|
len += json_printf(&out, "}");
|
||||||
mpd_song_free(song);
|
mpd_song_free(song);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -50,6 +50,18 @@
|
|||||||
return len; \
|
return len; \
|
||||||
} while (0)
|
} 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_SIZE 2048 * 400
|
||||||
#define MAX_ELEMENTS_PER_PAGE 400
|
#define MAX_ELEMENTS_PER_PAGE 400
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user