]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
DVR autorec: implement fulltext (title, subtitle, summary, description) filter, fixes...
authorJaroslav Kysela <perex@perex.cz>
Sun, 18 Jan 2015 20:19:26 +0000 (21:19 +0100)
committerJaroslav Kysela <perex@perex.cz>
Sun, 18 Jan 2015 20:19:26 +0000 (21:19 +0100)
src/dvr/dvr.h
src/dvr/dvr_autorec.c
src/htsp_server.c
src/webui/static/app/dvr.js
src/webui/static/app/epg.js

index 13358a2d496ab4bac9e3cb3e2c97c08b2abe6e10..a8a1258327470f1f116c927e602f922beb5e67c5 100644 (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,
index ccbaf5a90e7dbe85eb1310f3f590aab3f392740d..b113da21ac6b16a5b7baff4b4852f6b25d98f7df 100644 (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",
index fea8e6fb2aa1514021955e81b6f538ada794b177..321d5aaa25f7055f6289509c5cca10637db0febb 100644 (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);
 
index d617076a9d9a2975b796085280aaeeacdd35453a..4cde7833aef20f639efbf42d35646ec17e4fb944 100644 (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'
index 6bde52230ecda46f6e997c6971b1ae449a92cf3a..a8c67d9bdbf1c4c7c8b180a25a9b06e7e26dd569 100644 (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;