' +
- '
' + obj.searchstr + '
' +
+ '
' +
'
' + obj.data[i].value + '
' +
'
'+
@@ -1285,11 +1276,13 @@ function parseListDBtags(obj) {
document.getElementById('btnBrowseDatabaseByTag').parentNode.classList.remove('hide');
document.getElementById('BrowseDatabaseAddAllSongs').parentNode.parentNode.classList.add('hide');
document.getElementById('btnBrowseDatabaseTag').parentNode.classList.add('hide');
+
+ if (obj.data[0] && obj.data[0].value == '')
+ obj.data.shift();
var nrItems = obj.data.length;
- if (nrItems == 1 && obj.data[0].value == '')
- nrItems = 0;
var tbody = document.getElementById(app.current.app + app.current.tab + 'TagList').getElementsByTagName('tbody')[0];
var tr = tbody.getElementsByTagName('tr');
+ var skipped = 0;
for (var i = 0; i < nrItems; i++) {
var uri = encodeURI(obj.data[i].value);
if (tr[i])
@@ -1333,6 +1326,7 @@ function parseListTitles(obj) {
imga.setAttribute('data-uri', encodeURI(obj.data[0].uri.replace(/\/[^\/]+$/, '')));
imga.setAttribute('data-name', obj.album);
imga.setAttribute('data-type', 'dir');
+ document.getElementById('albumartist' + id).innerText = obj.albumartist;
var titleList = '';
var nrItems = obj.data.length;
@@ -1622,10 +1616,12 @@ function addToPlaylist() {
}
}
if (plist != '') {
- if (uri != 'SEARCH')
- sendAPI({"cmd": "MPD_API_PLAYLIST_ADD_TRACK", "data": {"uri": uri, "plist": plist}});
+ if (uri == 'SEARCH')
+ addAllFromSearchPlist(plist);
+ else if (uri == 'DATABASE')
+ addAllFromBrowseDatabasePlist(plist);
else
- addAllFromSearchPlist(plist);
+ sendAPI({"cmd": "MPD_API_PLAYLIST_ADD_TRACK", "data": {"uri": uri, "plist": plist}});
modalAddToPlaylist.hide();
}
else {
@@ -1950,13 +1946,6 @@ function addAllFromBrowseFilesystem() {
showNotification('Added all songs', '', '', 'success');
}
-function addAllFromSearch() {
- if (app.current.search.length >= 2) {
- sendAPI({"cmd": "MPD_API_DATABASE_SEARCH", "data": {"plist": "queue", "filter": app.current.filter, "searchstr": app.current.search, "offset": 0}});
- showNotification('Added '+ parseInt(document.getElementById('panel-heading-search').innerText) +' songs from search', '', '', 'success');
- }
-}
-
function addAllFromSearchPlist(plist) {
if (app.current.search.length >= 2) {
sendAPI({"cmd": "MPD_API_DATABASE_SEARCH", "data": {"plist": plist, "filter": app.current.filter, "searchstr": app.current.search, "offset": 0}});
@@ -1964,6 +1953,13 @@ function addAllFromSearchPlist(plist) {
}
}
+function addAllFromBrowseDatabasePlist(plist) {
+ if (app.current.search.length >= 2) {
+ sendAPI({"cmd": "MPD_API_DATABASE_SEARCH", "data": {"plist": plist, "filter": app.current.view, "searchstr": app.current.search, "offset": 0}});
+ showNotification('Added songs from database selection to ' + plist, '', '', 'success');
+ }
+}
+
function scrollTo(pos) {
document.body.scrollTop = pos; // For Safari
document.documentElement.scrollTop = pos; // For Chrome, Firefox, IE and Opera
@@ -2144,6 +2140,31 @@ function addFilterLetter(x) {
}, false);
}
+function selectTag(btnsEl, desc, setTo) {
+ var btns = document.getElementById(btnsEl);
+ var aBtn = btns.querySelector('.active')
+ if (aBtn)
+ aBtn.classList.remove('active');
+ aBtn = btns.querySelector('[data-tag=' + setTo + ']');
+ if (aBtn) {
+ aBtn.classList.add('active');
+ document.getElementById(desc).innerText = aBtn.innerText;
+ }
+}
+
+function addTagList(x, any) {
+ var tagList = '';
+ if (any == true)
+ tagList += '
';
+ for (var key in settings.tags) {
+ if (settings.tags[key] == true && key != 'Track') {
+ tagList += '
';
+ }
+ }
+ var tagListEl = document.getElementById(x);
+ tagListEl.innerHTML = tagList;
+}
+
function gotoTagList() {
appGoto(app.current.app, app.current.tab, app.current.view, '0/-/');
}
@@ -2170,7 +2191,7 @@ function beautifyDuration(x) {
}
function genId(x) {
- return 'id' + x.replace(/[^\w]/g, '');
+ return 'id' + x.replace(/[^\w\-\_]/g, '');
}
//Init app
diff --git a/src/mpd_client.c b/src/mpd_client.c
index 100d5be..b44ee22 100644
--- a/src/mpd_client.c
+++ b/src/mpd_client.c
@@ -636,7 +636,7 @@ void mympd_mpd_features() {
if (mpd.tag_artist == false)
printf("WARNING: Artist tag not enabled in mpd\n");
if (mpd.tag_album_artist == false)
- printf("WARNING: Albumartist tag not enabled in mpd\n");
+ printf("WARNING: AlbumArtist tag not enabled in mpd\n");
if (mpd.tag_title == false)
printf("WARNING: Title tag not enabled in mpd\n");
if (mpd.tag_track == false)
@@ -868,6 +868,8 @@ char* mympd_get_tag(struct mpd_song const *song, enum mpd_tag_type tag) {
if (str == NULL) {
if (tag == MPD_TAG_TITLE)
str = basename((char *)mpd_song_get_uri(song));
+ else if (tag == MPD_TAG_ALBUM_ARTIST)
+ str = (char *)mpd_song_get_tag(song, MPD_TAG_ARTIST, 0);
else
str = "-";
}
@@ -1419,6 +1421,7 @@ int mympd_put_songs_in_album(char *buffer, char *album, char *search, char *tag)
unsigned long entities_returned = 0;
int len;
char cover[500];
+ char *albumartist;
struct json_out out = JSON_OUT_BUF(buffer, MAX_SIZE);
if (mpd_search_db_songs(mpd.conn, true) == false)
@@ -1440,9 +1443,10 @@ int mympd_put_songs_in_album(char *buffer, char *album, char *search, char *tag)
if (entity_count <= MAX_ELEMENTS_PER_PAGE) {
if (entities_returned ++)
len += json_printf(&out, ", ");
- else
+ else {
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}",
mpd_song_get_uri(song),
mpd_song_get_duration(song),
@@ -1453,15 +1457,17 @@ 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}",
+ len += json_printf(&out, "], totalEntities: %d, returnedEntities: %d, album: %Q, search: %Q, tag: %Q, cover: %Q, albumartist: %Q}",
entity_count,
entities_returned,
album,
search,
tag,
- cover
+ cover,
+ albumartist
);
}
+ free(albumartist);
if (len > MAX_SIZE)
printf("Buffer truncated\n");