From: E.Smith <31170571+azlm8t@users.noreply.github.com> Date: Sun, 3 Sep 2017 11:35:05 +0000 (+0100) Subject: DVR: Prefer autorec rule name if comment field is empty (#4500) X-Git-Tag: v4.2.4~57 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ffb578c4869bc0cb5c4cabed59dc7168c5132b9f;p=thirdparty%2Ftvheadend.git DVR: Prefer autorec rule name if comment field is empty (#4500) Currently the Upcoming recordings tab has a comment field that says "Auto recording" or "Auto recording: ". 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: ", "Auto recording: ", otherwise "Auto recording". Fixes: #4500. --- diff --git a/src/dvr/dvr_db.c b/src/dvr/dvr_db.c index de226db21..c2d856750 100644 --- a/src/dvr/dvr_db.c +++ b/src/dvr/dvr_db.c @@ -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,