Add an additional rule to autorecordings to filter out only events that occures around a specific time of day

This commit is contained in:
Andreas Öman 2010-03-21 20:45:26 +00:00
parent 3162bc68e2
commit ccb447ae44
3 changed files with 50 additions and 1 deletions

View file

@ -188,6 +188,8 @@ typedef struct dvr_autorec_entry {
epg_content_group_t *dae_ecg;
int dae_approx_time; /* Minutes from midnight */
int dae_weekdays;
channel_t *dae_channel;

View file

@ -25,6 +25,7 @@
#include <string.h>
#include <stdarg.h>
#include <errno.h>
#include <math.h>
#include "tvhead.h"
#include "settings.h"
@ -99,6 +100,17 @@ autorec_cmp(dvr_autorec_entry_t *dae, event_t *e)
return 0;
}
if(dae->dae_approx_time != 0) {
struct tm a_time;
struct tm ev_time;
localtime_r(&e->e_start, &a_time);
localtime_r(&e->e_start, &ev_time);
a_time.tm_min = dae->dae_approx_time % 60;
a_time.tm_hour = dae->dae_approx_time / 60;
if(abs(mktime(&a_time) - mktime(&ev_time)) > 900)
return 0;
}
if(dae->dae_weekdays != 0x7f) {
struct tm tm;
localtime_r(&e->e_start, &tm);
@ -233,6 +245,8 @@ autorec_record_build(dvr_autorec_entry_t *dae)
htsmsg_add_str(e, "title", dae->dae_title ?: "");
htsmsg_add_u32(e, "approx_time", dae->dae_approx_time);
build_weekday_tags(str, sizeof(str), dae->dae_weekdays);
htsmsg_add_str(e, "weekdays", str);
@ -337,6 +351,17 @@ autorec_record_update(void *opaque, const char *id, htsmsg_t *values,
if((s = htsmsg_get_str(values, "contentgrp")) != NULL)
dae->dae_ecg = epg_content_group_find_by_name(s);
if((s = htsmsg_get_str(values, "approx_time")) != NULL) {
if(strchr(s, ':') != NULL) {
// formatted time string - convert
dae->dae_approx_time = (atoi(s) * 60) + atoi(s + 3);
} else if(strlen(s) == 0) {
dae->dae_approx_time = 0;
} else {
dae->dae_approx_time = atoi(s);
}
}
if((s = htsmsg_get_str(values, "weekdays")) != NULL)
dae->dae_weekdays = build_weekday_mask(s);

View file

@ -411,6 +411,28 @@ tvheadend.autoreceditor = function() {
valueField: 'identifier',
displayField: 'name'
})
}, {
header: "Starting Around",
dataIndex: 'approx_time',
renderer: function(value, metadata, record, row, col, store) {
if (typeof value === 'string')
return value;
if (value === 0)
return '';
var hours = Math.floor(value / 60);
var mins = value % 60;
var dt = new Date();
dt.setHours(hours);
dt.setMinutes(mins);
return dt.format('H:i');
},
editor: new Ext.form.TimeField({
allowBlank: true,
increment: 10,
format: 'H:i'
})
}, {
header: "Priority",
dataIndex: 'pri',
@ -505,7 +527,7 @@ tvheadend.dvr = function() {
tvheadend.autorecRecord = Ext.data.Record.create([
'enabled','title','channel','tag','creator','contentgrp','comment',
'weekdays', 'pri'
'weekdays', 'pri', 'approx_time'
]);