diff --git a/forked-daapd.conf b/forked-daapd.conf index 7be42a22..2bfe8b6a 100644 --- a/forked-daapd.conf +++ b/forked-daapd.conf @@ -33,6 +33,12 @@ library { # /srv/music/Podcasts, you can set this to "/Podcasts". podcasts = { "/Podcasts" } + # Directories containing audiobooks + # For each directory that is indexed the path is matched against these + # names. If there is a match all items in the directory are marked as + # audiobooks. + audiobooks = { "/Audiobooks" } + # Directories containing compilations (eg soundtracks) # For each directory that is indexed the path is matched against these # names. If there is a match all items in the directory are marked as @@ -46,11 +52,12 @@ library { # There are 5 default playlists: "Library", "Music", "Movies", "TV Shows" # and "Podcasts". Here you can change the names of these playlists. -# name_library = "Library" -# name_music = "Music" -# name_movies = "Movies" -# name_tvshows = "TV Shows" -# name_podcasts = "Podcasts" +# name_library = "Library" +# name_music = "Music" +# name_movies = "Movies" +# name_tvshows = "TV Shows" +# name_podcasts = "Podcasts" +# name_audiobooks = "Audiobooks" # Artwork file names (without file type extension) # forked-daapd will look for jpg and png files with these base names diff --git a/src/conffile.c b/src/conffile.c index ebff3f6e..e4c33083 100644 --- a/src/conffile.c +++ b/src/conffile.c @@ -61,6 +61,7 @@ static cfg_opt_t sec_library[] = CFG_STR("password", NULL, CFGF_NONE), CFG_STR_LIST("directories", NULL, CFGF_NONE), CFG_STR_LIST("podcasts", NULL, CFGF_NONE), + CFG_STR_LIST("audiobooks", NULL, CFGF_NONE), CFG_STR_LIST("compilations", NULL, CFGF_NONE), CFG_STR("compilation_artist", NULL, CFGF_NONE), CFG_STR("name_library", "Library", CFGF_NONE), @@ -68,6 +69,7 @@ static cfg_opt_t sec_library[] = CFG_STR("name_movies", "Movies", CFGF_NONE), CFG_STR("name_tvshows", "TV Shows", CFGF_NONE), CFG_STR("name_podcasts", "Podcasts", CFGF_NONE), + CFG_STR("name_audiobooks", "Audiobooks", CFGF_NONE), CFG_STR_LIST("artwork_basenames", "{artwork,cover,Folder}", CFGF_NONE), CFG_STR_LIST("filetypes_ignore", "{.db,.ini}", CFGF_NONE), CFG_BOOL("itunes_overrides", cfg_false, CFGF_NONE), diff --git a/src/db.c b/src/db.c index 7e17549a..cf3ca0fd 100644 --- a/src/db.c +++ b/src/db.c @@ -593,8 +593,8 @@ static void db_set_cfg_names(void) { #define Q_TMPL "UPDATE playlists SET title = '%q' WHERE type = 1 AND special_id = %d;" - char *cfg_item[5] = { "name_library", "name_music", "name_movies", "name_tvshows", "name_podcasts" }; - char special_id[5] = { 0, 6, 4, 5, 1 }; + char *cfg_item[6] = { "name_library", "name_music", "name_movies", "name_tvshows", "name_podcasts", "name_audiobooks" }; + char special_id[6] = { 0, 6, 4, 5, 1, 7 }; cfg_t *lib; char *query; char *title; @@ -4285,10 +4285,13 @@ db_perthread_deinit(void) "INSERT INTO playlists (id, title, type, query, db_timestamp, path, idx, special_id)" \ " VALUES(5, 'Podcasts', 1, 'f.media_kind = 4', 0, '', 0, 1);" +#define Q_PL6 \ + "INSERT INTO playlists (id, title, type, query, db_timestamp, path, idx, special_id)" \ + " VALUES(6, 'Audiobooks', 1, 'f.media_kind = 8', 0, '', 0, 7);" + /* These are the remaining automatically-created iTunes playlists, but * their query is unknown " VALUES(6, 'iTunes U', 0, 'media_kind = 256', 0, '', 0, 13);" - " VALUES(7, 'Audiobooks', 0, 'media_kind = 512', 0, '', 0, 7);" " VALUES(8, 'Purchased', 0, 'media_kind = 1024', 0, '', 0, 8);" */ @@ -4340,6 +4343,7 @@ static const struct db_init_query db_init_queries[] = { Q_PL3, "create default smart playlist 'Movies'" }, { Q_PL4, "create default smart playlist 'TV Shows'" }, { Q_PL5, "create default smart playlist 'Podcasts'" }, + { Q_PL6, "create default smart playlist 'Audiobooks'" }, { Q_SCVER, "set schema version" }, }; diff --git a/src/filescanner.c b/src/filescanner.c index 070670b9..5093649e 100644 --- a/src/filescanner.c +++ b/src/filescanner.c @@ -472,6 +472,8 @@ process_media_file(char *file, time_t mtime, off_t size, int type, struct extinf mfi.compilation = 1; if (type & F_SCAN_TYPE_PODCAST) mfi.media_kind = 4; /* podcast */ + if (type & F_SCAN_TYPE_AUDIOBOOK) + mfi.media_kind = 8; /* audiobook */ if (!mfi.item_kind) mfi.item_kind = 2; /* music */ @@ -612,38 +614,17 @@ process_file(char *file, time_t mtime, off_t size, int type, int flags) /* Thread: scan */ static int -check_podcast(char *path) +check_speciallib(char *path, const char *libtype) { cfg_t *lib; int ndirs; int i; lib = cfg_getsec(cfg, "library"); - ndirs = cfg_size(lib, "podcasts"); - + ndirs = cfg_size(lib, libtype); for (i = 0; i < ndirs; i++) { - if (strstr(path, cfg_getnstr(lib, "podcasts", i))) - return 1; - } - - return 0; -} - -/* Thread: scan */ -static int -check_compilation(char *path) -{ - cfg_t *lib; - int ndirs; - int i; - - lib = cfg_getsec(cfg, "library"); - ndirs = cfg_size(lib, "compilations"); - - for (i = 0; i < ndirs; i++) - { - if (strstr(path, cfg_getnstr(lib, "compilations", i))) + if (strstr(path, cfg_getnstr(lib, libtype, i))) return 1; } @@ -698,10 +679,12 @@ process_directory(char *path, int flags) /* Check if compilation and/or podcast directory */ type = 0; - if (check_compilation(path)) + if (check_speciallib(path, "compilations")) type |= F_SCAN_TYPE_COMPILATION; - if (check_podcast(path)) + if (check_speciallib(path, "podcasts")) type |= F_SCAN_TYPE_PODCAST; + if (check_speciallib(path, "audiobooks")) + type |= F_SCAN_TYPE_AUDIOBOOK; for (;;) { @@ -1159,10 +1142,12 @@ process_inotify_file(struct watch_info *wi, char *path, struct inotify_event *ie } type = 0; - if (check_compilation(path)) + if (check_speciallib(path, "compilations")) type |= F_SCAN_TYPE_COMPILATION; - if (check_podcast(path)) + if (check_speciallib(path, "podcasts")) type |= F_SCAN_TYPE_PODCAST; + if (check_speciallib(path, "audiobooks")) + type |= F_SCAN_TYPE_AUDIOBOOK; process_file(file, sb.st_mtime, sb.st_size, type, 0); diff --git a/src/filescanner.h b/src/filescanner.h index 8f2bf753..60a35f3e 100644 --- a/src/filescanner.h +++ b/src/filescanner.h @@ -5,8 +5,9 @@ #include "db.h" #define F_SCAN_TYPE_PODCAST (1 << 0) -#define F_SCAN_TYPE_COMPILATION (1 << 1) -#define F_SCAN_TYPE_URL (1 << 2) +#define F_SCAN_TYPE_AUDIOBOOK (1 << 1) +#define F_SCAN_TYPE_COMPILATION (1 << 2) +#define F_SCAN_TYPE_URL (1 << 3) int filescanner_init(void);