DVR autorec: implement fulltext (title, subtitle, summary, description) filter, fixes #2170

This commit is contained in:
Jaroslav Kysela 2015-01-18 21:19:26 +01:00
parent 941dbcbd74
commit c92ccca440
5 changed files with 59 additions and 26 deletions

View file

@ -254,6 +254,7 @@ typedef struct dvr_autorec_entry {
char *dae_title;
regex_t dae_title_preg;
int dae_fulltext;
uint32_t dae_content_type;
@ -498,7 +499,7 @@ dvr_entry_create_(const char *config_uuid, epg_broadcast_t *e,
dvr_prio_t pri, int retention, const char *comment);
dvr_autorec_entry_t *
dvr_autorec_create_htsp(const char *dvr_config_name, const char *title,
dvr_autorec_create_htsp(const char *dvr_config_name, const char *title, int fulltext,
channel_t *ch, uint32_t enabled, int32_t start,
int32_t start_window, uint32_t days, time_t start_extra,
time_t stop_extra, dvr_prio_t pri, int retention,

View file

@ -96,9 +96,25 @@ autorec_cmp(dvr_autorec_entry_t *dae, epg_broadcast_t *e)
}
if(dae->dae_title != NULL && dae->dae_title[0] != '\0') {
lang_str_ele_t *ls;
if(!e->episode->title) return 0;
RB_FOREACH(ls, e->episode->title, link)
if (!regexec(&dae->dae_title_preg, ls->str, 0, NULL, 0)) break;
if (!dae->dae_fulltext) {
if(!e->episode->title) return 0;
RB_FOREACH(ls, e->episode->title, link)
if (!regexec(&dae->dae_title_preg, ls->str, 0, NULL, 0)) break;
} else {
ls = NULL;
if (e->episode->title)
RB_FOREACH(ls, e->episode->title, link)
if (!regexec(&dae->dae_title_preg, ls->str, 0, NULL, 0)) break;
if (!ls && e->episode->subtitle)
RB_FOREACH(ls, e->episode->subtitle, link)
if (!regexec(&dae->dae_title_preg, ls->str, 0, NULL, 0)) break;
if (!ls && e->summary)
RB_FOREACH(ls, e->summary, link)
if (!regexec(&dae->dae_title_preg, ls->str, 0, NULL, 0)) break;
if (!ls && e->description)
RB_FOREACH(ls, e->description, link)
if (!regexec(&dae->dae_title_preg, ls->str, 0, NULL, 0)) break;
}
if (!ls) return 0;
}
@ -205,7 +221,7 @@ dvr_autorec_create(const char *uuid, htsmsg_t *conf)
dvr_autorec_entry_t*
dvr_autorec_create_htsp(const char *dvr_config_name, const char *title,
dvr_autorec_create_htsp(const char *dvr_config_name, const char *title, int fulltext,
channel_t *ch, uint32_t enabled, int32_t start, int32_t start_window,
uint32_t weekdays, time_t start_extra, time_t stop_extra,
dvr_prio_t pri, int retention,
@ -227,6 +243,7 @@ dvr_autorec_create_htsp(const char *dvr_config_name, const char *title,
htsmsg_add_s64(conf, "start_extra", start_extra);
htsmsg_add_s64(conf, "stop_extra", stop_extra);
htsmsg_add_str(conf, "title", title);
htsmsg_add_u32(conf, "fulltext", 1);
htsmsg_add_str(conf, "config_name", dvr_config_name ?: "");
htsmsg_add_str(conf, "owner", owner ?: "");
htsmsg_add_str(conf, "creator", creator ?: "");
@ -880,6 +897,12 @@ const idclass_t dvr_autorec_entry_class = {
.set = dvr_autorec_entry_class_title_set,
.off = offsetof(dvr_autorec_entry_t, dae_title),
},
{
.type = PT_BOOL,
.id = "fulltext",
.name = "Fulltext",
.off = offsetof(dvr_autorec_entry_t, dae_fulltext),
},
{
.type = PT_STR,
.id = "channel",

View file

@ -765,8 +765,10 @@ htsp_build_autorecentry(dvr_autorec_entry_t *dae, const char *method)
htsmsg_add_s64(out, "startExtra", dae->dae_start_extra);
htsmsg_add_s64(out, "stopExtra", dae->dae_stop_extra);
if(dae->dae_title)
if(dae->dae_title) {
htsmsg_add_str(out, "title", dae->dae_title);
htsmsg_add_u32(out, "fulltext", dae->dae_fulltext);
}
if(dae->dae_name)
htsmsg_add_str(out, "name", dae->dae_name);
if(dae->dae_directory)
@ -1607,13 +1609,16 @@ htsp_method_addAutorecEntry(htsp_connection_t *htsp, htsmsg_t *in)
dvr_autorec_entry_t *dae;
const char *dvr_config_name, *title, *creator, *comment, *name, *directory;
int64_t start_extra, stop_extra;
uint32_t u32, days_of_week, priority, min_duration, max_duration, retention, enabled;
uint32_t u32, days_of_week, priority, min_duration, max_duration;
uint32_t retention, enabled, fulltext;
int32_t approx_time, start, start_window;
channel_t *ch = NULL;
/* Options */
if(!(title = htsmsg_get_str(in, "title")))
return htsp_error("Invalid arguments");
if(htsmsg_get_u32(in, "fulltext", &fulltext))
fulltext = 0;
dvr_config_name = htsp_dvr_config_name(htsp, htsmsg_get_str(in, "configName"));
if(!htsmsg_get_u32(in, "channelId", &u32))
ch = channel_find_by_id(u32);
@ -1661,7 +1666,8 @@ htsp_method_addAutorecEntry(htsp_connection_t *htsp, htsmsg_t *in)
if (ch && !htsp_user_access_channel(htsp, ch))
return htsp_error("User does not have access");
dae = dvr_autorec_create_htsp(dvr_config_name, title, ch, enabled, start, start_window, days_of_week,
dae = dvr_autorec_create_htsp(dvr_config_name, title, fulltext,
ch, enabled, start, start_window, days_of_week,
start_extra, stop_extra, priority, retention, min_duration, max_duration,
htsp->htsp_granted_access->aa_username, creator, comment, name, directory);

View file

@ -436,15 +436,23 @@ tvheadend.autorec_editor = function(panel, index) {
name: { width: 200 },
directory: { width: 200 },
title: { width: 300 },
fulltext: { width: 70 },
channel: { width: 200 },
tag: { width: 200 },
content_type: { width: 100 },
minduration: { width: 80 },
maxduration: { width: 80 },
minduration: { width: 100 },
maxduration: { width: 100 },
weekdays: { width: 160 },
start: { width: 120 },
start_window: { width: 100 },
start: { width: 80 },
start_window: { width: 80 },
start_extra: { width: 80 },
stop_extra: { width: 80 },
weekdays: {
width: 120,
renderer: function(st) { return tvheadend.weekdaysRenderer(st); }
},
pri: { width: 80 },
retention: { width: 80 },
config_name: { width: 120 },
owner: { width: 100 },
creator: { width: 200 },
@ -453,19 +461,14 @@ tvheadend.autorec_editor = function(panel, index) {
add: {
url: 'api/dvr/autorec',
params: {
list: 'enabled,name,directory,title,channel,tag,content_type,minduration,' +
list: 'enabled,name,directory,title,fulltext,channel,tag,content_type,minduration,' +
'maxduration,weekdays,start,start_window,pri,config_name,comment'
},
create: { }
},
del: true,
list: 'enabled,name,directory,title,channel,tag,content_type,minduration,' +
list: 'enabled,name,directory,title,fulltext,channel,tag,content_type,minduration,' +
'maxduration,weekdays,start,start_window,pri,config_name,owner,creator,comment',
columns: {
weekdays: {
renderer: function(st) { return tvheadend.weekdaysRenderer(st); }
}
},
sort: {
field: 'name',
direction: 'ASC'
@ -496,7 +499,10 @@ tvheadend.timerec_editor = function(panel, index) {
directory: { width: 200 },
title: { width: 300 },
channel: { width: 200 },
weekdays: { width: 160 },
weekdays: {
width: 120,
renderer: function(st) { return tvheadend.weekdaysRenderer(st); }
},
start: { width: 120 },
stop: { width: 120 },
pri: { width: 80 },
@ -514,11 +520,6 @@ tvheadend.timerec_editor = function(panel, index) {
},
del: true,
list: 'enabled,name,directory,title,channel,weekdays,start,stop,pri,config_name,owner,creator,comment',
columns: {
weekdays: {
renderer: function(st) { return tvheadend.weekdaysRenderer(st); }
}
},
sort: {
field: 'name',
direction: 'ASC'

View file

@ -915,6 +915,7 @@ tvheadend.epg = function() {
var title = epgStore.baseParams.title ? epgStore.baseParams.title
: "<i>Don't care</i>";
var fulltext = epgStore.baseParams.fulltext ? " <i>(Fulltext)</i>" : "";
var channel = epgStore.baseParams.channel ? tvheadend.channelLookupName(epgStore.baseParams.channel)
: "<i>Don't care</i>";
var tag = epgStore.baseParams.channelTag ? tvheadend.channelTagLookupName(epgStore.baseParams.channelTag)
@ -927,7 +928,7 @@ tvheadend.epg = function() {
Ext.MessageBox.confirm('Auto Recorder', 'This will create an automatic rule that '
+ 'continuously scans the EPG for programmes '
+ 'to record that match this query: ' + '<br><br>'
+ '<div class="x-smallhdr">Title:</div>' + title + '<br>'
+ '<div class="x-smallhdr">Title:</div>' + title + fulltext + '<br>'
+ '<div class="x-smallhdr">Channel:</div>' + channel + '<br>'
+ '<div class="x-smallhdr">Tag:</div>' + tag + '<br>'
+ '<div class="x-smallhdr">Genre:</div>' + contentType + '<br>'
@ -948,6 +949,7 @@ tvheadend.epg = function() {
comment: 'Created from EPG query'
};
if (params.title) conf.title = params.title;
if (params.fulltext) conf.fulltext = params.fulltext;
if (params.channel) conf.channel = params.channel;
if (params.channelTag) conf.tag = params.channelTag;
if (params.contentType) conf.content_type = params.contentType;