]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
xmltv grabber: parse channel numbers only on request
authorJaroslav Kysela <perex@perex.cz>
Tue, 5 Apr 2016 06:48:41 +0000 (08:48 +0200)
committerJaroslav Kysela <perex@perex.cz>
Tue, 5 Apr 2016 06:48:43 +0000 (08:48 +0200)
- cleanup the PyEPG / XMLTV module registration
- create different classes for help and additional configs

docs/markdown/toc.md
src/epggrab.c
src/epggrab.h
src/epggrab/module.c
src/epggrab/module/pyepg.c
src/epggrab/module/xmltv.c
src/epggrab/private.h

index 2117ba9b434a88b41b85b076195f1aa8cbe2dd35..a22c6f3069c79ff5f14c76a60c1fc04ed556fb1d 100644 (file)
@@ -59,8 +59,10 @@ Web Interface Configuration Guide
   - [EPG Grabber](class/epggrab)
   - EPG Grabber Modules
     - [OTA Module](class/epggrab_mod_ota)
-    - [Internal Module](class/epggrab_mod_int)
-    - [External Module](class/epggrab_mod_ext)
+    - [Internal PyEPG](class/epggrab_mod_int_pyepg)
+    - [Internal XMLTV](class/epggrab_mod_int_xmltv)
+    - [External PyEPG](class/epggrab_mod_ext_pyepg)
+    - [External XMLTV](class/epggrab_mod_ext_xmltv)
 
 * Stream
 
index f957e3452c89d7d05f0fbbd7d43df67cba26c808..dc7acbd6d079dde4c445f5d2942a4e17ae5006e5 100644 (file)
@@ -402,7 +402,11 @@ void epggrab_init ( void )
   idclass_register(&epggrab_class);
   idclass_register(&epggrab_mod_class);
   idclass_register(&epggrab_mod_int_class);
+  idclass_register(&epggrab_mod_int_pyepg_class);
+  idclass_register(&epggrab_mod_int_xmltv_class);
   idclass_register(&epggrab_mod_ext_class);
+  idclass_register(&epggrab_mod_ext_pyepg_class);
+  idclass_register(&epggrab_mod_ext_xmltv_class);
   idclass_register(&epggrab_mod_ota_class);
 
   epggrab_channel_init();
index 73e37476a571f85e77a8488cd4c9f67766f6dc3f..20e101effa6c71e90f91cd1216f7b57a7b784f57 100644 (file)
@@ -172,6 +172,8 @@ struct epggrab_module_int
   const char                   *path;     ///< Path for the command
   const char                   *args;     ///< Extra arguments
 
+  int                           xmltv_chnum;
+
   /* Handle data */
   char*     (*grab)   ( void *mod );
   htsmsg_t* (*trans)  ( void *mod, char *data );
index f4ffe4ea4a7d4bdf7a575157ed53cc6c3d588c22..cd424774928d3c9d379fa796e12248c001aeb4f3 100644 (file)
@@ -552,7 +552,7 @@ epggrab_module_activate_socket ( void *m, int a )
  * Create a module
  */
 epggrab_module_ext_t *epggrab_module_ext_create
-  ( epggrab_module_ext_t *skel,
+  ( epggrab_module_ext_t *skel, const idclass_t *cls,
     const char *id, const char *saveid,
     const char *name, int priority, const char *sockid,
     int (*parse) (void *m, htsmsg_t *data, epggrab_stats_t *sta),
@@ -566,7 +566,7 @@ epggrab_module_ext_t *epggrab_module_ext_create
   /* Pass through */
   hts_settings_buildpath(path, sizeof(path), "epggrab/%s.sock", sockid);
   epggrab_module_int_create((epggrab_module_int_t*)skel,
-                            &epggrab_mod_ext_class,
+                            cls ?: &epggrab_mod_ext_class,
                             id, saveid, name, priority, path,
                             NULL, parse, trans);
 
index 4acfe7811485cdab993fa2de4692b75f65650efc..5994a2abbca91ae9a934039a9218c7605dfdd7ac 100644 (file)
@@ -458,18 +458,33 @@ static int _pyepg_parse
  * Module Setup
  * ***********************************************************************/
 
+const idclass_t epggrab_mod_int_pyepg_class = {
+  .ic_super      = &epggrab_mod_int_class,
+  .ic_class      = "epggrab_mod_int_pyepg",
+  .ic_caption    = N_("Internal PyEPG grabber"),
+};
+
+
+const idclass_t epggrab_mod_ext_pyepg_class = {
+  .ic_super      = &epggrab_mod_ext_class,
+  .ic_class      = "epggrab_mod_ext_pyepg",
+  .ic_caption    = N_("External PyEPG grabber"),
+};
+
+
 void pyepg_init ( void )
 {
   char buf[256];
 
   /* Internal module */
   if (find_exec("pyepg", buf, sizeof(buf)-1))
-    epggrab_module_int_create(NULL, NULL,
+    epggrab_module_int_create(NULL, &epggrab_mod_int_pyepg_class,
                               "pyepg-internal", "pyepg", "PyEPG", 4, buf,
                               NULL, _pyepg_parse, NULL);
 
   /* External module */
-  epggrab_module_ext_create(NULL, "pyepg", "pyepg", "PyEPG", 4, "pyepg",
+  epggrab_module_ext_create(NULL, &epggrab_mod_ext_pyepg_class,
+                            "pyepg", "pyepg", "PyEPG", 4, "pyepg",
                             _pyepg_parse, NULL);
 }
 
index 5c930184723bd2db85a729cd0c7e4dcb6adbbbb9..1d31b9c0d220bc2fb79ecc3bd8b37ee7a723e4b3 100644 (file)
@@ -657,12 +657,14 @@ static int _xmltv_parse_channel
       int n = 0;
 
       name = htsmsg_get_str(subtag, "cdata");
-      while (isdigit(*(name + n))) n++;
-      if (n > 0) {
-        if (*(name + n) == 0 || *(name + n) == ' ') {
-          save |= epggrab_channel_set_number(ch, atoi(name), 0);
-          name += n;
-          while (*name == ' ') name++;
+      if (((epggrab_module_ext_t *)mod)->xmltv_chnum) {
+        while (isdigit(*(name + n))) n++;
+        if (n > 0) {
+          if (*(name + n) == 0 || *(name + n) == ' ') {
+            save |= epggrab_channel_set_number(ch, atoi(name), 0);
+            name += n;
+            while (*name == ' ') name++;
+          }
         }
       }
       if (*name)
@@ -746,6 +748,45 @@ static int _xmltv_parse
  * Module Setup
  * ***********************************************************************/
 
+#define DN_CHNUM_NAME N_("Channel numbers (heuristic)")
+#define DN_CHNUM_DESC \
+  N_("Try to obtain channel numbers from the display-name xml tag. " \
+     "If the first word is number, it is used as the channel number.")
+
+const idclass_t epggrab_mod_int_xmltv_class = {
+  .ic_super      = &epggrab_mod_int_class,
+  .ic_class      = "epggrab_mod_int_xmltv",
+  .ic_caption    = N_("Internal XMLTV EPG grabber"),
+  .ic_properties = (const property_t[]){
+    {
+      .type   = PT_BOOL,
+      .id     = "dn_chnum",
+      .name   = DN_CHNUM_NAME,
+      .desc   = DN_CHNUM_DESC,
+      .off    = offsetof(epggrab_module_int_t, xmltv_chnum),
+      .group  = 1
+    },
+    {}
+  }
+};
+
+const idclass_t epggrab_mod_ext_xmltv_class = {
+  .ic_super      = &epggrab_mod_ext_class,
+  .ic_class      = "epggrab_mod_ext_xmltv",
+  .ic_caption    = N_("External XMLTV EPG grabber"),
+  .ic_properties = (const property_t[]){
+    {
+      .type   = PT_BOOL,
+      .id     = "dn_chnum",
+      .name   = DN_CHNUM_NAME,
+      .desc   = DN_CHNUM_DESC,
+      .off    = offsetof(epggrab_module_ext_t, xmltv_chnum),
+      .group  = 1
+    },
+    {}
+  }
+};
+
 static void _xmltv_load_grabbers ( void )
 {
   int outlen = -1, rd = -1;
@@ -767,7 +808,8 @@ static void _xmltv_load_grabbers ( void )
       if ( outbuf[i] == '\n' || outbuf[i] == '\0' ) {
         outbuf[i] = '\0';
         sprintf(name, "XMLTV: %s", &outbuf[n]);
-        epggrab_module_int_create(NULL, NULL, &outbuf[p], "xmltv",
+        epggrab_module_int_create(NULL, &epggrab_mod_int_xmltv_class,
+                                  &outbuf[p], "xmltv",
                                   name, 3, &outbuf[p],
                                   NULL, _xmltv_parse, NULL);
         p = n = i + 1;
@@ -814,7 +856,8 @@ static void _xmltv_load_grabbers ( void )
             close(rd);
             if (outbuf[outlen-1] == '\n') outbuf[outlen-1] = '\0';
             snprintf(name, sizeof(name), "XMLTV: %s", outbuf);
-            epggrab_module_int_create(NULL, NULL, bin, "xmltv", name, 3, bin,
+            epggrab_module_int_create(NULL, &epggrab_mod_int_xmltv_class,
+                                      bin, "xmltv", name, 3, bin,
                                       NULL, _xmltv_parse, NULL);
             free(outbuf);
           } else {
@@ -833,8 +876,8 @@ static void _xmltv_load_grabbers ( void )
 void xmltv_init ( void )
 {
   /* External module */
-  epggrab_module_ext_create(NULL, "xmltv", "xmltv",
-                            "XMLTV", 3, "xmltv",
+  epggrab_module_ext_create(NULL, &epggrab_mod_ext_xmltv_class,
+                            "xmltv", "xmltv", "XMLTV", 3, "xmltv",
                             _xmltv_parse, NULL);
 
   /* Standard modules */
index 73edc624007193bb5949cc74cf85cc06647b493d..8e6290e04587acc48912cd76f9e00cab163b88a7 100644 (file)
@@ -87,7 +87,7 @@ epggrab_module_int_t *epggrab_module_int_create
  * *************************************************************************/
 
 epggrab_module_ext_t *epggrab_module_ext_create
-  ( epggrab_module_ext_t *skel,
+  ( epggrab_module_ext_t *skel, const idclass_t *cls,
     const char *id, const char *saveid,
     const char *name, int priority,
     const char *sockid,
@@ -188,7 +188,11 @@ size_t freesat_huffman_decode
 
 extern const idclass_t epggrab_mod_class;
 extern const idclass_t epggrab_mod_int_class;
+extern const idclass_t epggrab_mod_int_pyepg_class;
+extern const idclass_t epggrab_mod_int_xmltv_class;
 extern const idclass_t epggrab_mod_ext_class;
+extern const idclass_t epggrab_mod_ext_pyepg_class;
+extern const idclass_t epggrab_mod_ext_xmltv_class;
 extern const idclass_t epggrab_mod_ota_class;
 
 /* **************************************************************************