@warren-bank/hls-proxy 3.6.1 → 3.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/hls-proxy/manifest_parser.js +26 -12
- package/package.json +1 -1
|
@@ -118,15 +118,16 @@ const parse_manifest = function(m3u8_content, m3u8_url, referer_url, querystring
|
|
|
118
118
|
|
|
119
119
|
const meta_data = {}
|
|
120
120
|
const embedded_urls = extract_embedded_urls(m3u8_lines, m3u8_url, referer_url, (cache_segments ? meta_data : null))
|
|
121
|
-
const qs_headers = !!querystring_req_headers ? utils.base64_encode(JSON.stringify(querystring_req_headers)) : null
|
|
122
121
|
const prefetch_urls = []
|
|
123
122
|
|
|
124
123
|
if (embedded_urls && Array.isArray(embedded_urls) && embedded_urls.length) {
|
|
124
|
+
const querystring = get_querystring(querystring_req_headers, qs_password)
|
|
125
|
+
|
|
125
126
|
embedded_urls.forEach(embedded_url => {
|
|
126
127
|
redirect_embedded_url(embedded_url, hooks, m3u8_url, debug)
|
|
127
128
|
if (validate_embedded_url(embedded_url)) {
|
|
128
129
|
finalize_embedded_url(embedded_url, vod_start_at_ms, debug)
|
|
129
|
-
encode_embedded_url(embedded_url, hooks, redirected_base_url, debug, manifest_extension, segment_extension,
|
|
130
|
+
encode_embedded_url(embedded_url, hooks, redirected_base_url, debug, manifest_extension, segment_extension, querystring)
|
|
130
131
|
get_prefetch_url(embedded_url, should_prefetch_url, prefetch_urls)
|
|
131
132
|
modify_m3u8_line(embedded_url, m3u8_lines)
|
|
132
133
|
}
|
|
@@ -234,6 +235,26 @@ const extract_meta_data = function(meta_data, m3u8_line, matching_landmark) {
|
|
|
234
235
|
}
|
|
235
236
|
}
|
|
236
237
|
|
|
238
|
+
const get_querystring = function(querystring_req_headers, qs_password) {
|
|
239
|
+
const qs_headers = !!querystring_req_headers ? utils.base64_encode(JSON.stringify(querystring_req_headers)) : null
|
|
240
|
+
let qs_pairs = []
|
|
241
|
+
let querystring = ''
|
|
242
|
+
|
|
243
|
+
if (qs_headers)
|
|
244
|
+
qs_pairs.push(['headers', qs_headers])
|
|
245
|
+
|
|
246
|
+
if (qs_password)
|
|
247
|
+
qs_pairs.push(['password', qs_password])
|
|
248
|
+
|
|
249
|
+
if (qs_pairs.length) {
|
|
250
|
+
qs_pairs = qs_pairs.map(pair => `${pair[0]}=${encodeURIComponent(pair[1])}`)
|
|
251
|
+
|
|
252
|
+
querystring = '?' + qs_pairs.join('&')
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
return querystring
|
|
256
|
+
}
|
|
257
|
+
|
|
237
258
|
const redirect_embedded_url = function(embedded_url, hooks, m3u8_url, debug) {
|
|
238
259
|
if (hooks && (hooks instanceof Object) && hooks.redirect && (typeof hooks.redirect === 'function')) {
|
|
239
260
|
let url, url_type, referer_url, result
|
|
@@ -333,7 +354,7 @@ const finalize_embedded_url = function(embedded_url, vod_start_at_ms, debug) {
|
|
|
333
354
|
}
|
|
334
355
|
}
|
|
335
356
|
|
|
336
|
-
const encode_embedded_url = function(embedded_url, hooks, redirected_base_url, debug, manifest_extension, segment_extension,
|
|
357
|
+
const encode_embedded_url = function(embedded_url, hooks, redirected_base_url, debug, manifest_extension, segment_extension, querystring) {
|
|
337
358
|
if (embedded_url.unencoded_url) {
|
|
338
359
|
let file_extension = embedded_url.url_type
|
|
339
360
|
if (file_extension) {
|
|
@@ -353,15 +374,8 @@ const encode_embedded_url = function(embedded_url, hooks, redirected_base_url, d
|
|
|
353
374
|
debug(3, 'redirecting (proxied, post-hook):', embedded_url.encoded_url)
|
|
354
375
|
}
|
|
355
376
|
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
qs_pairs.push(['headers', qs_headers])
|
|
359
|
-
if (qs_password)
|
|
360
|
-
qs_pairs.push(['password', qs_password])
|
|
361
|
-
if (qs_pairs.length) {
|
|
362
|
-
qs_pairs = qs_pairs.map(pair => `${pair[0]}=${encodeURIComponent(pair[1])}`)
|
|
363
|
-
|
|
364
|
-
embedded_url.encoded_url += '?' + qs_pairs.join('&')
|
|
377
|
+
if (querystring) {
|
|
378
|
+
embedded_url.encoded_url += querystring
|
|
365
379
|
debug(3, 'redirecting (proxied, with querystring):', embedded_url.encoded_url)
|
|
366
380
|
}
|
|
367
381
|
}
|
package/package.json
CHANGED