mirror of
https://github.com/owntone/owntone-server.git
synced 2024-12-25 22:55:56 -05:00
Add support for compilation directories
This commit is contained in:
parent
681a0f4288
commit
e496d18424
@ -136,6 +136,7 @@ CONFIGELEMENT config_elements[] = {
|
|||||||
{ 1,0,0,CONFIG_TYPE_STRING,"ssc_extensions",(void*)&config.ssc_extensions,config_emit_string },
|
{ 1,0,0,CONFIG_TYPE_STRING,"ssc_extensions",(void*)&config.ssc_extensions,config_emit_string },
|
||||||
{ 1,0,0,CONFIG_TYPE_STRING,"ssc_prog",(void*)&config.ssc_prog,config_emit_string },
|
{ 1,0,0,CONFIG_TYPE_STRING,"ssc_prog",(void*)&config.ssc_prog,config_emit_string },
|
||||||
{ 1,0,0,CONFIG_TYPE_STRING,"password",(void*)&config.readpassword, config_emit_string },
|
{ 1,0,0,CONFIG_TYPE_STRING,"password",(void*)&config.readpassword, config_emit_string },
|
||||||
|
{ 1,0,0,CONFIG_TYPE_STRING,"compdirs",(void*)&config.compdirs, config_emit_string },
|
||||||
{ 1,0,0,CONFIG_TYPE_STRING,"logfile",(void*)&config.logfile, config_emit_string },
|
{ 1,0,0,CONFIG_TYPE_STRING,"logfile",(void*)&config.logfile, config_emit_string },
|
||||||
{ 0,0,0,CONFIG_TYPE_SPECIAL,"host",(void*)NULL,config_emit_host },
|
{ 0,0,0,CONFIG_TYPE_SPECIAL,"host",(void*)NULL,config_emit_host },
|
||||||
{ 0,0,0,CONFIG_TYPE_SPECIAL,"release",(void*)VERSION,config_emit_literal },
|
{ 0,0,0,CONFIG_TYPE_SPECIAL,"release",(void*)VERSION,config_emit_literal },
|
||||||
@ -270,6 +271,9 @@ int config_read(char *file) {
|
|||||||
CONFIGELEMENT *pce;
|
CONFIGELEMENT *pce;
|
||||||
int handled;
|
int handled;
|
||||||
char *term;
|
char *term;
|
||||||
|
int compterms=0,currentterm;
|
||||||
|
char *term_begin, *term_end;
|
||||||
|
char *compdirs;
|
||||||
|
|
||||||
buffer=(char*)malloc(MAX_LINE+1);
|
buffer=(char*)malloc(MAX_LINE+1);
|
||||||
if(!buffer)
|
if(!buffer)
|
||||||
@ -309,6 +313,8 @@ int config_read(char *file) {
|
|||||||
config.scan_type=0;
|
config.scan_type=0;
|
||||||
config.compress=0;
|
config.compress=0;
|
||||||
config.latin1_tags=0;
|
config.latin1_tags=0;
|
||||||
|
config.compdirs=NULL;
|
||||||
|
config.complist = NULL;
|
||||||
|
|
||||||
/* DWB: use alloced space so it can be freed without errors */
|
/* DWB: use alloced space so it can be freed without errors */
|
||||||
config.extensions=strdup(".mp3");
|
config.extensions=strdup(".mp3");
|
||||||
@ -459,6 +465,52 @@ int config_read(char *file) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* See how many compilation dirs we have */
|
||||||
|
compterms=0;
|
||||||
|
term_begin=config.compdirs;
|
||||||
|
while(term_begin) {
|
||||||
|
compterms++;
|
||||||
|
term_begin=strchr(term_begin,',');
|
||||||
|
if(term_begin)
|
||||||
|
term_begin++;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Now allocate comp dirs */
|
||||||
|
if(compterms) {
|
||||||
|
config.complist=(char**)malloc((compterms+1) * sizeof(char*));
|
||||||
|
if(!config.complist)
|
||||||
|
DPRINTF(E_FATAL,L_MISC,"Alloc error.\n");
|
||||||
|
|
||||||
|
currentterm=0;
|
||||||
|
|
||||||
|
term_begin=config.compdirs;
|
||||||
|
while(*term_begin && *term_begin ==' ')
|
||||||
|
term_begin++;
|
||||||
|
|
||||||
|
compdirs = strdup(term_begin);
|
||||||
|
term_begin = term_end = compdirs;
|
||||||
|
|
||||||
|
while(term_end) {
|
||||||
|
term_end = strchr(term_begin,',');
|
||||||
|
while((*term_begin)&&(*term_begin == ' '))
|
||||||
|
term_begin++;
|
||||||
|
|
||||||
|
if(term_end)
|
||||||
|
*term_end='\0';
|
||||||
|
|
||||||
|
while(strlen(term_begin) && term_begin[strlen(term_begin)-1]==' ')
|
||||||
|
term_begin[strlen(term_begin)-1] == '\0';
|
||||||
|
|
||||||
|
if(strlen(term_begin)) {
|
||||||
|
config.complist[currentterm++] = term_begin;
|
||||||
|
}
|
||||||
|
|
||||||
|
term_begin = term_end + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
config.complist[currentterm] = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -470,6 +522,12 @@ void config_close(void) {
|
|||||||
CONFIGELEMENT *pce;
|
CONFIGELEMENT *pce;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
|
if(config.complist) {
|
||||||
|
if(config.complist[0])
|
||||||
|
free(config.complist[0]);
|
||||||
|
free(config.complist);
|
||||||
|
}
|
||||||
|
|
||||||
free(config.configfile);
|
free(config.configfile);
|
||||||
pce=config_elements;
|
pce=config_elements;
|
||||||
err=0;
|
err=0;
|
||||||
@ -531,6 +589,9 @@ int config_write(WS_CONNINFO *pwsc) {
|
|||||||
fprintf(configfile,"process_m3u\t%s\n",ws_getvar(pwsc,"process_m3u"));
|
fprintf(configfile,"process_m3u\t%s\n",ws_getvar(pwsc,"process_m3u"));
|
||||||
fprintf(configfile,"compress\t%s\n",ws_getvar(pwsc,"compress"));
|
fprintf(configfile,"compress\t%s\n",ws_getvar(pwsc,"compress"));
|
||||||
|
|
||||||
|
fprintf(configfile,"debuglevel\t%s\n",ws_getvar(pwsc,"debuglevel"));
|
||||||
|
fprintf(configfile,"compdirs\t%s\n",ws_getvar(pwsc,"compdirs"));
|
||||||
|
|
||||||
fclose(configfile);
|
fclose(configfile);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -48,12 +48,12 @@ typedef struct tag_config {
|
|||||||
int stop; /**< Time to exit? */
|
int stop; /**< Time to exit? */
|
||||||
int reload; /**< Time to reload and/or rescan the database? */
|
int reload; /**< Time to reload and/or rescan the database? */
|
||||||
char *configfile; /**< path to config file */
|
char *configfile; /**< path to config file */
|
||||||
char *web_root; /**< path to the directory containing the admin-root files */
|
char *web_root; /**< path to the dir containing the web files */
|
||||||
int port; /**< port to listen on */
|
int port; /**< port to listen on */
|
||||||
int rescan_interval; /**< How often to do a background rescan of the file system */
|
int rescan_interval; /**< How often to do a background fs rescan */
|
||||||
int always_scan; /**< 0 to minimize disk usage (embedded devices) */
|
int always_scan; /**< 0 to minimize disk usage (embedded devices) */
|
||||||
int process_m3u; /**< Should we process m3u files? */
|
int process_m3u; /**< Should we process m3u files? */
|
||||||
int scan_type; /**< How hard to search mp3 files. see scan_get_mp3fileinfo() */
|
int scan_type; /**< Method for finding playtime. see scan-mp3.c */
|
||||||
int compress; /**< Should we compress? */
|
int compress; /**< Should we compress? */
|
||||||
int pid; /**< pid that will accept INT to terminate */
|
int pid; /**< pid that will accept INT to terminate */
|
||||||
int latin1_tags; /**< interpret all tags as latin1 rather than utf8 */
|
int latin1_tags; /**< interpret all tags as latin1 rather than utf8 */
|
||||||
@ -69,6 +69,8 @@ typedef struct tag_config {
|
|||||||
char *ssc_prog; /**< Server side music format converter prog */
|
char *ssc_prog; /**< Server side music format converter prog */
|
||||||
char *artfilename; /**< What filename to merge coverart with */
|
char *artfilename; /**< What filename to merge coverart with */
|
||||||
char *logfile; /**< What file to use as a logfile */
|
char *logfile; /**< What file to use as a logfile */
|
||||||
|
char *compdirs; /**< Compilations directories */
|
||||||
|
char **complist; /**< list of compilation directories */
|
||||||
STATS stats; /**< Stats structure (see above) */
|
STATS stats; /**< Stats structure (see above) */
|
||||||
} CONFIG;
|
} CONFIG;
|
||||||
|
|
||||||
|
@ -76,7 +76,7 @@ typedef struct {
|
|||||||
static int scan_path(char *path);
|
static int scan_path(char *path);
|
||||||
static int scan_get_info(char *file, MP3FILE *pmp3);
|
static int scan_get_info(char *file, MP3FILE *pmp3);
|
||||||
static int scan_freetags(MP3FILE *pmp3);
|
static int scan_freetags(MP3FILE *pmp3);
|
||||||
static void scan_music_file(char *path, struct dirent *pde, struct stat *psb);
|
static void scan_music_file(char *path, struct dirent *pde, struct stat *psb, int is_compdir);
|
||||||
static TAGHANDLER *scan_gethandler(char *type);
|
static TAGHANDLER *scan_gethandler(char *type);
|
||||||
|
|
||||||
|
|
||||||
@ -237,6 +237,28 @@ int scan_init(char *path) {
|
|||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* check to see if a particular path is a complation path
|
||||||
|
*
|
||||||
|
* @param path path to check
|
||||||
|
* @returns 1 if it is a compilation path, 0 otherwise
|
||||||
|
*/
|
||||||
|
int scan_is_compdir(char *path) {
|
||||||
|
int current=0;
|
||||||
|
|
||||||
|
if(!config.complist)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
while(config.complist[current]) {
|
||||||
|
if(strcasestr(path,config.complist[current]))
|
||||||
|
return 1;
|
||||||
|
current++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* scan_path
|
* scan_path
|
||||||
*
|
*
|
||||||
@ -253,12 +275,15 @@ int scan_path(char *path) {
|
|||||||
int modified_time;
|
int modified_time;
|
||||||
char *ext;
|
char *ext;
|
||||||
MP3FILE *pmp3;
|
MP3FILE *pmp3;
|
||||||
|
int is_compdir;
|
||||||
|
|
||||||
if((current_dir=opendir(path)) == NULL) {
|
if((current_dir=opendir(path)) == NULL) {
|
||||||
DPRINTF(E_WARN,L_SCAN,"opendir: %s\n",strerror(errno));
|
DPRINTF(E_WARN,L_SCAN,"opendir: %s\n",strerror(errno));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
is_compdir=scan_is_compdir(path);
|
||||||
|
|
||||||
while(1) {
|
while(1) {
|
||||||
if(config.stop) {
|
if(config.stop) {
|
||||||
DPRINTF(E_WARN,L_SCAN,"Stop req. Aborting scan of %s.\n",path);
|
DPRINTF(E_WARN,L_SCAN,"Stop req. Aborting scan of %s.\n",path);
|
||||||
@ -310,7 +335,7 @@ int scan_path(char *path) {
|
|||||||
|
|
||||||
if((!pmp3) || (pmp3->db_timestamp < modified_time) ||
|
if((!pmp3) || (pmp3->db_timestamp < modified_time) ||
|
||||||
(pmp3->force_update)) {
|
(pmp3->force_update)) {
|
||||||
scan_music_file(path,pde,&sb);
|
scan_music_file(path,pde,&sb,is_compdir);
|
||||||
} else {
|
} else {
|
||||||
DPRINTF(E_DBG,L_SCAN,"Skipping file... not modified\n");
|
DPRINTF(E_DBG,L_SCAN,"Skipping file... not modified\n");
|
||||||
}
|
}
|
||||||
@ -431,7 +456,8 @@ int scan_static_playlist(char *path) {
|
|||||||
*
|
*
|
||||||
* scan a particular file as a music file
|
* scan a particular file as a music file
|
||||||
*/
|
*/
|
||||||
void scan_music_file(char *path, struct dirent *pde, struct stat *psb) {
|
void scan_music_file(char *path, struct dirent *pde,
|
||||||
|
struct stat *psb, int is_compdir) {
|
||||||
MP3FILE mp3file;
|
MP3FILE mp3file;
|
||||||
char mp3_path[PATH_MAX];
|
char mp3_path[PATH_MAX];
|
||||||
char *current=NULL;
|
char *current=NULL;
|
||||||
@ -496,6 +522,9 @@ void scan_music_file(char *path, struct dirent *pde, struct stat *psb) {
|
|||||||
|
|
||||||
DPRINTF(E_DBG,L_SCAN," Codec: %s\n",mp3file.codectype);
|
DPRINTF(E_DBG,L_SCAN," Codec: %s\n",mp3file.codectype);
|
||||||
|
|
||||||
|
if(is_compdir)
|
||||||
|
mp3file.compilation = 1;
|
||||||
|
|
||||||
db_add(&mp3file);
|
db_add(&mp3file);
|
||||||
} else {
|
} else {
|
||||||
DPRINTF(E_WARN,L_SCAN,"Skipping %s - scan failed\n",mp3file.path);
|
DPRINTF(E_WARN,L_SCAN,"Skipping %s - scan failed\n",mp3file.path);
|
||||||
|
Loading…
Reference in New Issue
Block a user