From: E.Smith <31170571+azlm8t@users.noreply.github.com> Date: Wed, 18 Oct 2017 02:09:32 +0000 (+0100) Subject: dvr: Make tvshows/tvmovies subdirectory configurable. (#4667). X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=e9ffb2cc87484da2e0607129f35454da263ce301;p=thirdparty%2Ftvheadend.git dvr: Make tvshows/tvmovies subdirectory configurable. (#4667). Issue: #4667. --- diff --git a/src/dvr/dvr.h b/src/dvr/dvr.h index 24a171db4..e5f4a6c4a 100644 --- a/src/dvr/dvr.h +++ b/src/dvr/dvr.h @@ -96,6 +96,8 @@ typedef struct dvr_config { int dvr_skip_commercials; int dvr_subtitle_in_title; int dvr_windows_compatible_filenames; + char *dvr_format_tvmovies_subdir; + char *dvr_format_tvshows_subdir; struct dvr_entry_list dvr_entries; struct dvr_autorec_entry_list dvr_autorec_entries; diff --git a/src/dvr/dvr_config.c b/src/dvr/dvr_config.c index f673c086a..3e0b4550a 100644 --- a/src/dvr/dvr_config.c +++ b/src/dvr/dvr_config.c @@ -264,6 +264,8 @@ dvr_config_destroy(dvr_config_t *cfg, int delconf) free(cfg->dvr_preproc); free(cfg->dvr_postproc); free(cfg->dvr_postremove); + free(cfg->dvr_format_tvmovies_subdir); + free(cfg->dvr_format_tvshows_subdir); free(cfg); } @@ -1302,6 +1304,34 @@ const idclass_t dvr_config_class = { .opts = PO_ADVANCED, .group = 6, }, + { + .type = PT_STR, + .id = "format-tvmovies-subdir", + .name = N_("Subdirectory for tvmovies for $q format specifier"), + .desc = N_("Subdirectory to use for tvmovies when using the $q specifier. " + "Default value is \"tvmovies\". " + "This can contain any alphanumeric " + "characters (A-Za-z0-9). Other characters may be supported depending " + "on your OS and filesystem." + ), + .off = offsetof(dvr_config_t, dvr_format_tvmovies_subdir), + .opts = PO_ADVANCED, + .group = 6, + }, + { + .type = PT_STR, + .id = "format-tvshows-subdir", + .name = N_("Subdirectory for tvshows for $q format specifier"), + .desc = N_("Subdirectory to use for tvshows when using the $q specifier. " + "Default value is \"tvshows\". " + "This can contain any alphanumeric " + "characters (A-Za-z0-9). Other characters may be supported depending " + "on your OS and filesystem." + ), + .off = offsetof(dvr_config_t, dvr_format_tvshows_subdir), + .opts = PO_ADVANCED, + .group = 6, + }, {} }, }; diff --git a/src/dvr/dvr_rec.c b/src/dvr/dvr_rec.c index 914942e14..864a33ef4 100644 --- a/src/dvr/dvr_rec.c +++ b/src/dvr/dvr_rec.c @@ -472,6 +472,7 @@ _dvr_sub_scraper_friendly(const char *id, const char *fmt, const void *aux, char */ size_t offset = 0; + const dvr_config_t *config = de->de_config; if (is_movie) { /* TV movies are probably best saved in one folder rather than @@ -485,7 +486,12 @@ _dvr_sub_scraper_friendly(const char *id, const char *fmt, const void *aux, char * "title (yyyy)" (without genre_subdir) * "title" (without genre_subdir, no airdate) */ - if (with_genre_subdir) tvh_strlcatf(tmp, tmplen, offset, "tvmovies/"); + if (with_genre_subdir) { + const char *subdir = config && config->dvr_format_tvmovies_subdir && *config->dvr_format_tvmovies_subdir ? + config->dvr_format_tvmovies_subdir : "tvmovies"; + tvh_strlcatf(tmp, tmplen, offset, "%s/", subdir); + } + if (*title_buf) tvh_strlcatf(tmp, tmplen, offset, "%s", title_buf); /* Movies don't have anything relevant in sub-titles field so * anything there should be ignored. I think some channels store a @@ -507,7 +513,11 @@ _dvr_sub_scraper_friendly(const char *id, const char *fmt, const void *aux, char * "title - subtitle_2001-05-04" (without genre_subdir, long running show) * "title - subtitle" (without genre_subdir, no epg info on show) */ - if (with_genre_subdir) tvh_strlcatf(tmp, tmplen, offset, "tvshows/"); + if (with_genre_subdir) { + const char *subdir = config && config->dvr_format_tvshows_subdir && *config->dvr_format_tvshows_subdir ? + config->dvr_format_tvshows_subdir : "tvshows"; + tvh_strlcatf(tmp, tmplen, offset, "%s/", subdir); + } if (*title_buf) tvh_strlcatf(tmp, tmplen, offset, "%s/%s", title_buf, title_buf); if (*episode_buf) tvh_strlcatf(tmp, tmplen, offset, " - %s", episode_buf); if (*subtitle_buf) tvh_strlcatf(tmp, tmplen, offset, " - %s", subtitle_buf);