]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
m3u playlist: add tvg-chnum attribute with the channel number, fixes #5011
authorJaroslav Kysela <perex@perex.cz>
Tue, 20 Mar 2018 08:59:40 +0000 (09:59 +0100)
committerJaroslav Kysela <perex@perex.cz>
Tue, 20 Mar 2018 09:00:17 +0000 (10:00 +0100)
src/channels.c
src/channels.h
src/input/mpegts/iptv/iptv_auto.c
src/webui/webui.c

index 0209f3b6d4964732d3110662398558695bc144fd..1c2c55239751caec3d88d12a8172bed77eb405d0 100644 (file)
@@ -935,6 +935,27 @@ channel_set_number ( channel_t *ch, uint32_t major, uint32_t minor )
   return save;
 }
 
+char *
+channel_get_number_as_str ( channel_t *ch, char *dst, size_t dstlen )
+{
+  int64_t num = channel_get_number(ch);
+  uint32_t major, minor;
+  if (num == 0) return NULL;
+  major = channel_get_major(num);
+  minor = channel_get_minor(num);
+  if (minor)
+    snprintf(dst, dstlen, "%u.%u", major, minor);
+  else
+    snprintf(dst, dstlen, "%u", major);
+  return dst;
+}
+
+int64_t
+channel_get_number_from_str ( const char *str )
+{
+  return prop_intsplit_from_str(str, CHANNEL_SPLIT);
+}
+
 char *
 channel_get_source ( channel_t *ch, char *dst, size_t dstlen )
 {
index 5d95ee4af3fbae28487034bbb8b075019cc410cd..4ac2a23889d54833d444b4dd286d72c3255e10d2 100644 (file)
@@ -200,6 +200,9 @@ static inline uint32_t channel_get_minor ( int64_t chnum ) { return chnum % CHAN
 int64_t channel_get_number ( channel_t *ch );
 int channel_set_number ( channel_t *ch, uint32_t major, uint32_t minor );
 
+char *channel_get_number_as_str ( channel_t *ch, char *dst, size_t dstlen );
+int64_t channel_get_number_from_str ( const char *str );
+
 char *channel_get_source ( channel_t *ch, char *dst, size_t dstlen );
 
 const char *channel_get_icon ( channel_t *ch );
index 11b4a8ffd0921a3b7f4987b393bdd9f756afe62c..509819a06e027187a468bbcb9bdd0526ad4fd1e9 100644 (file)
@@ -102,7 +102,8 @@ iptv_auto_network_process_m3u_item(iptv_network_t *in,
     return;
 
   epgid = htsmsg_get_str(item, "tvh-chnum");
-  chnum2 = epgid ? prop_intsplit_from_str(epgid, CHANNEL_SPLIT) : 0;
+  if (!epgid) epgid = htsmsg_get_str(item, "tvg-chno");
+  chnum2 = epgid ? channel_get_number_from_str(epgid) : 0;
 
   muxprio = htsmsg_get_s32_or_default(item, "tvh-prio", -1);
   smuxprio = htsmsg_get_s32_or_default(item, "tvh-sprio", -1);
index a71a249972cd63cbc0558ca6f823cf43a2e7db13..cccc49e01608c74a2fcfb243e21220cd2de2f7c0 100644 (file)
@@ -487,8 +487,8 @@ http_stream_run(http_connection_t *hc, profile_chain_t *prch,
 static void
 http_m3u_playlist_add(htsbuf_queue_t *hq, const char *hostpath,
                       const char *url_remain, const char *profile,
-                      const char *svcname, const char *logo,
-                      const char *epgid, access_t *access)
+                      const char *svcname, const char *chnum,
+                      const char *logo, const char *epgid, access_t *access)
 {
   htsbuf_append_str(hq, "#EXTINF:-1");
   if (logo) {
@@ -499,6 +499,8 @@ http_m3u_playlist_add(htsbuf_queue_t *hq, const char *hostpath,
   }
   if (epgid)
     htsbuf_qprintf(hq, " tvg-id=\"%s\"", epgid);
+  if (chnum)
+    htsbuf_qprintf(hq, " tvg-chno=\"%s\"", chnum);
   htsbuf_qprintf(hq, ",%s\n%s%s?ticket=%s", svcname, hostpath, url_remain,
                      access_ticket_create(url_remain, access));
   htsbuf_qprintf(hq, "&profile=%s\n", profile);
@@ -561,7 +563,7 @@ static int
 http_channel_playlist(http_connection_t *hc, int pltype, channel_t *channel)
 {
   htsbuf_queue_t *hq;
-  char buf[255];
+  char buf[255], chnum[32];
   char *profile, *hostpath;
   const char *name, *blank;
   const char *lang = hc->hc_access->aa_lang_ui;
@@ -584,6 +586,7 @@ http_channel_playlist(http_connection_t *hc, int pltype, channel_t *channel)
 
     htsbuf_append_str(hq, "#EXTM3U\n");
     http_m3u_playlist_add(hq, hostpath, buf, profile, name,
+                          channel_get_number_as_str(channel, chnum, sizeof(chnum)),
                           channel_get_icon(channel),
                           channel_get_uuid(channel, ubuf),
                           hc->hc_access);
@@ -612,7 +615,7 @@ static int
 http_tag_playlist(http_connection_t *hc, int pltype, channel_tag_t *tag)
 {
   htsbuf_queue_t *hq;
-  char buf[255], ubuf[UUID_HEX_SIZE];
+  char buf[255], chnum[32], ubuf[UUID_HEX_SIZE];
   char *profile, *hostpath;
   const char *name, *blank, *sort, *lang;
   channel_t *ch;
@@ -643,6 +646,7 @@ http_tag_playlist(http_connection_t *hc, int pltype, channel_tag_t *tag)
     name = channel_get_name(ch, blank);
     if (pltype == PLAYLIST_M3U) {
       http_m3u_playlist_add(hq, hostpath, buf, profile, name,
+                            channel_get_number_as_str(ch, chnum, sizeof(chnum)),
                             channel_get_icon(ch),
                             channel_get_uuid(ch, ubuf),
                             hc->hc_access);
@@ -703,7 +707,7 @@ http_tag_list_playlist(http_connection_t *hc, int pltype)
     ct = ctlist[idx];
     if (pltype == PLAYLIST_M3U) {
       snprintf(buf, sizeof(buf), "/playlist/tagid/%d", idnode_get_short_uuid(&ct->ct_id));
-      http_m3u_playlist_add(hq, hostpath, buf, profile, ct->ct_name,
+      http_m3u_playlist_add(hq, hostpath, buf, profile, ct->ct_name, NULL,
                             channel_tag_get_icon(ct), NULL, hc->hc_access);
     } else if (pltype == PLAYLIST_E2) {
       htsbuf_qprintf(hq, "#SERVICE 1:64:%d:0:0:0:0:0:0:0::%s\n", labelidx++, ct->ct_name);
@@ -743,7 +747,7 @@ static int
 http_channel_list_playlist(http_connection_t *hc, int pltype)
 {
   htsbuf_queue_t *hq;
-  char buf[255], ubuf[UUID_HEX_SIZE];
+  char buf[255], chnum[32], ubuf[UUID_HEX_SIZE];
   channel_t *ch;
   channel_t **chlist;
   int idx = 0, count = 0;
@@ -775,6 +779,7 @@ http_channel_list_playlist(http_connection_t *hc, int pltype)
 
     if (pltype == PLAYLIST_M3U) {
       http_m3u_playlist_add(hq, hostpath, buf, profile, name,
+                            channel_get_number_as_str(ch, chnum, sizeof(chnum)),
                             channel_get_icon(ch),
                             channel_get_uuid(ch, ubuf),
                             hc->hc_access);