]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
eit: Allow scraper configuration file to be configured at the GUI (#4287).
authorE.Smith <31170571+azlm8t@users.noreply.github.com>
Wed, 6 Sep 2017 11:59:50 +0000 (12:59 +0100)
committerJaroslav Kysela <perex@perex.cz>
Fri, 8 Sep 2017 06:29:45 +0000 (08:29 +0200)
Previously the scraper was hard-coded based on the module name.
So "uk_freeview" module would check "uk_freeview" configuration file
and then the "uk" file.

However, this meant that the generic "eit" module (used by several
countries) had to be symlinked by the user to a specific configuration
for their country.

With this change, the user can simply enter "uk" in the GUI to read
that configuration.j

Also renamed "fixup" to be called "scrape" since we are scraping
data from the EIT rather than fixing it.

Issue: #4287

data/conf/epggrab/eit/scrape/uk [moved from data/conf/epggrab/eit/fixup/uk with 100% similarity]
src/epggrab.h
src/epggrab/module.c
src/epggrab/module/eit.c

index d9e9602fd6fcf42b96b757e0b46209a8e299c7cc..fb08cd9e7f151f286553bce9ea83e50dea1f8bbd 100644 (file)
@@ -267,6 +267,7 @@ struct epggrab_module_ota
 struct epggrab_module_ota_scraper
 {
   epggrab_module_ota_t             ;      ///< Parent object
+  char                   *scrape_config;  ///< Config to use or blank/NULL for default.
   int                     scrape_episode; ///< Scrape season/episode from EIT summary
 };
 
index f8bc015e9cd2a0002c10a046b571453f5ffb5d1c..01f087aca02394629fb3d4b7847abb3e1f2cfd85 100644 (file)
@@ -225,14 +225,50 @@ const idclass_t epggrab_mod_ota_scraper_class = {
   .ic_super      = &epggrab_mod_ota_class,
   .ic_class      = "epggrab_mod_ota_scraper",
   .ic_caption    = N_("Over-the-air EPG grabber with scraping"),
+  .ic_groups     = (const property_group_t[]) {
+    {
+      .name      = N_("EPG behaviour"),
+      .number    = 1,
+    },
+    {
+      .name      = N_("Scrape behaviour"),
+      .number    = 2,
+    },
+    {}
+  },
   .ic_properties = (const property_t[]){
+    {
+      /* The "eit" grabber is used by a number of countries so
+       * we can't ship a config file named "eit" since regex use
+       * in the UK won't be the same as in Italy.
+       *
+       * So, this option allows the user to specify the configuration
+       * file to use from the ones that we do ship without them having
+       * to mess around in the filesystem copying files.
+       *
+       * For example they can simply specify "uk" to use its
+       * configuration file.
+       */
+      .type   = PT_STR,
+      .id     = "scrape_config",
+      .name   = N_("Scraper configuration to use"),
+      .desc   = N_("Configuration containing regular expressions to use for "
+                   "scraping information from the broadcast guide. "
+                   "This can be left blank to use the default or "
+                   "set to one of the Tvheadend configurations from the "
+                   "epggrab/eit/scrape directory such as "
+                   "\"uk\" (without the quotes)."
+                  ),
+      .off    = offsetof(epggrab_module_ota_scraper_t, scrape_config),
+      .group  = 2,
+    },
     {
       .type   = PT_BOOL,
       .id     = "scrape_episode",
       .name   = N_("Scrape Episode"),
       .desc   = N_("Enable/disable scraping episode from the grabber."),
       .off    = offsetof(epggrab_module_ota_scraper_t, scrape_episode),
-      .group  = 1,
+      .group  = 2,
     },
     {}
   }
index e9b6fb8f864de6a9df3d977d94fecaa52d2cff4f..7f7a337976e040c811ddb1fd27030683eafbcc8d 100644 (file)
@@ -960,7 +960,7 @@ static int _eit_tune
   return r;
 }
 
-static int _eit_fixup_load_one ( htsmsg_t *m, eit_module_t* mod )
+static int _eit_scrape_load_one ( htsmsg_t *m, eit_module_t* mod )
 {
     eit_pattern_compile_list(&mod->p_snum, htsmsg_get_list(m, "season_num"));
     eit_pattern_compile_list(&mod->p_enum, htsmsg_get_list(m, "episode_num"));
@@ -974,12 +974,16 @@ static void _eit_module_load_config(eit_module_t *mod)
     return;
   }
 
-  const char config_path[] = "epggrab/eit/fixup/%s";
-  const char *config_file = mod->id;
-
-  /* Attempt to load config file based on grabber id such as
-   * uk_freeview.
+  const char config_path[] = "epggrab/eit/scrape/%s";
+  /* Only use the user config if they have supplied one and it is not empty.
+   * Otherwise we default to using configuration based on the module
+   * name such as "uk_freeview".
    */
+  const char *config_file = mod->scrape_config && *mod->scrape_config ?
+    mod->scrape_config : mod->id;
+
+  tvhinfo(LS_TBL_EIT, "scraper %s attempt to load config \"%s\"", mod->id, config_file);
+
   htsmsg_t *m = hts_settings_load(config_path, config_file);
   char *generic_name = NULL;
   if (!m) {
@@ -988,7 +992,7 @@ static void _eit_module_load_config(eit_module_t *mod)
      * be "uk". This allows config for a country to be shared across
      * two grabbers such as DVB-T and DVB-S.
      */
-    generic_name = strdup(mod->id);
+    generic_name = strdup(config_file);
     if (generic_name) {
       char *underscore = strstr(generic_name, "_");
       if (underscore) {
@@ -1001,14 +1005,14 @@ static void _eit_module_load_config(eit_module_t *mod)
   }
 
   if (m) {
-    const int r = _eit_fixup_load_one(m, mod);
+    const int r = _eit_scrape_load_one(m, mod);
     if (r > 0)
-      tvhinfo(LS_TBL_EIT, "scraper %s loaded config %s", mod->id, config_file);
+      tvhinfo(LS_TBL_EIT, "scraper %s loaded config \"%s\"", mod->id, config_file);
     else
-      tvhwarn(LS_TBL_EIT, "scraper %s failed to load", mod->id);
+      tvhwarn(LS_TBL_EIT, "scraper %s failed to load config \"%s\"", mod->id, config_file);
     htsmsg_destroy(m);
   } else {
-      tvhinfo(LS_TBL_EIT, "no scraper config files loaded for %s", mod->id);
+      tvhinfo(LS_TBL_EIT, "scraper %s no scraper config files found", mod->id);
   }
 
   if (generic_name)