mirror of
https://github.com/owntone/owntone-server.git
synced 2025-02-25 04:19:15 -05:00
[smartpl] refactoring: repurpose playlist type PL_SMART for user created
smart playlists and introduce new type PL_SPECIAL for special system playlists
This commit is contained in:
parent
2c5ab966e5
commit
a174a1d18c
9
src/db.c
9
src/db.c
@ -663,7 +663,7 @@ db_set_cfg_names(void)
|
||||
continue;
|
||||
}
|
||||
|
||||
query = sqlite3_mprintf(Q_TMPL, title, PL_SMART, special_id[i]);
|
||||
query = sqlite3_mprintf(Q_TMPL, title, PL_SPECIAL, special_id[i]);
|
||||
if (!query)
|
||||
{
|
||||
DPRINTF(E_LOG, L_DB, "Out of memory for query string\n");
|
||||
@ -718,7 +718,7 @@ db_purge_cruft(time_t ref)
|
||||
|
||||
for (i = 0; i < (sizeof(queries_tmpl) / sizeof(queries_tmpl[0])); i++)
|
||||
{
|
||||
queries[i] = sqlite3_mprintf(queries_tmpl[i], PL_SMART, (int64_t)ref);
|
||||
queries[i] = sqlite3_mprintf(queries_tmpl[i], PL_SPECIAL, (int64_t)ref);
|
||||
if (!queries[i])
|
||||
{
|
||||
DPRINTF(E_LOG, L_DB, "Out of memory for query string\n");
|
||||
@ -780,7 +780,7 @@ db_purge_all(void)
|
||||
DPRINTF(E_DBG, L_DB, "Purged %d rows\n", sqlite3_changes(hdl));
|
||||
}
|
||||
|
||||
query = sqlite3_mprintf(Q_TMPL, PL_SMART);
|
||||
query = sqlite3_mprintf(Q_TMPL, PL_SPECIAL);
|
||||
if (!query)
|
||||
{
|
||||
DPRINTF(E_LOG, L_DB, "Out of memory for query string\n");
|
||||
@ -1141,6 +1141,7 @@ db_build_query_plitems(struct query_params *qp, char **q)
|
||||
|
||||
switch (pli->type)
|
||||
{
|
||||
case PL_SPECIAL:
|
||||
case PL_SMART:
|
||||
ret = db_build_query_plitems_smart(qp, pli->query, q);
|
||||
break;
|
||||
@ -1722,6 +1723,7 @@ db_query_fetch_pl(struct query_params *qp, struct db_playlist_info *dbpli)
|
||||
nstreams = db_pl_count_items(id, 1);
|
||||
break;
|
||||
|
||||
case PL_SPECIAL:
|
||||
case PL_SMART:
|
||||
nitems = db_smartpl_count_items(dbpli->query);
|
||||
nstreams = 0;
|
||||
@ -3041,6 +3043,7 @@ db_pl_fetch_byquery(char *query)
|
||||
pli->streams = db_pl_count_items(pli->id, 1);
|
||||
break;
|
||||
|
||||
case PL_SPECIAL:
|
||||
case PL_SMART:
|
||||
pli->items = db_smartpl_count_items(pli->query);
|
||||
break;
|
||||
|
5
src/db.h
5
src/db.h
@ -166,11 +166,12 @@ struct media_file_info {
|
||||
|
||||
#define mfi_offsetof(field) offsetof(struct media_file_info, field)
|
||||
|
||||
/* PL_SMART value must be in sync with type value in Q_PL* in db.c */
|
||||
/* PL_SPECIAL value must be in sync with type value in Q_PL* in db.c */
|
||||
enum pl_type {
|
||||
PL_PLAIN = 0,
|
||||
PL_FOLDER = 1,
|
||||
PL_SMART = 2,
|
||||
PL_SPECIAL = 2,
|
||||
PL_SMART = 3,
|
||||
PL_MAX,
|
||||
};
|
||||
|
||||
|
@ -1685,8 +1685,8 @@ daap_reply_playlists(struct evhttp_request *req, struct evbuffer *evbuf, char **
|
||||
if (!cfg_radiopl && (database != DAAP_DB_RADIO) && (plstreams > 0) && (plstreams == plitems))
|
||||
continue;
|
||||
|
||||
/* Don't add empty Smart playlists */
|
||||
if ((plid > 1) && (plitems == 0) && (pltype == PL_SMART))
|
||||
/* Don't add empty Special playlists */
|
||||
if ((plid > 1) && (plitems == PL_SPECIAL) && (pltype == 1))
|
||||
continue;
|
||||
|
||||
npls++;
|
||||
@ -1700,14 +1700,20 @@ daap_reply_playlists(struct evhttp_request *req, struct evbuffer *evbuf, char **
|
||||
if (dfm == &dfm_dmap_mimc)
|
||||
continue;
|
||||
|
||||
/* com.apple.itunes.smart-playlist - type = PL_SMART AND id != 1 */
|
||||
/* Add field "com.apple.itunes.smart-playlist" for special and smart playlists
|
||||
(excluding the special playlist for "library" with id = 1) */
|
||||
if (dfm == &dfm_dmap_aeSP)
|
||||
{
|
||||
if ((pltype == PL_SMART) && (plid != 1))
|
||||
if ((pltype == PL_SMART) || ((pltype == PL_SPECIAL) && (plid != 1)))
|
||||
{
|
||||
dmap_add_char(playlist, "aeSP", 1);
|
||||
}
|
||||
|
||||
/* Add field "com.apple.itunes.special-playlist" for special playlists
|
||||
(excluding the special playlist for "library" with id = 1) */
|
||||
if ((pltype == PL_SPECIAL) && (plid != 1))
|
||||
{
|
||||
int32_t aePS = 0;
|
||||
dmap_add_char(playlist, "aeSP", 1);
|
||||
|
||||
ret = safe_atoi32(dbpli.special_id, &aePS);
|
||||
if ((ret == 0) && (aePS > 0))
|
||||
dmap_add_char(playlist, "aePS", aePS);
|
||||
|
Loading…
x
Reference in New Issue
Block a user