@warren-bank/hls-proxy 3.1.2 → 3.2.0
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 +46 -2
- package/hls-proxy/cookies.js +17 -0
- package/hls-proxy/manifest_parser.js +489 -489
- package/hls-proxy/proxy.js +5 -1
- package/hls-proxy/segment_cache.js +2 -1
- package/hls-proxy/timers.js +44 -0
- package/hls-proxy/utils.js +157 -157
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -76,8 +76,15 @@
|
|
|
76
76
|
|
|
77
77
|
##### notes:
|
|
78
78
|
|
|
79
|
-
* adding a file extension to the base64 encoded video URL is
|
|
80
|
-
-
|
|
79
|
+
* adding a file extension to the base64 encoded video URL is highly recommended
|
|
80
|
+
- the following file extension values have important significance to indicate the type of file being requested:
|
|
81
|
+
* `.m3u8`<br>HLS manifest
|
|
82
|
+
* `.ts`<br>media segment
|
|
83
|
+
* `.key`<br>encryption key
|
|
84
|
+
* `.json`<br>JSON data
|
|
85
|
+
- though currently,
|
|
86
|
+
* `.m3u8`<br>is the only file extension that receives special treatment
|
|
87
|
+
* all other file types (including those without any file extension) are piped directly to the HTTP response
|
|
81
88
|
|
|
82
89
|
##### high-level tools that automate this task:
|
|
83
90
|
|
|
@@ -243,6 +250,43 @@ options:
|
|
|
243
250
|
* the length of `prefetch_urls` is > `max_segments`
|
|
244
251
|
* post-conditions:
|
|
245
252
|
* the length of the return value array is <= `max_segments`
|
|
253
|
+
* `"request_intervals": (add_request_interval) => {}`
|
|
254
|
+
* enables the use of a cookie jar for all outbound HTTP requests
|
|
255
|
+
* adds any number of timers that each execute at individually specified intervals
|
|
256
|
+
* when each timer executes, it is passed an HTTP request client that is preconfigured to:
|
|
257
|
+
- include the request headers that are specified by other relevant options
|
|
258
|
+
- utilize the same cookie jar as all other outbound HTTP requests
|
|
259
|
+
* this allows the implementation of custom logic that may be required by one or more video hosts to periodically refresh or update session cookies
|
|
260
|
+
* an example would better illustrate usage:
|
|
261
|
+
```javascript
|
|
262
|
+
module.exports = {
|
|
263
|
+
request_intervals: (add_request_interval) => {
|
|
264
|
+
|
|
265
|
+
add_request_interval(
|
|
266
|
+
0, // run timer once at startup to initialize cookies
|
|
267
|
+
(request) => {
|
|
268
|
+
request('https://example.com/login', {username: 'me', password: '12345'})
|
|
269
|
+
}
|
|
270
|
+
)
|
|
271
|
+
|
|
272
|
+
add_request_interval(
|
|
273
|
+
(1000 * 60 * 5), // run timer at 5 minute interval to refresh cookies
|
|
274
|
+
(request) => {
|
|
275
|
+
request('https://example.com/heart-beat')
|
|
276
|
+
}
|
|
277
|
+
)
|
|
278
|
+
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
```
|
|
282
|
+
* more advanced configuration of the call to the HTTP request client is possible
|
|
283
|
+
- the 1st parameter is required, and must be a _URL_ string
|
|
284
|
+
- the 2nd parameter is optional, and can contain POST data
|
|
285
|
+
- the 3rd parameter is optional, and can be used for more advanced configuration options
|
|
286
|
+
* usage of this HTTP request client is documented [here](https://github.com/warren-bank/node-request#api)
|
|
287
|
+
- specifically, pay careful attention to the signatures for:
|
|
288
|
+
* the latter two input parameters
|
|
289
|
+
* the attributes of the Object that is resolved by the Promise in the return value (if the content of the response is needed)
|
|
246
290
|
* _--prefetch_ is a flag to enable the prefetch and caching of video segments
|
|
247
291
|
* when .m3u8 files are downloaded and modified inflight, all of the URLs in the playlist are known
|
|
248
292
|
* at this time, it is possible to prefetch the video segments (.ts files)
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
const {CookieJar} = require('tough-cookie')
|
|
2
|
+
|
|
3
|
+
let cookieJar = null
|
|
4
|
+
|
|
5
|
+
const useCookieJar = function(){
|
|
6
|
+
if (!cookieJar)
|
|
7
|
+
cookieJar = new CookieJar()
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const getCookieJar = function(){
|
|
11
|
+
return cookieJar
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
module.exports = {
|
|
15
|
+
useCookieJar,
|
|
16
|
+
getCookieJar
|
|
17
|
+
}
|