From: Jaroslav Kysela Date: Thu, 29 Oct 2015 16:56:02 +0000 (+0100) Subject: IPTV: autonet - import custom HTTP headers from m3u, fixes #3219 X-Git-Tag: v4.2.1~1740 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=8b625855507f95708480509c8ccd107f3249efce;p=thirdparty%2Ftvheadend.git IPTV: autonet - import custom HTTP headers from m3u, fixes #3219 --- diff --git a/src/input/mpegts/iptv/iptv_auto.c b/src/input/mpegts/iptv/iptv_auto.c index 89024eafc..d688b7457 100644 --- a/src/input/mpegts/iptv/iptv_auto.c +++ b/src/input/mpegts/iptv/iptv_auto.c @@ -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) && @@ -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') @@ -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); @@ -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); @@ -211,6 +230,11 @@ skip_url: 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)++; @@ -236,6 +260,8 @@ skip_url: 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);