]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
IPTV: Add extra channels tags to IPTV mux config, m3u attribute tvh-tags
authorJaroslav Kysela <perex@perex.cz>
Thu, 12 Nov 2015 13:29:57 +0000 (14:29 +0100)
committerJaroslav Kysela <perex@perex.cz>
Thu, 12 Nov 2015 13:29:57 +0000 (14:29 +0100)
src/input/mpegts/iptv/iptv_auto.c
src/input/mpegts/iptv/iptv_mux.c
src/input/mpegts/iptv/iptv_private.h
src/input/mpegts/iptv/iptv_service.c
src/service.h
src/service_mapper.c

index 4f4370ef54af0b5554b9c987624700f29d9ea55c..7f1b5a9a545a319638e5a0de67ccba628de72d3e 100644 (file)
@@ -54,7 +54,7 @@ iptv_auto_network_process_m3u_item(iptv_network_t *in,
   int delim;
   size_t l;
   int64_t chnum2;
-  const char *url, *name, *logo, *epgid;
+  const char *url, *name, *logo, *epgid, *tags;
   char url2[512], custom[512], name2[128], buf[32], *n, *y;
 
   url = htsmsg_get_str(item, "m3u-url");
@@ -90,6 +90,15 @@ iptv_auto_network_process_m3u_item(iptv_network_t *in,
     logo = htsmsg_get_str(item, "logo");
 
   epgid = htsmsg_get_str(item, "tvg-id");
+  tags  = htsmsg_get_str(item, "tvh-tags");
+  if (tags) {
+    tags = n = strdupa(tags);
+    while (*n) {
+      if (*n == '|')
+        *n = '\n';
+      n++;
+    }
+  }
 
   urlinit(&u);
   custom[0] = '\0';
@@ -199,6 +208,11 @@ skip_url:
         im->mm_iptv_hdr = strdup(custom);
         change = 1;
       }
+      if (strcmp(im->mm_iptv_tags ?: "", tags ?: "")) {
+        free(im->mm_iptv_tags);
+        im->mm_iptv_tags = strdup(tags);
+        change = 1;
+      }
       if (change)
         idnode_notify_changed(&im->mm_id);
       (*total)++;
@@ -222,6 +236,8 @@ skip_url:
     htsmsg_add_str(conf, "iptv_icon", logo);
   if (epgid)
     htsmsg_add_str(conf, "iptv_epgid", epgid);
+  if (tags)
+    htsmsg_add_str(conf, "iptv_tags", tags);
   if (!in->in_scan_create)
     htsmsg_add_s32(conf, "scan_result", MM_SCAN_OK);
   if (custom[0])
index 49bb00cc4c64658bc79f263b3f169b3cdf0c9be3..432a5f7b16e2eceb9d591c678afd0f1a2e0a9a20 100644 (file)
@@ -224,6 +224,13 @@ const idclass_t iptv_mux_class =
       .off      = offsetof(iptv_mux_t, mm_iptv_hdr),
       .opts     = PO_ADVANCED | PO_MULTILINE
     },
+    {
+      .type     = PT_STR,
+      .id       = "iptv_tags",
+      .name     = N_("Channel tags"),
+      .off      = offsetof(iptv_mux_t, mm_iptv_tags),
+      .opts     = PO_ADVANCED | PO_MULTILINE
+    },
     {}
   }
 };
@@ -260,6 +267,7 @@ iptv_mux_delete ( mpegts_mux_t *mm, int delconf )
   free(im->mm_iptv_svcname);
   free(im->mm_iptv_env);
   free(im->mm_iptv_hdr);
+  free(im->mm_iptv_tags);
   free(im->mm_iptv_icon);
   free(im->mm_iptv_epgid);
   mpegts_mux_delete(mm, delconf);
index 77253473d788426e9b67da325415fa7006f39cca..0343e04a8d011d87d53a796ec389554fa7512134 100644 (file)
@@ -131,6 +131,7 @@ struct iptv_mux
   int                   mm_iptv_kill_timeout;
   char                 *mm_iptv_env;
   char                 *mm_iptv_hdr;
+  char                 *mm_iptv_tags;
 
   uint32_t              mm_iptv_rtp_seq;
 
index 2d2b3762a3d12eb3125edb0cb3d7b491ab850529..a09db9dab3617ec3341d925f15178cfd5fe67995 100644 (file)
@@ -108,6 +108,27 @@ iptv_service_channel_epgid ( service_t *s )
   return im->mm_iptv_epgid;
 }
 
+static htsmsg_t *
+iptv_service_channel_tags ( service_t *s )
+{
+  iptv_service_t   *is = (iptv_service_t *)s;
+  iptv_mux_t       *im = (iptv_mux_t *)is->s_dvb_mux;
+  char             *p = im->mm_iptv_tags, *x;
+  htsmsg_t         *r = NULL;
+  if (p) {
+    r = htsmsg_create_list();
+    while (*p) {
+      while (*p && *p <= ' ') p++;
+      x = p;
+      while (*p && *p >= ' ') p++;
+      if (*p) { *p = '\0'; p++; }
+      if (*x)
+        htsmsg_add_str(r, NULL, x);
+    }
+  }
+  return r;
+}
+
 /*
  * Create
  */
@@ -128,6 +149,7 @@ iptv_service_create0
   is->s_channel_number = iptv_service_channel_number;
   is->s_channel_icon   = iptv_service_channel_icon;
   is->s_channel_epgid  = iptv_service_channel_epgid;
+  is->s_channel_tags   = iptv_service_channel_tags;
 
   /* Set default service name */
   if (!is->s_dvb_svcname || !*is->s_dvb_svcname)
index 738af0a554d4f8967195a50019d086d18a1ad19b..c4612a93b30b47cf0c8fb550cec08969917deba5 100644 (file)
@@ -320,6 +320,7 @@ typedef struct service {
   int64_t     (*s_channel_number) (struct service *);
   const char *(*s_channel_name)   (struct service *);
   const char *(*s_channel_epgid)  (struct service *);
+  htsmsg_t   *(*s_channel_tags)   (struct service *);
   const char *(*s_provider_name)  (struct service *);
   const char *(*s_channel_icon)   (struct service *);
   void        (*s_mapped)         (struct service *);
index acfb6ab1cf41d94835a9bc9a51588ffc13dbeb5d..23a98ba303d0e1281207187a3e77b55183f154e9 100644 (file)
@@ -209,7 +209,9 @@ channel_t *
 service_mapper_process ( service_t *s, bouquet_t *bq )
 {
   channel_t *chn = NULL;
-  const char *name;
+  const char *name, *tagname;
+  htsmsg_field_t *f;
+  htsmsg_t *m;
 
   /* Ignore */
   if (s->s_status == SERVICE_ZOMBIE) {
@@ -249,6 +251,12 @@ service_mapper_process ( service_t *s, bouquet_t *bq )
       channel_tag_map(channel_tag_find_by_name("Radio", 1), chn, chn);
     }
 
+    /* Custom tags */
+    if (s->s_channel_tags && (m = s->s_channel_tags(s)) != NULL)
+      HTSMSG_FOREACH(f, m)
+        if ((tagname = htsmsg_field_get_str(f)) != NULL)
+          channel_tag_map(channel_tag_find_by_name(tagname, 1), chn, chn);
+
     /* Provider */
     if (service_mapper_conf.provider_tags)
       if ((prov = s->s_provider_name(s)))