From: E.Smith <31170571+azlm8t@users.noreply.github.com> Date: Wed, 6 Sep 2017 11:59:50 +0000 (+0100) Subject: eit: Allow scraper configuration file to be configured at the GUI (#4287). X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=72d087fe3d05a228fbbbba249cadbf28c766a2d1;p=thirdparty%2Ftvheadend.git eit: Allow scraper configuration file to be configured at the GUI (#4287). 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 --- diff --git a/data/conf/epggrab/eit/fixup/uk b/data/conf/epggrab/eit/scrape/uk similarity index 100% rename from data/conf/epggrab/eit/fixup/uk rename to data/conf/epggrab/eit/scrape/uk diff --git a/src/epggrab.h b/src/epggrab.h index d9e9602fd..fb08cd9e7 100644 --- a/src/epggrab.h +++ b/src/epggrab.h @@ -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 }; diff --git a/src/epggrab/module.c b/src/epggrab/module.c index f8bc015e9..01f087aca 100644 --- a/src/epggrab/module.c +++ b/src/epggrab/module.c @@ -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, }, {} } diff --git a/src/epggrab/module/eit.c b/src/epggrab/module/eit.c index e9b6fb8f8..7f7a33797 100644 --- a/src/epggrab/module/eit.c +++ b/src/epggrab/module/eit.c @@ -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)