<dd>
On which specific days of the week to find matching programmes.
<p>
-<dt><b>Starting Around</b>
+<dt><b>Start Time</b>
<dd>
-An approximate starting time for matching programmes.
-<br>
-<br>
-I'd need to check the code to see how this works to expand on this any further. It used to be:
-<br>
-<br>
-Only record events if they are scheduled +-15 minutes from this given time.
+An event which starts between this "start time" and "start time up to" will be matched (including).
+<p>
+<dt><b>Start Up To</b>
+<dd>
+The start up to limit.
<p>
<dt><b>Priority</b>
<dd>
static void
config_modify_dvrauto( htsmsg_t *c )
{
- int tm = -1;
+ int tm = -1, tw = -1;
char buf[16];
if (config_dvr_autorec_start_set(htsmsg_get_str(c, "start"), &tm) > 0 && tm >= 0) {
tm -= 15;
if (tm < 0)
tm += 24 * 60;
+ tw = tm + 30;
+ if (tw >= 24 * 60)
+ tw -= 24 * 60;
snprintf(buf, sizeof(buf), "%02d:%02d", tm / 60, tm % 60);
- htsmsg_set_str(c, "start", tm <= 0 ? "Any" : buf);
- htsmsg_set_u32(c, "start_window", 30);
+ htsmsg_set_str(c, "start", buf);
+ snprintf(buf, sizeof(buf), "%02d:%02d", tw / 60, tw % 60);
+ htsmsg_set_str(c, "start_window", buf);
} else {
htsmsg_delete_field(c, "start");
}
return 0;
}
- if(dae->dae_start >= 0 && dae->dae_start_window >= 0) {
+ if(dae->dae_start >= 0 && dae->dae_start_window >= 0 &&
+ dae->dae_start < 24*60 && dae->dae_start_window < 24*60) {
struct tm a_time, ev_time;
- time_t ta, te;
+ time_t ta, te, tad;
localtime_r(&e->start, &a_time);
ev_time = a_time;
a_time.tm_min = dae->dae_start % 60;
a_time.tm_hour = dae->dae_start / 60;
ta = mktime(&a_time);
te = mktime(&ev_time);
- if(ta > te || te > ta + dae->dae_start_window * 60)
- return 0;
+ if(dae->dae_start > dae->dae_start_window) {
+ ta -= 24 * 3600; /* 24 hours */
+ tad = ((24 * 60) - dae->dae_start + dae->dae_start_window) * 60;
+ if(ta > te || te > ta + tad) {
+ ta += 24 * 3600;
+ if(ta > te || te > ta + tad)
+ return 0;
+ }
+ } else {
+ tad = (dae->dae_start_window - dae->dae_start) * 60;
+ if(ta > te || te > ta + tad)
+ return 0;
+ }
}
duration = difftime(e->stop,e->start);
return dvr_autorec_entry_class_time_set(o, v, &dae->dae_start);
}
+static int
+dvr_autorec_entry_class_start_window_set(void *o, const void *v)
+{
+ dvr_autorec_entry_t *dae = (dvr_autorec_entry_t *)o;
+ return dvr_autorec_entry_class_time_set(o, v, &dae->dae_start_window);
+}
+
static const void *
dvr_autorec_entry_class_time_get(void *o, int tm)
{
return dvr_autorec_entry_class_time_get(o, dae->dae_start);
}
+static const void *
+dvr_autorec_entry_class_start_window_get(void *o)
+{
+ dvr_autorec_entry_t *dae = (dvr_autorec_entry_t *)o;
+ return dvr_autorec_entry_class_time_get(o, dae->dae_start_window);
+}
+
htsmsg_t *
dvr_autorec_entry_class_time_list(void *o, const char *null)
{
return dvr_autorec_entry_class_time_list(o, "Any");
}
-static htsmsg_t *
-dvr_autorec_entry_class_time_window_list(void *o)
-{
- return dvr_entry_class_duration_list(o, "Exact", 24*60, 1);
-}
-
static htsmsg_t *
dvr_autorec_entry_class_extra_list(void *o)
{
.opts = PO_SORTKEY
},
{
- .type = PT_INT,
+ .type = PT_STR,
.id = "start_window",
- .name = "Start Window",
- .list = dvr_autorec_entry_class_time_window_list,
- .off = offsetof(dvr_autorec_entry_t, dae_start_window),
+ .name = "Start Up To",
+ .set = dvr_autorec_entry_class_start_window_set,
+ .get = dvr_autorec_entry_class_start_window_get,
+ .list = dvr_autorec_entry_class_time_list_,
+ .opts = PO_SORTKEY,
},
{
.type = PT_TIME,
htsp_build_autorecentry(dvr_autorec_entry_t *dae, const char *method)
{
htsmsg_t *out = htsmsg_create_map();
+ int tad;
htsmsg_add_str(out, "id", idnode_uuid_as_str(&dae->dae_id));
htsmsg_add_u32(out, "enabled", dae->dae_enabled);
htsmsg_add_u32(out, "minDuration", dae->dae_minduration);
htsmsg_add_u32(out, "retention", dae->dae_retention);
htsmsg_add_u32(out, "daysOfWeek", dae->dae_weekdays);
+ if (dae->dae_start >= 0 && dae->dae_start_window >= 0) {
+ if (dae->dae_start > dae->dae_start_window)
+ tad = 24 * 60 - dae->dae_start + dae->dae_start_window;
+ else
+ tad = dae->dae_start_window - dae->dae_start;
+ } else {
+ tad = -1;
+ }
htsmsg_add_s32(out, "approxTime",
- dae->dae_start_window == 30 && dae->dae_start >= 0 ?
- dae->dae_start + 15 : -1);
+ dae->dae_start >= 0 && tad >= 0 ?
+ ((dae->dae_start + tad / 2) % (24 * 60)) : -1);
htsmsg_add_u32(out, "start", dae->dae_start);
htsmsg_add_u32(out, "startWindow", dae->dae_start_window);
htsmsg_add_u32(out, "priority", dae->dae_pri);
start = approx_time - 15;
if (start < 0)
start += 24 * 60;
- start_window = 60;
+ start_window = start + 30;
+ if (start_window >= 24 * 60)
+ start_window -= 24 * 60;
}
if(htsmsg_get_s64(in, "startExtra", &start_extra))
start_extra = 0; // 0 = dvr config