Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
IPTV: autonet - import custom HTTP headers from m3u, fixes #3219
  • Loading branch information
perexg committed Oct 29, 2015
1 parent ea20a7c commit 8b62585
Showing 1 changed file with 28 additions and 2 deletions.
30 changes: 28 additions & 2 deletions src/input/mpegts/iptv/iptv_auto.c
Expand Up @@ -106,8 +106,8 @@ iptv_auto_network_process_m3u_item(iptv_network_t *in,
http_arg_list_t args;
http_arg_t *ra1, *ra2, *ra2_next;
htsbuf_queue_t q;
size_t l = 0;
char url2[512], name2[128], buf[32], *n, *x = NULL;
size_t l;
char url2[512], custom[512], name2[128], buf[32], *n, *x = NULL, *y;

if (url == NULL ||
(strncmp(url, "file://", 7) &&
Expand All @@ -128,10 +128,27 @@ iptv_auto_network_process_m3u_item(iptv_network_t *in,
}

urlinit(&u);
custom[0] = '\0';

if (strncmp(url, "pipe://", 7) == 0)
goto skip_url;

if (strncmp(url, "http://", 7) == 0 ||
strncmp(url, "https://", 8) == 0) {
url = n = strdupa(url);
while (*n && *n != ' ' && *n != '|') n++;
if (*n) { *n = '\0'; n++; }
l = 0;
while (*n) {
while (*n && *n <= ' ') n++;
y = n;
while (*n && *n != ' ' && *n != '|') n++;
if (*n) { *n = '\0'; n++; }
if (*y)
tvh_strlcatf(custom, sizeof(custom), l, "%s\n", y);
}
}

if (urlparse(url, &u))
return;
if (u.host == NULL || u.host[0] == '\0')
Expand Down Expand Up @@ -163,6 +180,7 @@ iptv_auto_network_process_m3u_item(iptv_network_t *in,
htsbuf_queue_flush(&q);
}
http_arg_flush(&args);
l = 0;
tvh_strlcatf(url2, sizeof(url2), l, "%s://", u.scheme);
if (u.user && u.user[0] && u.pass && u.pass[0])
tvh_strlcatf(url2, sizeof(url2), l, "%s:%s@", u.user, u.pass);
Expand All @@ -176,6 +194,7 @@ iptv_auto_network_process_m3u_item(iptv_network_t *in,
}

skip_url:
x = NULL;
if (last_url) {
if (charset_id) {
x = intlconv_to_utf8safestr(charset_id, name, strlen(name)*2);
Expand Down Expand Up @@ -211,6 +230,11 @@ iptv_auto_network_process_m3u_item(iptv_network_t *in,
change = 1;
}
change |= replace_string(&im->mm_iptv_epgid, epgid, charset_id);
if (strcmp(im->mm_iptv_hdr ?: "", custom)) {
free(im->mm_iptv_hdr);
im->mm_iptv_hdr = strdup(custom);
change = 1;
}
if (change)
idnode_notify_changed(&im->mm_id);
(*total)++;
Expand All @@ -236,6 +260,8 @@ iptv_auto_network_process_m3u_item(iptv_network_t *in,
htsmsg_add_str(conf, "iptv_epgid", epgid);
if (!in->in_scan_create)
htsmsg_add_s32(conf, "scan_result", MM_SCAN_OK);
if (custom[0])
htsmsg_add_str(conf, "iptv_hdr", custom);
im = iptv_mux_create0(in, NULL, conf);
htsmsg_destroy(conf);

Expand Down

0 comments on commit 8b62585

Please sign in to comment.