mirror of
https://github.com/SuperBFG7/ympd
synced 2025-03-04 02:28:19 +00:00
Feat: add all from search to a playlist
This commit is contained in:
parent
d6a24d4531
commit
712966348e
@ -432,8 +432,8 @@
|
||||
</form>
|
||||
<div class="input-group mr-2">
|
||||
<div class="input-group-prepend">
|
||||
<button id="searchAddAllSongs" class="btn btn-secondary rounded-right" data-href="{'cmd': 'addAllFromSearch', 'options': []}">Add all</button>
|
||||
<button id="searchAddAllSongsBtn" class="btn btn-secondary dropdown-toggle dropdown-toggle-split rounded-right hide" type="button" data-toggle="dropdown"></button>
|
||||
<button id="searchAddAllSongs" class="btn btn-secondary" data-href="{'cmd': 'addAllFromSearch', 'options': []}">Add all</button>
|
||||
<button id="searchAddAllSongsBtn" class="btn btn-secondary dropdown-toggle dropdown-toggle-split rounded-right" type="button" data-toggle="dropdown"></button>
|
||||
<div class="dropdown-menu bg-dark dropdown-menu-right px-2" id="searchAddAllSongsDropdown">
|
||||
<button type="button" class="btn btn-secondary btn-block">Add all to queue</button>
|
||||
<button type="button" class="btn btn-secondary btn-block">Add all to playlist</button>
|
||||
|
@ -1684,7 +1684,11 @@ function addAllFromSearch() {
|
||||
|
||||
function addAllFromSearchPlist(plist) {
|
||||
if (app.current.search.length >= 2) {
|
||||
sendAPI({"cmd":"MPD_API_SEARCH_ADD_PLIST", "data":{ "plist": plist, "filter": app.current.filter, "searchstr": app.current.search}});
|
||||
var filter = app.current.filter;
|
||||
if (filter == 'Any Tag')
|
||||
filter = 'any';
|
||||
|
||||
sendAPI({"cmd":"MPD_API_SEARCH_ADD_PLIST", "data":{ "plist": plist, "filter": filter, "searchstr": app.current.search}});
|
||||
showNotification('Added '+ parseInt(document.getElementById('panel-heading-search').innerText) +' songs from search to ' + plist, '', '', 'success');
|
||||
}
|
||||
}
|
||||
|
@ -1309,30 +1309,15 @@ int mympd_search_add(char *buffer, char *mpdtagtype, char *searchstr) {
|
||||
|
||||
int mympd_search_add_plist(char *buffer, char *plist, char *mpdtagtype, char *searchstr) {
|
||||
int len = 0;
|
||||
struct mpd_song *song;
|
||||
struct json_out out = JSON_OUT_BUF(buffer, MAX_SIZE);
|
||||
|
||||
if (mpd_search_db_songs(mpd.conn, false) == false) {
|
||||
RETURN_ERROR_AND_RECOVER("mpd_search_add_db_songs");
|
||||
}
|
||||
|
||||
if (mpd_tag_name_parse(mpdtagtype) != MPD_TAG_UNKNOWN) {
|
||||
if (mpd_search_add_tag_constraint(mpd.conn, MPD_OPERATOR_DEFAULT, mpd_tag_name_parse(mpdtagtype), searchstr) == false)
|
||||
RETURN_ERROR_AND_RECOVER("mpd_search_add_tag_constraint");
|
||||
}
|
||||
else {
|
||||
if (mpd_search_add_any_tag_constraint(mpd.conn, MPD_OPERATOR_DEFAULT, searchstr) == false)
|
||||
RETURN_ERROR_AND_RECOVER("mpd_search_add_any_tag_constraint");
|
||||
struct mpd_pair *pair;
|
||||
|
||||
mpd_send_command(mpd.conn, "searchaddpl", plist, mpdtagtype, searchstr, NULL);
|
||||
|
||||
while ((pair = mpd_recv_pair(mpd.conn)) != NULL) {
|
||||
mpd_return_pair(mpd.conn, pair);
|
||||
}
|
||||
|
||||
if (mpd_search_commit(mpd.conn) == false)
|
||||
RETURN_ERROR_AND_RECOVER("mpd_search_commit");
|
||||
|
||||
while((song = mpd_recv_song(mpd.conn)) != NULL) {
|
||||
// mpd_send_playlist_add(mpd.conn, plist, mpd_song_get_uri(song));
|
||||
mpd_song_free(song);
|
||||
}
|
||||
|
||||
|
||||
if (len > MAX_SIZE)
|
||||
fprintf(stderr,"Buffer truncated\n");
|
||||
return len;
|
||||
|
Loading…
x
Reference in New Issue
Block a user