now-hls

1.0.1 • Public • Published

now-hls

Take a .m3u8 file and its' .ts files, and host it on ▲ now.

npm version

NPM

Support goals

What now-hls can take care of, and what it will in future updates.

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}`)
});

Readme

Keywords

Package Sidebar

Install

npm i now-hls

Weekly Downloads

1

Version

1.0.1

License

MIT

Unpacked Size

7.92 kB

Total Files

4

Last publish

Collaborators

  • jasonidris