mirror of
https://github.com/owntone/owntone-server.git
synced 2024-12-24 22:25:56 -05:00
Add count value to smart playlists, closing #150
This commit is contained in:
parent
fffe34e5eb
commit
a8b6d93c07
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<h2>Smart Playlists</h2>
|
<h2>Smart Playlists</h2>
|
||||||
<table cellspacing="0" >
|
<table cellspacing="0" >
|
||||||
<thead><tr><th>ID</th><th>Playlist Name</th><th>Type</th><th>Action</th></tr></thead>
|
<thead><tr><th>ID</th><th>Playlist Name</th><th>Type</th><th>Count</th><th>Action</th></tr></thead>
|
||||||
<tbody id="playlists">
|
<tbody id="playlists">
|
||||||
<tr><td></td></tr>
|
<tr><td></td></tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
|
@ -172,6 +172,7 @@ function pl_process() {
|
|||||||
var pl_id;
|
var pl_id;
|
||||||
var pl_name;
|
var pl_name;
|
||||||
var pl_type;
|
var pl_type;
|
||||||
|
var pl_count;
|
||||||
|
|
||||||
pl_id=playlists[x].getElementsByTagName("dmap.itemid")[0].firstChild.nodeValue;
|
pl_id=playlists[x].getElementsByTagName("dmap.itemid")[0].firstChild.nodeValue;
|
||||||
if(playlists[x].getElementsByTagName("dmap.itemname")[0].firstChild) {
|
if(playlists[x].getElementsByTagName("dmap.itemname")[0].firstChild) {
|
||||||
@ -180,6 +181,7 @@ function pl_process() {
|
|||||||
pl_name = "";
|
pl_name = "";
|
||||||
}
|
}
|
||||||
pl_type=playlists[x].getElementsByTagName("org.mt-daapd.playlist-type")[0].firstChild.nodeValue;
|
pl_type=playlists[x].getElementsByTagName("org.mt-daapd.playlist-type")[0].firstChild.nodeValue;
|
||||||
|
pl_count=playlists[x].getElementsByTagName("dmap.itemcount")[0].firstChild.nodeValue;
|
||||||
|
|
||||||
|
|
||||||
playlist_info[String(pl_id)] = { 'name': pl_name, 'type': pl_type };
|
playlist_info[String(pl_id)] = { 'name': pl_name, 'type': pl_type };
|
||||||
@ -209,20 +211,24 @@ function pl_process() {
|
|||||||
var td2 = document.createElement("td");
|
var td2 = document.createElement("td");
|
||||||
var td3 = document.createElement("td");
|
var td3 = document.createElement("td");
|
||||||
var td4 = document.createElement("td");
|
var td4 = document.createElement("td");
|
||||||
|
var td5 = document.createElement("td");
|
||||||
|
|
||||||
td1.innerHTML=pl_id + '\n';
|
td1.innerHTML=pl_id + '\n';
|
||||||
td2.innerHTML=pl_name + '\n';
|
td2.innerHTML=pl_name + '\n';
|
||||||
td3.innerHTML=pl_type + '\n';
|
td3.innerHTML=pl_type + '\n';
|
||||||
|
td4.innerHTML=pl_count + '\n';
|
||||||
if((pl_id != 1) && (playlist_info[pl_id]['type'] == 1)) {
|
if((pl_id != 1) && (playlist_info[pl_id]['type'] == 1)) {
|
||||||
td4.innerHTML='<a href="javascript:pl_edit(' + pl_id + ')">Edit</a>';
|
td5.innerHTML='<a href="javascript:pl_edit(' + pl_id + ')">Edit</a>';
|
||||||
td4.innerHTML = td4.innerHTML + ' <a href="javascript:pl_delete(' + pl_id + ')">Delete</a>';
|
td5.innerHTML = td5.innerHTML + ' <a href="javascript:pl_delete(' + pl_id + ')">Delete</a>';
|
||||||
} else {
|
} else {
|
||||||
td4.innerHTML=" ";
|
td5.innerHTML=" ";
|
||||||
}
|
}
|
||||||
|
|
||||||
row.appendChild(td1);
|
row.appendChild(td1);
|
||||||
row.appendChild(td2);
|
row.appendChild(td2);
|
||||||
row.appendChild(td3);
|
row.appendChild(td3);
|
||||||
row.appendChild(td4);
|
row.appendChild(td4);
|
||||||
|
row.appendChild(td5);
|
||||||
pl_table.appendChild(row);
|
pl_table.appendChild(row);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
28
src/db-sql.c
28
src/db-sql.c
@ -632,17 +632,24 @@ int db_sql_edit_playlist(char **pe, int id, char *name, char *clause) {
|
|||||||
return DB_E_DUPLICATE_PLAYLIST;
|
return DB_E_DUPLICATE_PLAYLIST;
|
||||||
}
|
}
|
||||||
|
|
||||||
if((playlist_type == PL_SMART)&&(clause))
|
if((playlist_type == PL_SMART)&&(clause)) {
|
||||||
return db_sql_exec_fn(pe,E_LOG,"update playlists set title='%q', "
|
result=db_sql_exec_fn(pe,E_LOG,"update playlists set title='%q', "
|
||||||
"query='%q' where id=%d",name,clause,id);
|
"query='%q' where id=%d",name,clause,id);
|
||||||
|
|
||||||
return db_sql_exec_fn(pe,E_LOG,"update playlists set title='%q' "
|
} else {
|
||||||
"where id=%d",name,id);
|
result=db_sql_exec_fn(pe,E_LOG,"update playlists set title='%q' "
|
||||||
|
"where id=%d",name,id);
|
||||||
|
}
|
||||||
|
db_sql_update_playlists(NULL);
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
if((playlist_type == PL_SMART) && (clause))
|
if((playlist_type == PL_SMART) && (clause)) {
|
||||||
return db_sql_exec_fn(pe,E_LOG,"update playlists set query='%q' "
|
result= db_sql_exec_fn(pe,E_LOG,"update playlists set query='%q' "
|
||||||
"where id=%d",clause,id);
|
"where id=%d",clause,id);
|
||||||
|
db_sql_update_playlists(NULL);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
return DB_E_SUCCESS; /* ?? */
|
return DB_E_SUCCESS; /* ?? */
|
||||||
}
|
}
|
||||||
@ -730,6 +737,7 @@ int db_sql_add_playlist(char **pe, char *name, int type, char *clause, char *pat
|
|||||||
db_sql_exec_fn(NULL,E_FATAL,"insert into plupdated values (%d)",*playlistid);
|
db_sql_exec_fn(NULL,E_FATAL,"insert into plupdated values (%d)",*playlistid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
db_sql_update_playlists(NULL);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -833,7 +841,7 @@ int db_sql_add(char **pe, MP3FILE *pmp3, int *id) {
|
|||||||
/* sqlite2 doesn't support 64 bit ints */
|
/* sqlite2 doesn't support 64 bit ints */
|
||||||
sprintf(sample_count,"%lld",pmp3->sample_count);
|
sprintf(sample_count,"%lld",pmp3->sample_count);
|
||||||
sprintf(file_size,"%lld",pmp3->file_size);
|
sprintf(file_size,"%lld",pmp3->file_size);
|
||||||
|
|
||||||
err=db_sql_exec_fn(pe,E_DBG,"INSERT INTO songs VALUES "
|
err=db_sql_exec_fn(pe,E_DBG,"INSERT INTO songs VALUES "
|
||||||
"(NULL," // id
|
"(NULL," // id
|
||||||
"'%q'," // path
|
"'%q'," // path
|
||||||
@ -950,7 +958,7 @@ int db_sql_update(char **pe, MP3FILE *pmp3, int *id) {
|
|||||||
char *path;
|
char *path;
|
||||||
char sample_count[40];
|
char sample_count[40];
|
||||||
char file_size[40];
|
char file_size[40];
|
||||||
|
|
||||||
if(!pmp3->time_modified)
|
if(!pmp3->time_modified)
|
||||||
pmp3->time_modified = (int)time(NULL);
|
pmp3->time_modified = (int)time(NULL);
|
||||||
|
|
||||||
@ -958,7 +966,7 @@ int db_sql_update(char **pe, MP3FILE *pmp3, int *id) {
|
|||||||
|
|
||||||
sprintf(sample_count,"%lld",pmp3->sample_count);
|
sprintf(sample_count,"%lld",pmp3->sample_count);
|
||||||
sprintf(file_size,"%lld",pmp3->file_size);
|
sprintf(file_size,"%lld",pmp3->file_size);
|
||||||
|
|
||||||
strcpy(query,"UPDATE songs SET "
|
strcpy(query,"UPDATE songs SET "
|
||||||
"title='%q'," // title
|
"title='%q'," // title
|
||||||
"artist='%q'," // artist
|
"artist='%q'," // artist
|
||||||
|
Loading…
Reference in New Issue
Block a user