Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
DVR: autorec duration fixes
  • Loading branch information
perexg committed Sep 8, 2014
1 parent 0506aac commit 9858ed0
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 15 deletions.
1 change: 1 addition & 0 deletions src/dvr/dvr.h
Expand Up @@ -395,6 +395,7 @@ void dvr_entry_cancel_delete(dvr_entry_t *de);

htsmsg_t *dvr_entry_class_pri_list(void *o);
htsmsg_t *dvr_entry_class_config_name_list(void *o);
htsmsg_t *dvr_entry_class_duration_list(void *o, const char *not_set, int max);

/**
* Query interface
Expand Down
23 changes: 15 additions & 8 deletions src/dvr/dvr_autorec.c
Expand Up @@ -81,8 +81,8 @@ autorec_cmp(dvr_autorec_entry_t *dae, epg_broadcast_t *e)
dae->dae_title[0] == '\0') &&
dae->dae_brand == NULL &&
dae->dae_season == NULL &&
dae->dae_minduration == 0 &&
(dae->dae_maxduration == 0 || dae->dae_maxduration > 24 * 3600) &&
dae->dae_minduration <= 0 &&
(dae->dae_maxduration <= 0 || dae->dae_maxduration > 24 * 3600) &&
dae->dae_serieslink == NULL)
return 0; // Avoid super wildcard match

Expand Down Expand Up @@ -141,11 +141,11 @@ autorec_cmp(dvr_autorec_entry_t *dae, epg_broadcast_t *e)

duration = difftime(e->stop,e->start);

if(dae->dae_minduration) {
if(dae->dae_minduration > 0) {
if(duration < dae->dae_minduration) return 0;
}

if(dae->dae_maxduration) {
if(dae->dae_maxduration > 0) {
if(duration > dae->dae_maxduration) return 0;
}

Expand Down Expand Up @@ -452,6 +452,7 @@ dvr_autorec_entry_class_start_get(void *o)
static int
dvr_autorec_entry_class_stop_get(void *o)
{
dvr_autorec_entry_t *dae = (dvr_autorec_entry_t *)o;
return dvr_autorec_entry_class_time_get(o, v, &dae->dae_stop);
}
#endif
Expand Down Expand Up @@ -479,8 +480,13 @@ dvr_autorec_entry_class_time_list(void *o)
static htsmsg_t *
dvr_autorec_entry_class_minduration_list(void *o)
{
/* reuse */
return dvr_autorec_entry_class_time_list(o);
return dvr_entry_class_duration_list(o, "Not set", 24*60);
}

static htsmsg_t *
dvr_autorec_entry_class_maxduration_list(void *o)
{
return dvr_entry_class_duration_list(o, "Not set", 24*60);
}

static int
Expand Down Expand Up @@ -735,16 +741,17 @@ const idclass_t dvr_autorec_entry_class = {
.rend = dvr_autorec_entry_class_weekdays_rend,
},
{
.type = PT_U32,
.type = PT_INT,
.id = "minduration",
.name = "Minimal Duration",
.list = dvr_autorec_entry_class_minduration_list,
.off = offsetof(dvr_autorec_entry_t, dae_minduration),
},
{
.type = PT_U32,
.type = PT_INT,
.id = "maxduration",
.name = "Maximal Duration",
.list = dvr_autorec_entry_class_maxduration_list,
.off = offsetof(dvr_autorec_entry_t, dae_maxduration),
},
{
Expand Down
15 changes: 10 additions & 5 deletions src/dvr/dvr_db.c
Expand Up @@ -1522,15 +1522,15 @@ dvr_entry_class_channel_icon_url_get(void *o)
return &s;
}

static htsmsg_t *
dvr_entry_class_extra_list(void *o)
htsmsg_t *
dvr_entry_class_duration_list(void *o, const char *not_set, int max)
{
int i;
htsmsg_t *e, *l = htsmsg_create_list();
char buf[32];
e = htsmsg_create_map();
htsmsg_add_u32(e, "key", 0);
htsmsg_add_str(e, "val", "Not set (use channel or DVR config)");
htsmsg_add_str(e, "val", not_set);
htsmsg_add_msg(l, NULL, e);
for (i = 1; i <= 120; i++) {
snprintf(buf, sizeof(buf), "%d min%s", i, i > 1 ? "s" : "");
Expand All @@ -1539,7 +1539,7 @@ dvr_entry_class_extra_list(void *o)
htsmsg_add_str(e, "val", buf);
htsmsg_add_msg(l, NULL, e);
}
for (i = 120; i <= 240; i += 30) {
for (i = 120; i <= max; i += 30) {
if ((i % 60) == 0)
snprintf(buf, sizeof(buf), "%d hrs", i / 60);
else
Expand All @@ -1551,8 +1551,13 @@ dvr_entry_class_extra_list(void *o)
}
return l;
}


static htsmsg_t *
dvr_entry_class_extra_list(void *o)
{
return dvr_entry_class_duration_list(o, "Not set (use channel or DVR config)", 4*60);
}

static htsmsg_t *
dvr_entry_class_content_type_list(void *o)
{
Expand Down
4 changes: 2 additions & 2 deletions src/webui/static/app/dvr.js
Expand Up @@ -243,13 +243,13 @@ tvheadend.autorec_editor = function(panel, index) {
url: 'api/dvr/autorec',
params: {
list: 'enable,title,channel,tag,content_type,minduration,' +
'weekdays,approx_time,pri,config_name,comment',
'maxduration,weekdays,approx_time,pri,config_name,comment',
},
create: { }
},
del: true,
list: 'enable,title,channel,tag,content_type,minduration,' +
'weekdays,approx_time,pri,config_name,creator,comment',
'maxduration,weekdays,approx_time,pri,config_name,creator,comment',
sort: {
field: 'name',
direction: 'ASC'
Expand Down

0 comments on commit 9858ed0

Please sign in to comment.