From e1a44b80ab583b8d5c6292a25e150e6da3c8eb5d Mon Sep 17 00:00:00 2001 From: "E.Smith" <31170571+azlm8t@users.noreply.github.com> Date: Mon, 20 Nov 2017 22:36:43 +0000 Subject: [PATCH] xmltv: Optionally disable mapping category to genre. (#3753). Allow user to disable mapping from xmltv to genre. The mapping is imprecise and often has numerous categories not mapped. By not mapping to genres, some GUIs can pass through the category instead. Issue: #3753. --- src/epggrab.h | 1 + src/epggrab/module/xmltv.c | 29 ++++++++++++++++++++++++++++- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/src/epggrab.h b/src/epggrab.h index 7944794a4..9a0842e58 100644 --- a/src/epggrab.h +++ b/src/epggrab.h @@ -182,6 +182,7 @@ struct epggrab_module_int int xmltv_scrape_extra; ///< Scrape actors and extra details int xmltv_scrape_onto_desc; ///< Include scraped actors ///< and extra details on to programme description for viewing by legacy clients. + int xmltv_use_category_not_genre; ///< Use category tags and don't map to DVB genres. /* Handle data */ char* (*grab) ( void *mod ); diff --git a/src/epggrab/module/xmltv.c b/src/epggrab/module/xmltv.c index f02b6c1ea..1037cb6ba 100644 --- a/src/epggrab/module/xmltv.c +++ b/src/epggrab/module/xmltv.c @@ -599,6 +599,7 @@ static int _xmltv_parse_programme_tags { const int scrape_extra = ((epggrab_module_ext_t *)mod)->xmltv_scrape_extra; const int scrape_onto_desc = ((epggrab_module_ext_t *)mod)->xmltv_scrape_onto_desc; + const int use_category_not_genre = ((epggrab_module_int_t *)mod)->xmltv_use_category_not_genre; int save = 0, save2 = 0, save3 = 0; epg_episode_t *ee = NULL; epg_serieslink_t *es = NULL; @@ -742,7 +743,7 @@ static int _xmltv_parse_programme_tags if (subtitle) save3 |= epg_episode_set_subtitle(ee, subtitle, &changes3); - if ((egl = _xmltv_parse_categories(tags))) { + if (!use_category_not_genre && (egl = _xmltv_parse_categories(tags))) { save3 |= epg_episode_set_genre(ee, egl, &changes3); epg_genre_list_destroy(egl); } @@ -1003,6 +1004,16 @@ static int _xmltv_parse "You should not enable this if you use 'duplicate detect if different description' " \ "since the descriptions will change due to added information.") +#define USE_CATEGORY_NOT_GENRE_NAME N_("Use category instead of genre") +#define USE_CATEGORY_NOT_GENRE_DESC \ + N_("Some xmltv providers supply multiple category tags, however mapping "\ + "to genres is imprecise and many categories have no genre mapping "\ + "at all. Some frontends will only pass through categories " \ + "unchanged if there is no genre so for these we can " \ + "avoid the genre mappings and only use categories. " \ + "If this option is not ticked then we continue to map " \ + "xmltv categories to genres and supply both to clients.") + static htsmsg_t * xmltv_dn_chnum_list ( void *o, const char *lang ) { @@ -1045,6 +1056,14 @@ const idclass_t epggrab_mod_int_xmltv_class = { .off = offsetof(epggrab_module_int_t, xmltv_scrape_onto_desc), .group = 1 }, + { + .type = PT_BOOL, + .id = "use_category_not_genre", + .name = USE_CATEGORY_NOT_GENRE_NAME, + .desc = USE_CATEGORY_NOT_GENRE_DESC, + .off = offsetof(epggrab_module_int_t, xmltv_use_category_not_genre), + .group = 1 + }, {} } }; @@ -1079,6 +1098,14 @@ const idclass_t epggrab_mod_ext_xmltv_class = { .off = offsetof(epggrab_module_int_t, xmltv_scrape_onto_desc), .group = 1 }, + { + .type = PT_BOOL, + .id = "use_category_not_genre", + .name = USE_CATEGORY_NOT_GENRE_NAME, + .desc = USE_CATEGORY_NOT_GENRE_DESC, + .off = offsetof(epggrab_module_int_t, xmltv_use_category_not_genre), + .group = 1 + }, {} } }; base-commit: eaa7bf56b293f0a861d6c317632f09da0ff47a9e -- 2.14.1