From: Jaroslav Kysela Date: Tue, 20 Mar 2018 08:59:40 +0000 (+0100) Subject: m3u playlist: add tvg-chnum attribute with the channel number, fixes #5011 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=35c83be2fc8cdded8f65cc31be26edba36a6d627;p=thirdparty%2Ftvheadend.git m3u playlist: add tvg-chnum attribute with the channel number, fixes #5011 --- diff --git a/src/channels.c b/src/channels.c index 0209f3b6d..1c2c55239 100644 --- a/src/channels.c +++ b/src/channels.c @@ -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 ) { diff --git a/src/channels.h b/src/channels.h index 5d95ee4af..4ac2a2388 100644 --- a/src/channels.h +++ b/src/channels.h @@ -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 ); diff --git a/src/input/mpegts/iptv/iptv_auto.c b/src/input/mpegts/iptv/iptv_auto.c index 11b4a8ffd..509819a06 100644 --- a/src/input/mpegts/iptv/iptv_auto.c +++ b/src/input/mpegts/iptv/iptv_auto.c @@ -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); diff --git a/src/webui/webui.c b/src/webui/webui.c index a71a24997..cccc49e01 100644 --- a/src/webui/webui.c +++ b/src/webui/webui.c @@ -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);