@warren-bank/hls-proxy 3.6.1 → 3.6.3

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/README.md CHANGED
@@ -1,4 +1,4 @@
1
- ### [_HLS Proxy_](https://github.com/warren-bank/HLS-Proxy) : HTTP Live Streaming Proxy
1
+ ### [_Node.js HLS Proxy_](https://github.com/warren-bank/node-HLS-Proxy) : HTTP Live Streaming Proxy for the [_Node JS_ Runtime](https://nodejs.org/)
2
2
 
3
3
  #### Basic Functionality:
4
4
 
@@ -175,7 +175,7 @@ options:
175
175
  * _--tls-key_
176
176
  * _--tls-pass_
177
177
  * the values assigned to these options enable the use of a self-signed security certificate that is included in both the git repo and npm package, within the directory:
178
- * [`./hls-proxy/servers/cert`](https://github.com/warren-bank/HLS-Proxy/tree/master/hls-proxy/servers/cert)
178
+ * [`./hls-proxy/servers/cert`](./hls-proxy/servers/cert/)
179
179
  * when all of these option are properly specified:
180
180
  * the `https:` protocol is used by all URLs in modified HLS manifests
181
181
  * _--host_ is an IP or hostname with an optional port number that can be resolved and is reachable by clients
@@ -445,7 +445,7 @@ options:
445
445
  #### How to: Install:
446
446
 
447
447
  ```bash
448
- git clone "https://github.com/warren-bank/HLS-Proxy.git"
448
+ git clone "https://github.com/warren-bank/node-HLS-Proxy.git"
449
449
  cd "HLS-Proxy"
450
450
  npm install
451
451
  ```
@@ -627,24 +627,24 @@ curl --silent --insecure "$URL"
627
627
  * usage test result:
628
628
  * [doesn't appear to work with HTML5 video players or Chromecast](https://github.com/streamlink/streamlink/issues/1704#issuecomment-413661578)
629
629
  * the server starts and works as it was intended, but something about the format of the data it "streams" is incompatible
630
- * [VLC](https://portableapps.com/apps/music_video/vlc_portable) can play the video stream from the server, and be used to [render the video on Chromecast](https://github.com/warren-bank/HLS-Proxy/blob/master/.related/.recipes/01.%20Streamlink/notes.txt)
630
+ * [VLC](https://portableapps.com/apps/music_video/vlc_portable) can play the video stream from the server, and be used to [render the video on Chromecast](./.related/.recipes/01.%20Streamlink/notes.txt)
631
631
 
632
632
  - - - -
633
633
 
634
634
  #### Major Versions:
635
635
 
636
636
  * `v1.x`
637
- - commit history is in branch: [`v01`](https://github.com/warren-bank/HLS-Proxy/commits/v01)
637
+ - commit history is in branch: [`v01`](https://github.com/warren-bank/node-HLS-Proxy/commits/v01)
638
638
  - summary:
639
639
  * m3u8 manifest parser uses regex patterns to identify all URL patterns without any special knowledge of the m3u8 manifest specification
640
640
  * internal `proxy` module exports a function that accepts an instance of [`http.Server`](https://nodejs.org/api/http.html#class-httpserver) and adds event listeners to process requests
641
641
  - system requirements:
642
642
  * Node.js version: v8.6.0 (and higher)
643
- - transitive [dependency](https://github.com/warren-bank/HLS-Proxy/blob/v1.0.1/package.json#L13-L14) requirements:
643
+ - transitive [dependency](https://github.com/warren-bank/node-HLS-Proxy/blob/v1.0.1/package.json#L13-L14) requirements:
644
644
  * v08.06.00+: [`@warren-bank/node-process-argv`](https://github.com/warren-bank/node-process-argv#requirements)
645
645
  * v08.06.00+: [`@warren-bank/node-request`](https://github.com/warren-bank/node-request#requirements)
646
646
  * `v2.x`
647
- - commit history is in branch: [`v02`](https://github.com/warren-bank/HLS-Proxy/commits/v02)
647
+ - commit history is in branch: [`v02`](https://github.com/warren-bank/node-HLS-Proxy/commits/v02)
648
648
  - summary:
649
649
  * m3u8 manifest parser uses regex patterns to identify all URL patterns without any special knowledge of the m3u8 manifest specification
650
650
  * internal `proxy` module exports an Object containing event listeners to process requests that can be either:
@@ -653,11 +653,11 @@ curl --silent --insecure "$URL"
653
653
  * important limitation: since `/` is a valid character in a base64 encoded URL, the path for a custom route needs to end with a character that is not allowed in base64 encoding (ex: `'/proxy_/*'`)
654
654
  - system requirements:
655
655
  * Node.js version: v8.6.0 (and higher)
656
- - transitive [dependency](https://github.com/warren-bank/HLS-Proxy/blob/v2.0.3/package.json#L13-L14) requirements:
656
+ - transitive [dependency](https://github.com/warren-bank/node-HLS-Proxy/blob/v2.0.3/package.json#L13-L14) requirements:
657
657
  * v08.06.00+: [`@warren-bank/node-process-argv`](https://github.com/warren-bank/node-process-argv#requirements)
658
658
  * v08.06.00+: [`@warren-bank/node-request`](https://github.com/warren-bank/node-request#requirements)
659
659
  * `v3.x`
660
- - commit history is in branch: [`v03`](https://github.com/warren-bank/HLS-Proxy/commits/v03)
660
+ - commit history is in branch: [`v03`](https://github.com/warren-bank/node-HLS-Proxy/commits/v03)
661
661
  - summary:
662
662
  * m3u8 manifest parser uses special knowledge of the m3u8 manifest specification to contextually identify URLs
663
663
  * internal `proxy` module exports an Object containing event listeners to process requests that can be either:
@@ -667,7 +667,7 @@ curl --silent --insecure "$URL"
667
667
  * the use of nested routers is supported
668
668
  - system requirements:
669
669
  * Node.js version: v8.6.0 (and higher)
670
- - transitive [dependency](https://github.com/warren-bank/HLS-Proxy/blob/v3.5.1/package.json#L13-L14) requirements:
670
+ - transitive [dependency](https://github.com/warren-bank/node-HLS-Proxy/blob/v3.5.1/package.json#L13-L14) requirements:
671
671
  * v08.06.00+: [`@warren-bank/node-process-argv`](https://github.com/warren-bank/node-process-argv#requirements)
672
672
  * v08.06.00+: [`@warren-bank/node-request`](https://github.com/warren-bank/node-request#requirements)
673
673
 
@@ -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, qs_headers, qs_password)
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, qs_headers, qs_password) {
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
- let qs_pairs = []
357
- if (qs_headers)
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
  }
@@ -5,7 +5,7 @@ const start_server = function({port}) {
5
5
 
6
6
  const server = http.createServer()
7
7
 
8
- server.listen(port, function () {
8
+ server.listen(port, '0.0.0.0', function () {
9
9
  console.log(`HTTP server is listening on port: ${port}`)
10
10
  })
11
11
 
@@ -18,7 +18,7 @@ const start_server = function({port, tls_cert, tls_key, tls_pass}) {
18
18
 
19
19
  const server = https.createServer(ssl_options)
20
20
 
21
- server.listen(port, function () {
21
+ server.listen(port, '0.0.0.0', function () {
22
22
  console.log(`HTTPS server is listening on port: ${port}`)
23
23
  })
24
24
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@warren-bank/hls-proxy",
3
3
  "description": "Node.js server to proxy HLS video streams",
4
- "version": "3.6.1",
4
+ "version": "3.6.3",
5
5
  "scripts": {
6
6
  "start": "node hls-proxy/bin/hlsd.js",
7
7
  "sudo": "sudo node hls-proxy/bin/hlsd.js"
@@ -23,12 +23,12 @@
23
23
  "email": "warren.r.bank@gmail.com",
24
24
  "url": "https://github.com/warren-bank"
25
25
  },
26
- "homepage": "https://github.com/warren-bank/HLS-Proxy",
26
+ "homepage": "https://github.com/warren-bank/node-HLS-Proxy",
27
27
  "repository": {
28
28
  "type": "git",
29
- "url": "https://github.com/warren-bank/HLS-Proxy"
29
+ "url": "https://github.com/warren-bank/node-HLS-Proxy"
30
30
  },
31
31
  "bugs": {
32
- "url": "https://github.com/warren-bank/HLS-Proxy/issues"
32
+ "url": "https://github.com/warren-bank/node-HLS-Proxy/issues"
33
33
  }
34
34
  }