]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
DVR: Prefer autorec rule name if comment field is empty (#4500)
authorE.Smith <31170571+azlm8t@users.noreply.github.com>
Sun, 3 Sep 2017 11:35:05 +0000 (12:35 +0100)
committerJaroslav Kysela <perex@perex.cz>
Mon, 18 Sep 2017 13:13:34 +0000 (15:13 +0200)
Currently the Upcoming recordings tab has a comment field that says
"Auto recording" or "Auto recording: <comment from autorec rule>".
This helps to identify why a recording is scheduled.

This patch ensures we continue to use the autorec comment field if
it is non-empty (keeping existing behaviour), but fallback to using
the recording rule name. If both are empty then we keep the
existing behaviour of fallback to an empty string.

This avoids the user having to duplicate the rule name in to
the comment string for manually created autorec rules.

So, in the above case it would be "Auto recording: <comment>",
"Auto recording: <rule name>", otherwise "Auto recording".

Fixes: #4500.
src/dvr/dvr_db.c

index de226db21d0f07104b1743eadd1ce77b9befb4c6..c2d8567502d5ebd76874f13cd0c8d141ffacd243 100644 (file)
@@ -1516,6 +1516,7 @@ dvr_entry_create_by_autorec(int enabled, epg_broadcast_t *e, dvr_autorec_entry_t
 {
   char buf[512];
   char ubuf[UUID_HEX_SIZE];
+  const char *s;
   dvr_entry_t *de;
   uint32_t count = 0, max_count;
 
@@ -1541,9 +1542,9 @@ dvr_entry_create_by_autorec(int enabled, epg_broadcast_t *e, dvr_autorec_entry_t
     }
   }
 
-  snprintf(buf, sizeof(buf), _("Auto recording%s%s"),
-           dae->dae_comment ? ": " : "",
-           dae->dae_comment ?: "");
+  /* Prefer the recording comment or the name of the rule to an empty string */
+  s = dae->dae_comment && *dae->dae_comment ? dae->dae_comment : dae->dae_name;
+  snprintf(buf, sizeof(buf), _("Auto recording%s%s"), s ? ": " : "", s ?: "");
 
   dvr_entry_create_by_event(enabled, idnode_uuid_as_str(&dae->dae_config->dvr_id, ubuf),
                             e, dae->dae_start_extra, dae->dae_stop_extra,