mirror of
https://github.com/owntone/owntone-server.git
synced 2024-12-26 15:15:57 -05:00
add m3ufile struct, functions for retrieving it
This commit is contained in:
parent
a3c30304b7
commit
afd41008dc
@ -1194,7 +1194,19 @@ char *db_sqlite_strdup(const char *what) {
|
||||
return what ? (strlen(what) ? strdup(what) : NULL) : NULL;
|
||||
}
|
||||
|
||||
void db_sqlite_build_m3ufile(char **valarray, M3UFILE *pm3u) {
|
||||
memset(pm3u,0x00,sizeof(M3UFILE));
|
||||
|
||||
pm3u->id=db_sqlite_atoi(valarray[0]);
|
||||
pm3u->title=db_sqlite_strdup(valarray[1]);
|
||||
pm3u->type=db_sqlite_atoi(valarray[2]);
|
||||
pm3u->items=db_sqlite_atoi(valarray[3]);
|
||||
pm3u->query=db_sqlite_strdup(valarray[4]);
|
||||
pm3u->db_timestamp=db_sqlite_atoi(valarray[5]);
|
||||
pm3u->path=db_sqlite_strdup(valarray[6]);
|
||||
pm3u->index=db_sqlite_atoi(valarray[7]);
|
||||
return;
|
||||
}
|
||||
void db_sqlite_build_mp3file(char **valarray, MP3FILE *pmp3) {
|
||||
memset(pmp3,0x00,sizeof(MP3FILE));
|
||||
pmp3->id=db_sqlite_atoi(valarray[0]);
|
||||
@ -1237,6 +1249,40 @@ void db_sqlite_build_mp3file(char **valarray, MP3FILE *pmp3) {
|
||||
pmp3->codectype=db_sqlite_strdup(valarray[37]);
|
||||
}
|
||||
|
||||
/**
|
||||
* fetch a playlist by path
|
||||
*
|
||||
* \param path path to fetch
|
||||
*/
|
||||
M3UFILE *db_sqlite_fetch_playlist(char *path) {
|
||||
int rows,cols;
|
||||
char **resarray;
|
||||
int result;
|
||||
M3UFILE *pm3u;
|
||||
|
||||
result = db_sqlite_get_table(E_DBG,&resarray,&rows,&cols,
|
||||
"select * from playlists where path='%q'",path);
|
||||
|
||||
if(result != DB_E_SUCCESS)
|
||||
return NULL;
|
||||
|
||||
if(rows != 0) {
|
||||
pm3u=(M3UFILE*)malloc(sizeof(M3UFILE));
|
||||
if(!pm3u)
|
||||
DPRINTF(E_FATAL,L_MISC,"malloc error in db_sqlite_fetch_playlist\n");
|
||||
|
||||
db_sqlite_build_m3ufile((char**)&resarray[cols],pm3u);
|
||||
}
|
||||
|
||||
db_sqlite_free_table(resarray);
|
||||
|
||||
if((rows) && (db_sqlite_in_scan) && (!db_sqlite_reload)) {
|
||||
// db_sqlite_exec(E_FATAL,"insert into updatedplaylists values (%d)",pm3u->id);
|
||||
}
|
||||
|
||||
return pm3u;
|
||||
}
|
||||
|
||||
/**
|
||||
* fetch a MP3FILE for a specific id
|
||||
*
|
||||
|
@ -36,7 +36,9 @@ extern int db_sqlite_end_scan(void);
|
||||
extern int db_sqlite_get_count(CountType_t type);
|
||||
extern MP3FILE *db_sqlite_fetch_item(int id);
|
||||
extern MP3FILE *db_sqlite_fetch_path(char *path);
|
||||
extern M3UFILE *db_sqlite_fetch_playlist(char *path);
|
||||
extern void db_sqlite_dispose_item(MP3FILE *pmp3);
|
||||
extern void db_sqlite_dispose_playlist(M3UFILE *pm3u);
|
||||
extern int db_sqlite_add_playlist(char *name, int type, char *clause, char *path, int *playlistid);
|
||||
extern int db_sqlite_add_playlist_item(int playlistid, int songid);
|
||||
|
||||
|
@ -72,6 +72,17 @@ typedef struct tag_mp3file {
|
||||
char compilation;
|
||||
} MP3FILE;
|
||||
|
||||
typedef struct tag_m3ufile {
|
||||
int id; /**< integer id (miid) */
|
||||
char *title; /**< playlist name as displayed in iTunes (minm) */
|
||||
int type; /**< 0=static webmanaged, 1=smart, 2=static m3u (aeSP/MPTY) */
|
||||
int items; /**< number of items (mimc) */
|
||||
char *query; /**< where clause if type 1 (MSPS) */
|
||||
int db_timestamp; /**< time last updated */
|
||||
char *path; /**< path of underlying playlist (if type 2) */
|
||||
int index; /**< index of playlist for paths with multiple playlists */
|
||||
} M3UFILE;
|
||||
|
||||
extern int scan_init(char *path);
|
||||
extern void make_composite_tags(MP3FILE *song);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user