How to use miniget - 2 common examples

To help you get started, we’ve selected a few miniget examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github fent / node-m3u8stream / src / index.ts View on Github external
const requestQueue = new Queue((segment: Item, callback: () => void): void => {
    let req = miniget(urlResolve(playlistURL, segment.url), requestOptions);
    req.on('error', callback);
    streamQueue.push(req, (err, size) => {
      downloaded += +size;
      stream.emit('progress', {
        num: ++segmentNumber,
        size: size,
        duration: segment.duration,
        url: segment.url,
      }, requestQueue.total, downloaded);
      callback();
    });
  }, { concurrency: chunkReadahead });
github fent / node-m3u8stream / src / index.ts View on Github external
const refreshPlaylist = (): void => {
    lastRefresh = Date.now();
    currPlaylist = miniget(playlistURL, requestOptions);
    currPlaylist.on('error', onError);
    const parser = currPlaylist.pipe(new Parser(options.id));
    parser.on('starttime', (a: number) => {
      if (starttime) { return; }
      starttime = a;
      if (typeof options.begin === 'string' && begin >= 0) {
        begin += starttime;
      }
    });
    parser.on('endlist', () => { isStatic = true; });
    parser.on('endearly', currPlaylist.unpipe.bind(currPlaylist, parser));

    let addedItems: any[] = [];
    let liveAddedItems: any[] = [];
    const addItem = (item: TimedItem, isLive: boolean): void => {
      if (item.seq <= lastSeq) { return; }

miniget

A small HTTP(S) GET request library, with redirects and streaming.

MIT
Latest version published 1 year ago

Package Health Score

56 / 100
Full package analysis

Popular miniget functions