]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
EPG: implement fulltext search (title, subtitle, summary, description)
authorJaroslav Kysela <perex@perex.cz>
Sat, 17 Jan 2015 21:43:14 +0000 (22:43 +0100)
committerJaroslav Kysela <perex@perex.cz>
Sat, 17 Jan 2015 21:43:14 +0000 (22:43 +0100)
src/api/api_epg.c
src/epg.c
src/epg.h
src/webui/static/app/epg.js

index dac92579fadb59350e03774907ed3428f3632780..80200b2c8d53c43cfa94b11ceebed2412fb46734 100644 (file)
@@ -289,11 +289,12 @@ api_epg_grid
   memset(&eq, 0, sizeof(eq));
 
   lang = htsmsg_get_str(args, "lang");
-  eq.lang = lang ? strdup(lang) : NULL;
-
+  if (lang)
+    eq.lang = strdup(lang);
   str = htsmsg_get_str(args, "title");
   if (str)
     eq.stitle = strdup(str);
+  eq.fulltext = htsmsg_get_bool_or_default(args, "fulltext", 0);
   str = htsmsg_get_str(args, "channel");
   if (str)
     eq.channel = strdup(str);
index 82f69808d4a022b1426e479c361c7d90e0cf6f2d..95e596f73bd077044d51d7fdcdbfeea40537204c 100644 (file)
--- a/src/epg.c
+++ b/src/epg.c
@@ -2263,6 +2263,7 @@ _eq_add ( epg_query_t *eq, epg_broadcast_t *e )
 {
   const char *s, *lang = eq->lang;
   epg_episode_t *ep;
+  int fulltext = eq->stitle && eq->fulltext;
 
   /* Filtering */
   if (e == NULL) return;
@@ -2292,22 +2293,36 @@ _eq_add ( epg_query_t *eq, epg_broadcast_t *e )
     }
     if (!r) return;
   }
-  if (eq->title.comp != EC_NO || eq->stitle) {
+  if (fulltext) {
+    if ((s = epg_episode_get_title(ep, lang)) == NULL ||
+        regexec(&eq->stitle_re, s, 0, NULL, 0)) {
+      if ((s = epg_episode_get_subtitle(ep, lang)) == NULL ||
+          regexec(&eq->stitle_re, s, 0, NULL, 0)) {
+        if ((s = epg_broadcast_get_summary(e, lang)) == NULL ||
+            regexec(&eq->stitle_re, s, 0, NULL, 0)) {
+          if ((s = epg_broadcast_get_description(e, lang)) == NULL ||
+              regexec(&eq->stitle_re, s, 0, NULL, 0)) {
+            return;
+          }
+        }
+      }
+    }
+  }
+  if (eq->title.comp != EC_NO || (eq->stitle && !fulltext)) {
     if ((s = epg_episode_get_title(ep, lang)) == NULL) return;
-    if (eq->stitle)
-      if (regexec(&eq->stitle_re, s, 0, NULL, 0)) return;
-    if (_eq_comp_str(&eq->title, s)) return;
+    if (eq->stitle && !fulltext && regexec(&eq->stitle_re, s, 0, NULL, 0)) return;
+    if (eq->title.comp != EC_NO && _eq_comp_str(&eq->title, s)) return;
   }
   if (eq->subtitle.comp != EC_NO) {
     if ((s = epg_episode_get_subtitle(ep, lang)) == NULL) return;
     if (_eq_comp_str(&eq->subtitle, s)) return;
   }
   if (eq->summary.comp != EC_NO) {
-    if ((s = epg_episode_get_summary(ep, lang)) == NULL) return;
+    if ((s = epg_broadcast_get_summary(e, lang)) == NULL) return;
     if (_eq_comp_str(&eq->summary, s)) return;
   }
   if (eq->description.comp != EC_NO) {
-    if ((s = epg_episode_get_description(ep, lang)) == NULL) return;
+    if ((s = epg_broadcast_get_description(e, lang)) == NULL) return;
     if (_eq_comp_str(&eq->description, s)) return;
   }
 
index 28c5791eca000deb20eeec246df67bf2f6be9a44..a93e64b6896f113543fc9b1c68670c140667cd3f 100644 (file)
--- a/src/epg.h
+++ b/src/epg.h
@@ -579,6 +579,7 @@ typedef struct epg_query {
   epg_filter_num_t  channel_num;
   char             *stitle;
   regex_t           stitle_re;
+  int               fulltext;
   char             *channel;
   char             *channel_tag;
   uint32_t          genre_count;
index 36a36318fc1de75d94da2f5ba771cf3309654a5b..6bde52230ecda46f6e997c6971b1ae449a92cf3a 100644 (file)
@@ -562,6 +562,10 @@ tvheadend.epg = function() {
         width: 200
     });
 
+    var epgFilterFulltext = new Ext.form.Checkbox({
+        width: 20
+    });
+
     // Channels, uses global store
 
     var epgFilterChannels = new Ext.form.ComboBox({
@@ -662,6 +666,11 @@ tvheadend.epg = function() {
         epgFilterTitle.setValue("");
     };
 
+    clearFulltextFilter = function() {
+        delete epgStore.baseParams.fulltext;
+        epgFilterFulltext.setValue(0);
+    };
+
     clearChannelFilter = function() {
         delete epgStore.baseParams.channel;
         epgFilterChannels.setValue("");
@@ -685,6 +694,7 @@ tvheadend.epg = function() {
 
     function epgQueryClear() {
         clearTitleFilter();
+        clearFulltextFilter();
         clearChannelFilter();
         clearChannelTagsFilter();
         clearDurationFilter();
@@ -752,6 +762,13 @@ tvheadend.epg = function() {
         }
     });
 
+    epgFilterFulltext.on('check', function(c, value) {
+        if (epgStore.baseParams.fulltext !== value) {
+            epgStore.baseParams.fulltext = value;
+            epgView.reset();
+        }
+    });
+
     var epgView = new Ext.ux.grid.livegrid.GridView({
         nearLimit: 100,
         loadMask: {
@@ -777,7 +794,7 @@ tvheadend.epg = function() {
     });
 
     var tbar = [
-        epgFilterTitle, '-',
+        epgFilterTitle, { text: 'Fulltext' }, epgFilterFulltext, '-',
         epgFilterChannels, '-',
         epgFilterChannelTags, '-',
         epgFilterContentGroup, '-',