Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

hlsdownloader

2.2.0 • Public • Published

HLSDownloader

Greenkeeper badge version coding style: standard dependencies devDependencies Downloads Travis branch semantic-release

Downloads m3u8 playlist and TS chunks for a given playlist URL.

Installation

Install it via npm or yarn

[sudo] npm install hlsdownloader --save
# Or 
[sudo] yarn add hlsdownloader

Configuration

destination field is optional. If destination is not provided it just fetches the content from origin. It can also be useful if you want to do content pre-fetching from CDN for your end viewers. If any TS or m3u8 variant download is failed it continues downloading others and reports after finishing.

It's simple as below.

import HLSDownloader from 'hlsdownloader'; //Using ES2015 module
//var HLSDownloader = require('hlsdownloader').downloader; //using commonJS module
 
const params = {
  playlistURL: 'http://example.com/path/to/your/playlist.m3u8', // change it
  destination: '/tmp' // change it (optional field)
};
const downloader = new HLSDownloader(params);
downloader.startDownload((err, msg) => (err ? console.log(err) : console.log(msg)));

msg is an object with following properties

//on success
{
message: 'Downloaded successfully',
playlistURL: 'your playlist url'
}
//on partial download
{
message: 'Download done with some errors',
playlistURL: 'your playlist url',
errors: [] // items url that is skipped or could not downloaded for error
}

Advance Usage

HLSDownloader accepts all parameters supported by request-promise except these following options

  • method
  • uri
  • url
  • transform
  • resolveWithFullResponse
  • baseUrl
  • json
  • form
  • formData
  • preambleCRLF
  • postambleCRLF
  • jsonReviver
  • jsonReplacer

It helps you to do Auth, limit concurrency of download and other various tasks without changing your code and workflow.

I will be grateful if you all help me to improve this package by giving your suggestions, feature request and pull requests. I am all ears!!

install

npm i hlsdownloader

Downloadsweekly downloads

110

version

2.2.0

license

MIT

repository

Gitgithub

last publish

collaborators

  • avatar