mirror of
https://github.com/SuperBFG7/ympd
synced 2025-08-24 06:22:21 +00:00
Added filtering of playlists and database, issue #8
This commit is contained in:
parent
fb96a48d1d
commit
abedf01628
@ -180,7 +180,10 @@ main {
|
|||||||
margin-right:5px;
|
margin-right:5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
#browseFilesystemFilterLetters > button {
|
#browseFilesystemFilterLetters > button,
|
||||||
|
#browseDatabaseFilterLetters > button,
|
||||||
|
#browsePlaylistsFilterLetters > button
|
||||||
|
{
|
||||||
min-width:28px;
|
min-width:28px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -206,16 +206,21 @@
|
|||||||
<a class="nav-link text-dark" href="#/browse/filesystem/0/!/" id="cardBrowseNavFilesystem">Filesystem</a>
|
<a class="nav-link text-dark" href="#/browse/filesystem/0/!/" id="cardBrowseNavFilesystem">Filesystem</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link text-dark" href="#/browse/playlists/0" id="cardBrowseNavPlaylists">Playlists</a>
|
<a class="nav-link text-dark" href="#/browse/playlists/0/!/" id="cardBrowseNavPlaylists">Playlists</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link text-dark" href="#/browse/database/0/" id="cardBrowseNavDatabase">Database</a>
|
<a class="nav-link text-dark" href="#/browse/database/0/!/" id="cardBrowseNavDatabase">Database</a>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="card-body hide" id="cardBrowsePlaylists">
|
<div class="card-body hide" id="cardBrowsePlaylists">
|
||||||
<div class="btn-toolbar collapse show" id="browsePlaylistsButtons" role="toolbar">
|
<div class="btn-toolbar collapse show" id="browsePlaylistsButtons" role="toolbar">
|
||||||
|
<div class="btn-group mr-2">
|
||||||
|
<button id="browsePlaylistsFilter" class="btn btn-secondary dropdown-toggle" type="button" data-toggle="dropdown">Filter</button>
|
||||||
|
<div class="dropdown-menu bg-dark px-2" id="browsePlaylistsFilterLetters">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div id="browsePlaylistsPaginationTop" class="btn-group mr-2">
|
<div id="browsePlaylistsPaginationTop" class="btn-group mr-2">
|
||||||
<button onclick="gotoPage('prev',this,event)" id="browsePlaylistsPaginationTopPrev" title="Previous Page" type="button" class="btn btn-secondary">«</button>
|
<button onclick="gotoPage('prev',this,event)" id="browsePlaylistsPaginationTopPrev" title="Previous Page" type="button" class="btn btn-secondary">«</button>
|
||||||
<div class="input-group-append">
|
<div class="input-group-append">
|
||||||
@ -267,7 +272,12 @@
|
|||||||
|
|
||||||
<div class="btn-toolbar collapse show" id="browseDatabaseButtons" role="toolbar">
|
<div class="btn-toolbar collapse show" id="browseDatabaseButtons" role="toolbar">
|
||||||
<div class="btn-group mr-2">
|
<div class="btn-group mr-2">
|
||||||
<button id="btnBrowseDatabaseArtist" onclick="app.setLocation('#/browse/database/0/');" type="button" class="btn btn-secondary hide">« Artists</button>
|
<button id="btnBrowseDatabaseArtist" onclick="app.setLocation('#/browse/database/0/!/');" type="button" class="btn btn-secondary hide">« Artists</button>
|
||||||
|
</div>
|
||||||
|
<div class="btn-group mr-2">
|
||||||
|
<button id="browseDatabaseFilter" class="btn btn-secondary dropdown-toggle" type="button" data-toggle="dropdown">Filter</button>
|
||||||
|
<div class="dropdown-menu bg-dark px-2" id="browseDatabaseFilterLetters">
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div id="browseDatabasePaginationTop" class="btn-group mr-2">
|
<div id="browseDatabasePaginationTop" class="btn-group mr-2">
|
||||||
<button onclick="gotoPage('prev',this,event)" id="browseDatabasePaginationTopPrev" title="Previous Page" type="button" class="btn btn-secondary">«</button>
|
<button onclick="gotoPage('prev',this,event)" id="browseDatabasePaginationTopPrev" title="Previous Page" type="button" class="btn btn-secondary">«</button>
|
||||||
|
@ -93,32 +93,35 @@ var app = $.sammy(function() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
this.get(/\#\/browse\/playlists\/(\d+)/, function() {
|
this.get(/\#\/browse\/playlists\/(\d+)\/(\w|\!)/, function() {
|
||||||
prepare();
|
prepare();
|
||||||
browsepath = this.params['splat'][1];
|
|
||||||
pagination = parseInt(this.params['splat'][0]);
|
pagination = parseInt(this.params['splat'][0]);
|
||||||
|
filterLetter = this.params['splat'][1];
|
||||||
current_app = 'browsePlaylists';
|
current_app = 'browsePlaylists';
|
||||||
$('#navBrowse').addClass('active');
|
$('#navBrowse').addClass('active');
|
||||||
$('#cardBrowse').removeClass('hide');
|
$('#cardBrowse').removeClass('hide');
|
||||||
$('#cardBrowsePlaylists').removeClass('hide');
|
$('#cardBrowsePlaylists').removeClass('hide');
|
||||||
$('#cardBrowseNavPlaylists').addClass('active');
|
$('#cardBrowseNavPlaylists').addClass('active');
|
||||||
socket.send('MPD_API_GET_PLAYLISTS,'+pagination);
|
socket.send('MPD_API_GET_PLAYLISTS,'+pagination+','+filterLetter);
|
||||||
|
doSetFilterLetter('#browsePlaylistsFilter');
|
||||||
});
|
});
|
||||||
|
|
||||||
this.get(/\#\/browse\/database\/(\d+)\/(.*)/, function() {
|
this.get(/\#\/browse\/database\/(\d+)\/(\w|\!)\/(.*)/, function() {
|
||||||
prepare();
|
prepare();
|
||||||
pagination = parseInt(this.params['splat'][0]);
|
pagination = parseInt(this.params['splat'][0]);
|
||||||
artist = this.params['splat'][1];
|
filterLetter = this.params['splat'][1];
|
||||||
|
artist = this.params['splat'][2];
|
||||||
current_app = 'browseDatabase';
|
current_app = 'browseDatabase';
|
||||||
$('#navBrowse').addClass('active');
|
$('#navBrowse').addClass('active');
|
||||||
$('#cardBrowse').removeClass('hide');
|
$('#cardBrowse').removeClass('hide');
|
||||||
$('#cardBrowseDatabase').removeClass('hide');
|
$('#cardBrowseDatabase').removeClass('hide');
|
||||||
$('#cardBrowseNavDatabase').addClass('active');
|
$('#cardBrowseNavDatabase').addClass('active');
|
||||||
if (artist == "") {
|
if (artist == "") {
|
||||||
socket.send('MPD_API_GET_ARTISTS,'+pagination);
|
socket.send('MPD_API_GET_ARTISTS,' + pagination + ',' + filterLetter);
|
||||||
} else {
|
} else {
|
||||||
socket.send('MPD_API_GET_ARTISTALBUMS,'+pagination+',' + decodeURI(artist));
|
socket.send('MPD_API_GET_ARTISTALBUMS,' + pagination+',' + filterLetter + ',' + decodeURI(artist));
|
||||||
}
|
}
|
||||||
|
doSetFilterLetter('#browseDatabaseFilter');
|
||||||
});
|
});
|
||||||
|
|
||||||
this.get(/\#\/browse\/filesystem\/(\d+)\/(\w|\!)\/(.*)/, function() {
|
this.get(/\#\/browse\/filesystem\/(\d+)\/(\w|\!)\/(.*)/, function() {
|
||||||
@ -133,24 +136,7 @@ var app = $.sammy(function() {
|
|||||||
$('#cardBrowseNavFilesystem').addClass('active');
|
$('#cardBrowseNavFilesystem').addClass('active');
|
||||||
$('#browseBreadcrumb').empty().append("<li class=\"breadcrumb-item\"><a uri=\"\">root</a></li>");
|
$('#browseBreadcrumb').empty().append("<li class=\"breadcrumb-item\"><a uri=\"\">root</a></li>");
|
||||||
socket.send('MPD_API_GET_BROWSE,'+pagination+','+(browsepath ? browsepath : "/")+','+filterLetter);
|
socket.send('MPD_API_GET_BROWSE,'+pagination+','+(browsepath ? browsepath : "/")+','+filterLetter);
|
||||||
$('#browseFilesystemFilterLetters > button').removeClass('btn-success').addClass('btn-secondary');
|
doSetFilterLetter('#browseFilesystemFilter');
|
||||||
if (filterLetter == '0') {
|
|
||||||
$('#browseFilesystemFilter').text('Filter: #');
|
|
||||||
$('#browseFilesystemFilterLetters > button').each(function() {
|
|
||||||
if ($(this).text() == '#') {
|
|
||||||
$(this).addClass('btn-success');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else if (filterLetter != '!') {
|
|
||||||
$('#browseFilesystemFilter').text('Filter: '+filterLetter);
|
|
||||||
$('#browseFilesystemFilterLetters > button').each(function() {
|
|
||||||
if ($(this).text() == filterLetter) {
|
|
||||||
$(this).addClass('btn-success');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
$('#browseFilesystemFilter').text('Filter');
|
|
||||||
}
|
|
||||||
// Don't add all songs from root
|
// Don't add all songs from root
|
||||||
var add_all_songs = $('#browseFilesystemAddAllSongs');
|
var add_all_songs = $('#browseFilesystemAddAllSongs');
|
||||||
if (browsepath) {
|
if (browsepath) {
|
||||||
@ -268,7 +254,9 @@ $(document).ready(function(){
|
|||||||
if (Cookies.get('notificationPage') === 'true')
|
if (Cookies.get('notificationPage') === 'true')
|
||||||
$('#btnnotifyPage').removeClass('btn-secondary').addClass("btn-success")
|
$('#btnnotifyPage').removeClass('btn-secondary').addClass("btn-success")
|
||||||
|
|
||||||
add_filter();
|
add_filter('#browseFilesystemFilterLetters');
|
||||||
|
add_filter('#browseDatabaseFilterLetters');
|
||||||
|
add_filter('#browsePlaylistsFilterLetters');
|
||||||
});
|
});
|
||||||
|
|
||||||
function webSocketConnect() {
|
function webSocketConnect() {
|
||||||
@ -462,7 +450,7 @@ function webSocketConnect() {
|
|||||||
$('#'+current_app+'List > tbody > tr').on({
|
$('#'+current_app+'List > tbody > tr').on({
|
||||||
click: function() {
|
click: function() {
|
||||||
pagination = 0;
|
pagination = 0;
|
||||||
app.setLocation('#/browse/database/'+pagination+'/'+$(this).attr('uri'));
|
app.setLocation('#/browse/database/'+pagination+'/!/'+$(this).attr('uri'));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (nrItems == 0) {
|
if (nrItems == 0) {
|
||||||
@ -1169,10 +1157,10 @@ function gotoPage(x,element,event) {
|
|||||||
app.setLocation('#/browse/filesystem/'+pagination+'/'+filterLetter+'/'+browsepath);
|
app.setLocation('#/browse/filesystem/'+pagination+'/'+filterLetter+'/'+browsepath);
|
||||||
break;
|
break;
|
||||||
case "browsePlaylists":
|
case "browsePlaylists":
|
||||||
app.setLocation('#/browse/playlists/'+pagination);
|
app.setLocation('#/browse/playlists/'+pagination+'/'+filterLetter);
|
||||||
break;
|
break;
|
||||||
case "browseDatabase":
|
case "browseDatabase":
|
||||||
app.setLocation('#/browse/database/'+pagination+'/'+artist);
|
app.setLocation('#/browse/database/'+pagination+'/'+filterLetter+'/'+artist);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
@ -1282,16 +1270,47 @@ $(document).keydown(function(e){
|
|||||||
|
|
||||||
function setFilterLetter(filter) {
|
function setFilterLetter(filter) {
|
||||||
pagination = 0;
|
pagination = 0;
|
||||||
app.setLocation('#/browse/filesystem/'+pagination+'/'+filter+'/'+browsepath);
|
switch(current_app) {
|
||||||
|
case 'browseFilesystem':
|
||||||
|
app.setLocation('#/browse/filesystem/'+pagination+'/'+filter+'/'+browsepath);
|
||||||
|
break;
|
||||||
|
case 'browseDatabase':
|
||||||
|
app.setLocation('#/browse/database/'+pagination+'/'+filter+'/'+artist);
|
||||||
|
break;
|
||||||
|
case 'browsePlaylists':
|
||||||
|
app.setLocation('#/browse/playlists/'+pagination+'/'+filter+'/'+artist);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function add_filter () {
|
function doSetFilterLetter(x) {
|
||||||
$('#browseFilesystemFilterLetters').append('<button class="mr-1 mb-1 btn btn-sm btn-secondary" onclick="setFilterLetter(\'!\');">'+
|
$(x+'Letters > button').removeClass('btn-success').addClass('btn-secondary');
|
||||||
|
if (filterLetter == '0') {
|
||||||
|
$(x).text('Filter: #');
|
||||||
|
$(x+'Letters > button').each(function() {
|
||||||
|
if ($(this).text() == '#') {
|
||||||
|
$(this).addClass('btn-success');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else if (filterLetter != '!') {
|
||||||
|
$(x).text('Filter: '+filterLetter);
|
||||||
|
$(x+'Letters > button').each(function() {
|
||||||
|
if ($(this).text() == filterLetter) {
|
||||||
|
$(this).addClass('btn-success');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
$(x).text('Filter');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function add_filter (x) {
|
||||||
|
$(x).append('<button class="mr-1 mb-1 btn btn-sm btn-secondary" onclick="setFilterLetter(\'!\');">'+
|
||||||
'<span class="material-icons" style="font-size:14px;">delete</span></button>');
|
'<span class="material-icons" style="font-size:14px;">delete</span></button>');
|
||||||
$('#browseFilesystemFilterLetters').append('<button class="mr-1 mb-1 btn btn-sm btn-secondary" onclick="setFilterLetter(\'0\');">#</button>');
|
$(x).append('<button class="mr-1 mb-1 btn btn-sm btn-secondary" onclick="setFilterLetter(\'0\');">#</button>');
|
||||||
for (i = 65; i <= 90; i++) {
|
for (i = 65; i <= 90; i++) {
|
||||||
var c = String.fromCharCode(i);
|
var c = String.fromCharCode(i);
|
||||||
$('#browseFilesystemFilterLetters').append('<button class="mr-1 mb-1 btn-sm btn btn-secondary" onclick="setFilterLetter(\'' + c + '\');">' + c + '</button>');
|
$(x).append('<button class="mr-1 mb-1 btn-sm btn btn-secondary" onclick="setFilterLetter(\'' + c + '\');">' + c + '</button>');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
134
src/mpd_client.c
134
src/mpd_client.c
@ -172,8 +172,20 @@ int callback_mpd(struct mg_connection *c)
|
|||||||
n = mpd_put_queue(mpd.buf, uint_buf);
|
n = mpd_put_queue(mpd.buf, uint_buf);
|
||||||
break;
|
break;
|
||||||
case MPD_API_GET_ARTISTS:
|
case MPD_API_GET_ARTISTS:
|
||||||
if(sscanf(c->content, "MPD_API_GET_ARTISTS,%u", &uint_buf))
|
p_charbuf = strdup(c->content);
|
||||||
n = mympd_put_db_tag(mpd.buf, uint_buf, "AlbumArtist","","");
|
if(strcmp(strtok(p_charbuf, ","), "MPD_API_GET_ARTISTS"))
|
||||||
|
goto out_artist;
|
||||||
|
uint_buf = strtoul(strtok(NULL, ","), NULL, 10);
|
||||||
|
|
||||||
|
if((token = strtok(NULL, ",")) == NULL) {
|
||||||
|
goto out_artist;
|
||||||
|
} else {
|
||||||
|
p_charbuf2 = strdup(token);
|
||||||
|
}
|
||||||
|
n = mympd_put_db_tag(mpd.buf, uint_buf, "AlbumArtist","","",p_charbuf2);
|
||||||
|
free(p_charbuf2);
|
||||||
|
out_artist:
|
||||||
|
free(p_charbuf);
|
||||||
break;
|
break;
|
||||||
case MPD_API_GET_ARTISTALBUMS:
|
case MPD_API_GET_ARTISTALBUMS:
|
||||||
p_charbuf = strdup(c->content);
|
p_charbuf = strdup(c->content);
|
||||||
@ -183,13 +195,21 @@ int callback_mpd(struct mg_connection *c)
|
|||||||
|
|
||||||
if((token = strtok(NULL, ",")) == NULL) {
|
if((token = strtok(NULL, ",")) == NULL) {
|
||||||
goto out_artistalbum;
|
goto out_artistalbum;
|
||||||
|
} else {
|
||||||
|
p_charbuf2 = strdup(token);
|
||||||
|
}
|
||||||
|
|
||||||
|
if((token = strtok(NULL, ",")) == NULL) {
|
||||||
|
free(p_charbuf2);
|
||||||
|
goto out_artistalbum;
|
||||||
} else {
|
} else {
|
||||||
searchstr = strdup(token);
|
searchstr = strdup(token);
|
||||||
}
|
}
|
||||||
n = mympd_put_db_tag(mpd.buf, uint_buf, "Album", "AlbumArtist", searchstr);
|
n = mympd_put_db_tag(mpd.buf, uint_buf, "Album", "AlbumArtist", searchstr, p_charbuf2);
|
||||||
free(searchstr);
|
free(searchstr);
|
||||||
|
free(p_charbuf2);
|
||||||
out_artistalbum:
|
out_artistalbum:
|
||||||
free(p_charbuf);
|
free(p_charbuf);
|
||||||
break;
|
break;
|
||||||
case MPD_API_GET_ARTISTALBUMTITLES:
|
case MPD_API_GET_ARTISTALBUMTITLES:
|
||||||
p_charbuf = strdup(c->content);
|
p_charbuf = strdup(c->content);
|
||||||
@ -201,20 +221,26 @@ out_artistalbum:
|
|||||||
} else {
|
} else {
|
||||||
searchstr = strdup(token);
|
searchstr = strdup(token);
|
||||||
}
|
}
|
||||||
/* if((token = strtok(NULL, ",")) == NULL) {
|
|
||||||
goto out_artistalbumtitle;
|
|
||||||
} else {
|
|
||||||
p_charbuf2 = strdup(token);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
n = mympd_put_songs_in_album(mpd.buf, searchstr, token+strlen(token)+1);
|
n = mympd_put_songs_in_album(mpd.buf, searchstr, token+strlen(token)+1);
|
||||||
free(searchstr);
|
free(searchstr);
|
||||||
out_artistalbumtitle:
|
out_artistalbumtitle:
|
||||||
free(p_charbuf);
|
free(p_charbuf);
|
||||||
break;
|
break;
|
||||||
case MPD_API_GET_PLAYLISTS:
|
case MPD_API_GET_PLAYLISTS:
|
||||||
if(sscanf(c->content, "MPD_API_GET_PLAYLISTS,%u", &uint_buf))
|
p_charbuf = strdup(c->content);
|
||||||
n = mpd_put_playlists(mpd.buf, uint_buf);
|
if(strcmp(strtok(p_charbuf, ","), "MPD_API_GET_PLAYLISTS"))
|
||||||
|
goto out_artist;
|
||||||
|
uint_buf = strtoul(strtok(NULL, ","), NULL, 10);
|
||||||
|
|
||||||
|
if((token = strtok(NULL, ",")) == NULL) {
|
||||||
|
goto out_playlists;
|
||||||
|
} else {
|
||||||
|
p_charbuf2 = strdup(token);
|
||||||
|
}
|
||||||
|
n = mympd_put_playlists(mpd.buf, uint_buf, p_charbuf2);
|
||||||
|
free(p_charbuf2);
|
||||||
|
out_playlists:
|
||||||
|
free(p_charbuf);
|
||||||
break;
|
break;
|
||||||
case MPD_API_GET_BROWSE:
|
case MPD_API_GET_BROWSE:
|
||||||
p_charbuf = strdup(c->content);
|
p_charbuf = strdup(c->content);
|
||||||
@ -971,12 +997,14 @@ int mpd_put_browse(char *buffer, char *path, unsigned int offset, char *filter)
|
|||||||
cur += json_emit_raw_str(cur, end - cur, ",\"offset\":");
|
cur += json_emit_raw_str(cur, end - cur, ",\"offset\":");
|
||||||
cur += json_emit_int(cur, end - cur, offset);
|
cur += json_emit_int(cur, end - cur, offset);
|
||||||
cur += json_emit_raw_str(cur, end - cur, ",\"returnedEntities\":");
|
cur += json_emit_raw_str(cur, end - cur, ",\"returnedEntities\":");
|
||||||
cur += json_emit_int(cur, end - cur, entities_returned);
|
cur += json_emit_int(cur, end - cur, entities_returned);
|
||||||
|
cur += json_emit_raw_str(cur, end - cur, ",\"filter\":");
|
||||||
|
cur += json_emit_quoted_str(cur, end - cur, filter);
|
||||||
cur += json_emit_raw_str(cur, end - cur, "}");
|
cur += json_emit_raw_str(cur, end - cur, "}");
|
||||||
return cur - buffer;
|
return cur - buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
int mympd_put_db_tag(char *buffer, unsigned int offset, char *mpdtagtype, char *mpdsearchtagtype, char *searchstr)
|
int mympd_put_db_tag(char *buffer, unsigned int offset, char *mpdtagtype, char *mpdsearchtagtype, char *searchstr, char *filter)
|
||||||
{
|
{
|
||||||
char *cur = buffer;
|
char *cur = buffer;
|
||||||
const char *end = buffer + MAX_SIZE;
|
const char *end = buffer + MAX_SIZE;
|
||||||
@ -994,39 +1022,47 @@ int mympd_put_db_tag(char *buffer, unsigned int offset, char *mpdtagtype, char *
|
|||||||
|
|
||||||
if(mpd_search_commit(mpd.conn) == false)
|
if(mpd_search_commit(mpd.conn) == false)
|
||||||
RETURN_ERROR_AND_RECOVER("mpd_search_commit");
|
RETURN_ERROR_AND_RECOVER("mpd_search_commit");
|
||||||
else {
|
|
||||||
cur += json_emit_raw_str(cur, end - cur, "{\"type\":\"listDBtags\",\"data\":[ ");
|
cur += json_emit_raw_str(cur, end - cur, "{\"type\":\"listDBtags\",\"data\":[ ");
|
||||||
while((pair = mpd_recv_pair_tag(mpd.conn, mpd_tag_name_parse(mpdtagtype))) != NULL) {
|
while((pair = mpd_recv_pair_tag(mpd.conn, mpd_tag_name_parse(mpdtagtype))) != NULL) {
|
||||||
entity_count ++;
|
entity_count ++;
|
||||||
if(entity_count > offset && entity_count <= offset+MAX_ELEMENTS_PER_PAGE) {
|
if(entity_count > offset && entity_count <= offset+MAX_ELEMENTS_PER_PAGE) {
|
||||||
|
if (strncmp(filter,"!",1) == 0 || strncasecmp(filter,pair->value,1) == 0 ||
|
||||||
|
( strncmp(filter,"0",1) == 0 && isalpha(*pair->value) == 0 )
|
||||||
|
) {
|
||||||
entities_returned ++;
|
entities_returned ++;
|
||||||
cur += json_emit_raw_str(cur, end - cur, "{\"type\":");
|
cur += json_emit_raw_str(cur, end - cur, "{\"type\":");
|
||||||
cur += json_emit_quoted_str(cur, end - cur, mpdtagtype);
|
cur += json_emit_quoted_str(cur, end - cur, mpdtagtype);
|
||||||
cur += json_emit_raw_str(cur, end - cur, ",\"value\":");
|
cur += json_emit_raw_str(cur, end - cur, ",\"value\":");
|
||||||
cur += json_emit_quoted_str(cur, end - cur, pair->value);
|
cur += json_emit_quoted_str(cur, end - cur, pair->value);
|
||||||
cur += json_emit_raw_str(cur, end - cur, "},");
|
cur += json_emit_raw_str(cur, end - cur, "},");
|
||||||
|
} else {
|
||||||
|
entity_count --;
|
||||||
}
|
}
|
||||||
mpd_return_pair(mpd.conn, pair);
|
|
||||||
}
|
}
|
||||||
|
mpd_return_pair(mpd.conn, pair);
|
||||||
/* remove last ',' */
|
|
||||||
cur--;
|
|
||||||
|
|
||||||
cur += json_emit_raw_str(cur, end - cur, "]");
|
|
||||||
cur += json_emit_raw_str(cur, end - cur, ",\"totalEntities\":");
|
|
||||||
cur += json_emit_int(cur, end - cur, entity_count);
|
|
||||||
cur += json_emit_raw_str(cur, end - cur, ",\"offset\":");
|
|
||||||
cur += json_emit_int(cur, end - cur, offset);
|
|
||||||
cur += json_emit_raw_str(cur, end - cur, ",\"returnedEntities\":");
|
|
||||||
cur += json_emit_int(cur, end - cur, entities_returned);
|
|
||||||
cur += json_emit_raw_str(cur, end - cur, ",\"tagtype\":");
|
|
||||||
cur += json_emit_quoted_str(cur, end - cur, mpdtagtype);
|
|
||||||
cur += json_emit_raw_str(cur, end - cur, ",\"searchtagtype\":");
|
|
||||||
cur += json_emit_quoted_str(cur, end - cur, mpdsearchtagtype);
|
|
||||||
cur += json_emit_raw_str(cur, end - cur, ",\"searchstr\":");
|
|
||||||
cur += json_emit_quoted_str(cur, end - cur, searchstr);
|
|
||||||
cur += json_emit_raw_str(cur, end - cur, "}");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* remove last ',' */
|
||||||
|
cur--;
|
||||||
|
|
||||||
|
cur += json_emit_raw_str(cur, end - cur, "]");
|
||||||
|
cur += json_emit_raw_str(cur, end - cur, ",\"totalEntities\":");
|
||||||
|
cur += json_emit_int(cur, end - cur, entity_count);
|
||||||
|
cur += json_emit_raw_str(cur, end - cur, ",\"offset\":");
|
||||||
|
cur += json_emit_int(cur, end - cur, offset);
|
||||||
|
cur += json_emit_raw_str(cur, end - cur, ",\"returnedEntities\":");
|
||||||
|
cur += json_emit_int(cur, end - cur, entities_returned);
|
||||||
|
cur += json_emit_raw_str(cur, end - cur, ",\"tagtype\":");
|
||||||
|
cur += json_emit_quoted_str(cur, end - cur, mpdtagtype);
|
||||||
|
cur += json_emit_raw_str(cur, end - cur, ",\"searchtagtype\":");
|
||||||
|
cur += json_emit_quoted_str(cur, end - cur, mpdsearchtagtype);
|
||||||
|
cur += json_emit_raw_str(cur, end - cur, ",\"searchstr\":");
|
||||||
|
cur += json_emit_quoted_str(cur, end - cur, searchstr);
|
||||||
|
cur += json_emit_raw_str(cur, end - cur, ",\"filter\":");
|
||||||
|
cur += json_emit_quoted_str(cur, end - cur, filter);
|
||||||
|
cur += json_emit_raw_str(cur, end - cur, "}");
|
||||||
|
|
||||||
return cur - buffer;
|
return cur - buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1088,13 +1124,14 @@ int mympd_put_songs_in_album(char *buffer, char *albumartist, char *album)
|
|||||||
return cur - buffer;
|
return cur - buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
int mpd_put_playlists(char *buffer, unsigned int offset)
|
int mympd_put_playlists(char *buffer, unsigned int offset, char *filter)
|
||||||
{
|
{
|
||||||
char *cur = buffer;
|
char *cur = buffer;
|
||||||
const char *end = buffer + MAX_SIZE;
|
const char *end = buffer + MAX_SIZE;
|
||||||
struct mpd_playlist *pl;
|
struct mpd_playlist *pl;
|
||||||
unsigned int entity_count = 0;
|
unsigned int entity_count = 0;
|
||||||
unsigned int entities_returned = 0;
|
unsigned int entities_returned = 0;
|
||||||
|
const char *plpath;
|
||||||
|
|
||||||
if (!mpd_send_list_playlists(mpd.conn))
|
if (!mpd_send_list_playlists(mpd.conn))
|
||||||
RETURN_ERROR_AND_RECOVER("mpd_send_lists_playlists");
|
RETURN_ERROR_AND_RECOVER("mpd_send_lists_playlists");
|
||||||
@ -1104,12 +1141,19 @@ int mpd_put_playlists(char *buffer, unsigned int offset)
|
|||||||
while((pl = mpd_recv_playlist(mpd.conn)) != NULL) {
|
while((pl = mpd_recv_playlist(mpd.conn)) != NULL) {
|
||||||
entity_count ++;
|
entity_count ++;
|
||||||
if(entity_count > offset && entity_count <= offset+MAX_ELEMENTS_PER_PAGE) {
|
if(entity_count > offset && entity_count <= offset+MAX_ELEMENTS_PER_PAGE) {
|
||||||
entities_returned ++;
|
plpath = mpd_playlist_get_path(pl);
|
||||||
cur += json_emit_raw_str(cur, end - cur, "{\"type\":\"playlist\",\"plist\":");
|
if (strncmp(filter,"!",1) == 0 || strncasecmp(filter,plpath,1) == 0 ||
|
||||||
cur += json_emit_quoted_str(cur, end - cur, mpd_playlist_get_path(pl));
|
( strncmp(filter,"0",1) == 0 && isalpha(*plpath) == 0 )
|
||||||
cur += json_emit_raw_str(cur, end - cur, ",\"last_modified\":");
|
) {
|
||||||
cur += json_emit_int(cur, end - cur, mpd_playlist_get_last_modified(pl));
|
entities_returned ++;
|
||||||
cur += json_emit_raw_str(cur, end - cur, "},");
|
cur += json_emit_raw_str(cur, end - cur, "{\"type\":\"playlist\",\"plist\":");
|
||||||
|
cur += json_emit_quoted_str(cur, end - cur, plpath);
|
||||||
|
cur += json_emit_raw_str(cur, end - cur, ",\"last_modified\":");
|
||||||
|
cur += json_emit_int(cur, end - cur, mpd_playlist_get_last_modified(pl));
|
||||||
|
cur += json_emit_raw_str(cur, end - cur, "},");
|
||||||
|
} else {
|
||||||
|
entity_count --;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
mpd_playlist_free(pl);
|
mpd_playlist_free(pl);
|
||||||
}
|
}
|
||||||
|
@ -132,15 +132,15 @@ int mpd_put_state(char *buffer, int *current_song_id, int *next_song_id, unsigne
|
|||||||
int mpd_put_outputs(char *buffer, int putnames);
|
int mpd_put_outputs(char *buffer, int putnames);
|
||||||
int mpd_put_current_song(char *buffer);
|
int mpd_put_current_song(char *buffer);
|
||||||
int mpd_put_queue(char *buffer, unsigned int offset);
|
int mpd_put_queue(char *buffer, unsigned int offset);
|
||||||
int mpd_put_playlists(char *buffer, unsigned int offset);
|
|
||||||
int mpd_put_browse(char *buffer, char *path, unsigned int offset, char *filter);
|
int mpd_put_browse(char *buffer, char *path, unsigned int offset, char *filter);
|
||||||
int mpd_search(char *buffer, char *mpdtagtype, unsigned int offset, char *searchstr);
|
int mpd_search(char *buffer, char *mpdtagtype, unsigned int offset, char *searchstr);
|
||||||
int mpd_search_add(char *buffer, char *mpdtagtype, char *searchstr);
|
int mpd_search_add(char *buffer, char *mpdtagtype, char *searchstr);
|
||||||
int mpd_search_queue(char *buffer, char *mpdtagtype, unsigned int offset, char *searchstr);
|
int mpd_search_queue(char *buffer, char *mpdtagtype, unsigned int offset, char *searchstr);
|
||||||
int mympd_get_stats(char *buffer);
|
int mympd_get_stats(char *buffer);
|
||||||
int mympd_put_settings(char *buffer);
|
int mympd_put_settings(char *buffer);
|
||||||
int mympd_put_db_tag(char *buffer, unsigned int offset, char *mpdtagtype, char *mpdsearchtagtype, char *searchstr);
|
int mympd_put_db_tag(char *buffer, unsigned int offset, char *mpdtagtype, char *mpdsearchtagtype, char *searchstr, char *filter);
|
||||||
int mympd_put_songs_in_album(char *buffer, char *albumartist, char *album);
|
int mympd_put_songs_in_album(char *buffer, char *albumartist, char *album);
|
||||||
|
int mympd_put_playlists(char *buffer, unsigned int offset, char *filter);
|
||||||
void mpd_disconnect();
|
void mpd_disconnect();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user