From: Jaroslav Kysela Date: Wed, 11 Nov 2015 19:56:08 +0000 (+0100) Subject: IPTV: autonet - extract channel number from tvh-chnum m3u attribute, fixes #3281 X-Git-Tag: v4.2.1~1571 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=bafa61277c3a5ba7178bca05a2e2f702a013b246;p=thirdparty%2Ftvheadend.git IPTV: autonet - extract channel number from tvh-chnum m3u attribute, fixes #3281 --- diff --git a/src/input/mpegts/iptv/iptv_auto.c b/src/input/mpegts/iptv/iptv_auto.c index ff86d7992..a62001d56 100644 --- a/src/input/mpegts/iptv/iptv_auto.c +++ b/src/input/mpegts/iptv/iptv_auto.c @@ -53,6 +53,7 @@ iptv_auto_network_process_m3u_item(iptv_network_t *in, htsbuf_queue_t q; int delim; size_t l; + int64_t chnum2; const char *url, *name, *logo, *epgid; char url2[512], custom[512], name2[128], buf[32], *n, *y; @@ -69,7 +70,11 @@ iptv_auto_network_process_m3u_item(iptv_network_t *in, strncmp(url, "rtp://", 6))) return; - if (chnum) { + epgid = htsmsg_get_str(item, "tvh-chnum"); + chnum2 = epgid ? prop_intsplit_from_str(epgid, CHANNEL_SPLIT) : 0; + if (chnum2) { + chnum += chnum2; + } else if (chnum) { if (chnum % CHANNEL_SPLIT) chnum += *total; else diff --git a/src/prop.c b/src/prop.c index aceb7500e..60fc309da 100644 --- a/src/prop.c +++ b/src/prop.c @@ -155,12 +155,9 @@ prop_write_values } case PT_S64: { if (p->intsplit) { - char *s; if (!(new = htsmsg_field_get_str(f))) continue; - s64 = (int64_t)atol(new) * p->intsplit; - if ((s = strchr(new, '.')) != NULL) - s64 += (atol(s + 1) % p->intsplit); + s64 = prop_intsplit_from_str(new, p->intsplit); } else { if (htsmsg_field_get_s64(f, &s64)) continue; diff --git a/src/prop.h b/src/prop.h index bd44b94ba..3c9ba7a5f 100644 --- a/src/prop.h +++ b/src/prop.h @@ -119,6 +119,14 @@ void prop_serialize (void *obj, const property_t *pl, htsmsg_t *m, htsmsg_t *list, int optmask, const char *lang); +static inline int64_t prop_intsplit_from_str(const char *s, int64_t intsplit) +{ + int64_t s64 = (int64_t)atol(s) * intsplit; + if ((s = strchr(s, '.')) != NULL) + s64 += (atol(s + 1) % intsplit); + return s64; +} + #endif /* __TVH_PROP_H__ */ /******************************************************************************