now-hls
▲ now
.
Take a .m3u8 file and its' .ts files, and host it on
Support goals
What now-hls can take care of, and what it will in future updates.
- [x] Standard M3U8 with .ts files
- [ ] Variant stream (.m3u8s inside .m3u8) in progress, see branch
nested
Make an issue to request further playlist types.
Debugging
now-hls uses the debug
module to log to be silent and fast. Errors are always on however. Only "extra" logs are put in debug
. If you want to enable extra logs, run nowhls
through the DEBUG
environment variable.
You should always enable this if you plan to contribute.
# unix, mac, linux
export DEBUG=nowhls
# windows shell
set DEBUG=nowhls
# windows powershell
$env:DEBUG = "nowhls"
# then just run normally
node example.js # or whatever your node script that uses now-hls is
Usage
const nowHls = require("now-hls");
nowHls('example-m3u8/cats.m3u8', function(url) {
console.log(`url to hosted file: ${url}`)
}, '<NOW_TOKEN>');
if you need to get the content in it,
const nowHls = require("now-hls");
nowHls('example-m3u8/cats.m3u8', function(url, content) {
console.log(`url to hosted file: ${url}`)
console.log(`content: ${content}`)
}, '<NOW_TOKEN>');
Or alternatively, assuming you (or your team) stored the token in a ▲ now
secret and exposed it as NOW_TOKEN
...
now secrets add now-token <token>
$ echo "{ \
>
> \"env\": {
> \"NOW_TOKEN\": \"@now-token\"
> }
> }" >> now.json
you don't even need to specify the token!
const nowHls = require("now-hls");
// notice that <NOW_TOKEN> is gone!
// now-hls automatically grabs it uses process.env.NOW_TOKEN
nowHls('example-m3u8/cats.m3u8', function(url) {
console.log(`url to hosted file: ${url}`)
});