npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

hlsdownloader

v3.2.11

Published

Downloads HLS Playlist file and TS chunks

Downloads

184

Readme

HLSDownloader

Version Node CI Documentation Maintenance License: MIT Semver: Badge Downloads: HLSDownloader Min Bundle Size: HLSDownloader Known Vulnerabilities

⚠️ This package is native ESM and no longer provides a CommonJS export. If your project uses CommonJS, you will have to convert to ESM. Please don't open issues for questions regarding CommonJS / ESM.

⚠️ HLSDownloader v2.x.x is no longer maintained and we will not accept any backport requests.

Features

  • Retryable
  • Promise Based
  • Support for HTTP/2
  • Overwrite protection
  • Support for custom HTTP Headers
  • Support for custom HTTP Client
  • Bring your own progress bar during download
  • Concurrent download segments with multiple http connections

Prerequisites

  • node >=18.x.x

Installation

It is pretty straight forward

# using npm
npm install --save hlsdownloader
# or with yarn
yarn add hlsdownloader
# or pnpm
pnpm install hlsdownloader

How to use

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 with.

import HLSDownloader from 'hlsdownloader';

const options = {
  playlistURL: 'http://example.com/path/to/your/playlist.m3u8', // change it
  destination: '/tmp', // change it (optional: default '')
  concurrency: 10, // change it (optional: default = 1),
  overwrite: true, // change it (optional: default = false)
  // (optional: default = null
  onData: function (data) {
    console.log(data); // {url: "<url-just-downloaded>", totalItems: "<total-items-to-download>", path: "<absolute-path-of-download-loation>"}
  },
  // (optional: default = null
  onError: function (error) {
    console.log(error); // { url: "<URLofItem>", name: "<nameOfError>", message: "human readable message of error" }
  },
};
const downloader = new HLSDownloader(options);
downloader.startDownload().then(response => console.log(response));

ℹ️ Check example.js for working example

// on success
{
  total: <number>,
  playlistURL: 'your playlist url'
  message: 'Downloaded successfully',
}

// on partial download
{
  total: <number>,
  playlistURL: 'your playlist url',
  message: 'Download done with some errors',
  errors: [
    {
      name: 'InvalidPlaylist',
      message: 'Playlist parsing is not successful'
      url: 'https://cnd.hls-server.test/playlist.m3u8'
    }
  ] // items url that is skipped or could not downloaded for error
}

Advance Usage

HLSDownloader supports all Ky API except these options given below

  • uri
  • url
  • json
  • form
  • body
  • method
  • setHost
  • isStream
  • parseJson
  • prefixUrl
  • cookieJar
  • playlistURL
  • concurrency
  • allowGetBody
  • stringifyJson
  • methodRewriting

It also disable retry failed request that you can easily override

Running Tests

npm test

To run it on watch mode

npm run test:watch

Generate Documentations

npm docs:gen

Authors

👤 Nur Rony

Contributing

Contributions, issues and feature requests are welcome!Feel free to check issues page. You can also take a look at the contributing guide.

Show your support

Give a ⭐️ if this project helped you!. 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!!

Special Thanks to

License

Copyright © 2024 Nur Rony. This project is MIT licensed.