]> 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>
Fri, 8 Sep 2017 06:59:44 +0000 (08:59 +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 8ba3e1ce9cd0cbc16143ad441ded5d57d183cff3..68df6bb0127c6fd81b3eb80a633ea5e5fd8060b9 100644 (file)
@@ -1517,6 +1517,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;
 
@@ -1542,9 +1543,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,