]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
xmltv: Optionally disable mapping category to genre. (#3753).
authorE.Smith <31170571+azlm8t@users.noreply.github.com>
Mon, 20 Nov 2017 22:36:43 +0000 (22:36 +0000)
committerJaroslav Kysela <perex@perex.cz>
Mon, 18 Dec 2017 08:41:06 +0000 (09:41 +0100)
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
src/epggrab/module/xmltv.c

index 768bce2350ea4128207122df84260e78c88bb3a1..a7e6a0c5084908e5d77ad5dadc2d16782e8ecd6e 100644 (file)
@@ -199,6 +199,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 );
index 7290f3a936eea02b785ae38b1c3d6186868eac31..ff421dd36c019003b3d66a941c4285c00619c4e2 100644 (file)
@@ -607,6 +607,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;
@@ -752,7 +753,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);
     }
@@ -1013,6 +1014,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 )
 {
@@ -1055,6 +1066,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
+    },
     {}
   }
 };
@@ -1089,6 +1108,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
+    },
     {}
   }
 };