]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
DVR: Add delimiters format strings (<space>-_.,;) to $t,$s,$e,$c, fixes #2885
authorJaroslav Kysela <perex@perex.cz>
Mon, 25 May 2015 07:35:34 +0000 (09:35 +0200)
committerJaroslav Kysela <perex@perex.cz>
Mon, 25 May 2015 07:40:13 +0000 (09:40 +0200)
docs/html/config_dvr.html
src/dvr/dvr_config.c
src/dvr/dvr_rec.c

index ff130d40fb3f2050be86cfde44eb7e3ecc08866a..75188ea64faddc1d05012c0774bc39c9caea3bc2 100644 (file)
       <tr><td>$t$n.$x</td><td>Default format (title, unique number, extension)</td><td>Tenis - Wimbledon-1.mkv</td></tr>
       <br>
       <tr><td>$t</td><td>Event title name</td><td>Tenis - Wimbledon</td></tr>
+      <tr><td>$s</td><td>Event subtitle name</td><td>Sport</td></tr>
       <tr><td>$e</td><td>Event episode name</td><td>S02-E06</td></tr>
+      <tr><td>$c</td><td>Channel name</td><td>SkySport</td></tr>
       <tr><td>$n</td><td>Unique number added when the file already exists&nbsp;&nbsp;&nbsp;&nbsp;</td><td>-1</td></tr>
       <tr><td>$x</td><td>Filename extension (from the active stream muxer</td><td>mkv</td></tr>
       <br>
       <tr><td>%R</td><td>The time in 24-hour notation</td><td>14:12</td></tr>
       </table>
 
+  The format strings <i>$t,$s,%e,$c</i> have also delimiter variants like
+  <i>$ t</i> (space after the dolar character), <i>$-t</i>, <i>$_t</i>,
+  <i>$.t</i>, <i>$,t</i>, <i>$;t</i>, . In this case, the delimiter is applied
+  only when the substituted string is not empty.
+
   <br><br>
   <hr>
   <b>Subdirectory Options</b>
index 565182519bacb579b93d205883331679627d1bdc..007204f4fe719edbbfb98ab16c5cb2e6686d2a62 100644 (file)
@@ -431,11 +431,11 @@ dvr_update_pathname_from_fmtstr(dvr_config_t *cfg)
   cfg->dvr_channel_dir = dvr_match_fmtstr(cfg, "$c/") >= 0;
   cfg->dvr_title_dir   = dvr_match_fmtstr(cfg, "$t/") >= 0;
 
-  cfg->dvr_channel_in_title  = dvr_match_fmtstr_nodir(cfg, "$c-") >= 0;
+  cfg->dvr_channel_in_title  = dvr_match_fmtstr_nodir(cfg, "$-c") >= 0;
   cfg->dvr_date_in_title     = dvr_match_fmtstr_nodir(cfg, "%F") >= 0;
   cfg->dvr_time_in_title     = dvr_match_fmtstr_nodir(cfg, "%R") >= 0;
-  cfg->dvr_episode_in_title  = dvr_match_fmtstr_nodir(cfg, "$e") >= 0;
-  cfg->dvr_subtitle_in_title = dvr_match_fmtstr_nodir(cfg, ".$s") >= 0;
+  cfg->dvr_episode_in_title  = dvr_match_fmtstr_nodir(cfg, "$-e") >= 0;
+  cfg->dvr_subtitle_in_title = dvr_match_fmtstr_nodir(cfg, "$.s") >= 0;
 
   cfg->dvr_omit_title = dvr_match_fmtstr_nodir(cfg, "$t") < 0;
 }
@@ -460,11 +460,11 @@ dvr_update_pathname_from_booleans(dvr_config_t *cfg)
       dvr_insert_fmtstr_before_extension(cfg, "$t");
   }
 
-  dvr_match_and_insert_or_remove(cfg, "$c-", cfg->dvr_channel_in_title, -1);
-  dvr_match_and_insert_or_remove(cfg, ".$s", cfg->dvr_subtitle_in_title, -1);
+  dvr_match_and_insert_or_remove(cfg, "$-c", cfg->dvr_channel_in_title, -1);
+  dvr_match_and_insert_or_remove(cfg, "$.s", cfg->dvr_subtitle_in_title, -1);
   dvr_match_and_insert_or_remove(cfg, "%F",  cfg->dvr_date_in_title, -1);
   dvr_match_and_insert_or_remove(cfg, "%R",  cfg->dvr_time_in_title, -1);
-  dvr_match_and_insert_or_remove(cfg, "$e",  cfg->dvr_episode_in_title, -1);
+  dvr_match_and_insert_or_remove(cfg, "$-e",  cfg->dvr_episode_in_title, -1);
 
   dvr_match_and_insert_or_remove(cfg, "$t/", cfg->dvr_title_dir, 0);
   dvr_match_and_insert_or_remove(cfg, "$c/", cfg->dvr_channel_dir, 0);
index c72e638107857a8ae950a6e05f957579720c45dc..900903a807ba0d6a32b52d8cb22529ede5b2c860 100644 (file)
@@ -20,6 +20,7 @@
 #include <pthread.h>
 #include <assert.h>
 #include <string.h>
+#include <ctype.h>
 #include <sys/stat.h>
 #include <libgen.h> /* basename */
 
@@ -89,7 +90,7 @@ dvr_rec_subscribe(dvr_entry_t *de)
     tvherror("dvr", "unable to find access (owner '%s', creator '%s')",
              de->de_owner, de->de_creator);
     return -1;
 }
+ }
 
   if (aa->aa_conn_limit) {
     rec_count = dvr_usage_count(aa);
@@ -220,15 +221,28 @@ cleanup_filename(dvr_config_t *cfg, char *s)
 /**
  *
  */
+static const char *dvr_do_prefix(const char *id, const char *s)
+{
+  static char buf[128];
+
+  if (s == NULL)
+    s = "";
+  if (s[0] && !isalpha(id[0])) {
+    snprintf(buf, sizeof(buf), "%c%s", id[0], s);
+    return buf;
+  }
+  return s;
+}
+
 
 static const char *dvr_sub_title(const char *id, const void *aux)
 {
-  return lang_str_get(((dvr_entry_t *)aux)->de_title, NULL) ?: "";
+  return dvr_do_prefix(id, lang_str_get(((dvr_entry_t *)aux)->de_title, NULL));
 }
 
 static const char *dvr_sub_subtitle(const char *id, const void *aux)
 {
-  return lang_str_get(((dvr_entry_t *)aux)->de_subtitle, NULL) ?: "";
+  return dvr_do_prefix(id, lang_str_get(((dvr_entry_t *)aux)->de_subtitle, NULL));
 }
 
 static const char *dvr_sub_episode(const char *id, const void *aux)
@@ -241,20 +255,43 @@ static const char *dvr_sub_episode(const char *id, const void *aux)
   epg_episode_number_format(de->de_bcast->episode,
                             buf, sizeof(buf),
                             ".", "S%02d", NULL, "E%02d", NULL);
-  return buf;
+  return dvr_do_prefix(id, buf);
 }
 
 static const char *dvr_sub_channel(const char *id, const void *aux)
 {
-  return DVR_CH_NAME((dvr_entry_t *)aux);
+  return dvr_do_prefix(id, DVR_CH_NAME((dvr_entry_t *)aux));
 }
 
-
 static str_substitute_t dvr_subs_entry[] = {
-  { .id = "t", .getval = dvr_sub_title },
-  { .id = "s", .getval = dvr_sub_subtitle },
-  { .id = "e", .getval = dvr_sub_episode },
-  { .id = "c", .getval = dvr_sub_channel },
+  { .id = "t",  .getval = dvr_sub_title },
+  { .id = " t", .getval = dvr_sub_title },
+  { .id = "-t", .getval = dvr_sub_title },
+  { .id = "_t", .getval = dvr_sub_title },
+  { .id = ".t", .getval = dvr_sub_title },
+  { .id = ",t", .getval = dvr_sub_title },
+  { .id = ";t", .getval = dvr_sub_title },
+  { .id = "s",  .getval = dvr_sub_subtitle },
+  { .id = " s", .getval = dvr_sub_subtitle },
+  { .id = "-s", .getval = dvr_sub_subtitle },
+  { .id = "_s", .getval = dvr_sub_subtitle },
+  { .id = ".s", .getval = dvr_sub_subtitle },
+  { .id = ",s", .getval = dvr_sub_subtitle },
+  { .id = ";s", .getval = dvr_sub_subtitle },
+  { .id = "e",  .getval = dvr_sub_episode },
+  { .id = " e", .getval = dvr_sub_episode },
+  { .id = "-e", .getval = dvr_sub_episode },
+  { .id = "_e", .getval = dvr_sub_episode },
+  { .id = ".e", .getval = dvr_sub_episode },
+  { .id = ",e", .getval = dvr_sub_episode },
+  { .id = ";e", .getval = dvr_sub_episode },
+  { .id = "c",  .getval = dvr_sub_channel },
+  { .id = " c", .getval = dvr_sub_channel },
+  { .id = "-c", .getval = dvr_sub_channel },
+  { .id = "_c", .getval = dvr_sub_channel },
+  { .id = ".c", .getval = dvr_sub_channel },
+  { .id = ",c", .getval = dvr_sub_channel },
+  { .id = ";c", .getval = dvr_sub_channel },
   { .id = NULL, .getval = NULL }
 };