Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
IPTV: autonet - extract channel number from tvh-chnum m3u attribute, …
…fixes #3281
  • Loading branch information
perexg committed Nov 11, 2015
1 parent 4abfe79 commit bafa612
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
7 changes: 6 additions & 1 deletion src/input/mpegts/iptv/iptv_auto.c
Expand Up @@ -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;

Expand All @@ -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
Expand Down
5 changes: 1 addition & 4 deletions src/prop.c
Expand Up @@ -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;
Expand Down
8 changes: 8 additions & 0 deletions src/prop.h
Expand Up @@ -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__ */

/******************************************************************************
Expand Down

0 comments on commit bafa612

Please sign in to comment.