From 28d77734594e373a96217d948cd132817024f1d4 Mon Sep 17 00:00:00 2001 From: "E.Smith" <31170571+azlm8t@users.noreply.github.com> Date: Wed, 19 Sep 2018 15:22:31 +0100 Subject: [PATCH] dvr: Avoid recording partial programme if autorec created mid-programme. When creating an autorec, it can match a programme that has already started. If so, it's better to prefer the later recording so you get a full recording. So, if it's 09:10 and there is an hour long programme that started at 09:00 but is repeated at 10:00, then let's record at 10:00 instead and get the full hour, instead of at 09:10 and only get 50 minutes. --- src/dvr/dvr_db.c | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/src/dvr/dvr_db.c b/src/dvr/dvr_db.c index cc705e3b6..e479fbe80 100644 --- a/src/dvr/dvr_db.c +++ b/src/dvr/dvr_db.c @@ -1753,13 +1753,30 @@ dvr_is_better_recording_timeslot(const epg_broadcast_t *new_bcast, const dvr_ent /* Ealier start time is better; prefers non-timeshift channel X to X+1. * This gives us time to reschedule to X+1 if the recording on X fails. + * + * However, when creating an autorec, it can match a programme that has + * already started. If so, it's better to prefer the later recording so + * you get a full recording. + * + * So, if it's 09:10 and there is an hour long programme that + * started at 09:00 but is repeated at 10:00, then let's record at + * 10:00 instead and get the full hour, instead of at 09:10 and only + * get 50 minutes. */ - if (new_bcast->start < old_bcast->start) - return 1; + if (new_bcast->start != old_bcast->start) { + if (new_bcast->start > old_bcast->start && time(NULL) > old_bcast->start) { + return 1; + } else if (new_bcast->start < old_bcast->start && time(NULL) > new_bcast->start) { + return 0; + } - /* Later broadcast is always worse. */ - if (new_bcast->start > old_bcast->start) - return 0; + if (new_bcast->start < old_bcast->start) + return 1; + + /* Later broadcast is always worse. */ + if (new_bcast->start > old_bcast->start) + return 0; + } /* If here, we have the same time. */ -- 2.47.2