]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
dvr: Make tvshows/tvmovies subdirectory configurable. (#4667).
authorE.Smith <31170571+azlm8t@users.noreply.github.com>
Wed, 18 Oct 2017 02:09:32 +0000 (03:09 +0100)
committerJaroslav Kysela <perex@perex.cz>
Wed, 18 Oct 2017 17:16:04 +0000 (19:16 +0200)
Issue: #4667.

src/dvr/dvr.h
src/dvr/dvr_config.c
src/dvr/dvr_rec.c

index 24a171db44fcb7c6df5887b7a99e5b1cee6125e7..e5f4a6c4a8773e457ad3815bccd0e7bbb22cf2a5 100644 (file)
@@ -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;
index f673c086a7186e2103eb482398bd0846e8af3343..3e0b4550adfc15ddfbeac9642a94fbdb698c8d21 100644 (file)
@@ -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,
+    },
     {}
   },
 };
index 914942e14f5dcf2d7a5ea132ef36c4dfd70e6a55..864a33ef4638daf866853473d0757d53efc734e2 100644 (file)
@@ -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);