How to use m3u8-parser - 9 common examples

To help you get started, we’ve selected a few m3u8-parser 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 videojs / http-streaming / src / playlist-loader.js View on Github external
haveMetadata(xhr, url, id) {
    // any in-flight request is now finished
    this.request = null;
    this.state = 'HAVE_METADATA';

    const parser = new M3u8Parser();

    // adding custom tag parsers
    this.customTagParsers.forEach(customParser => parser.addParser(customParser));

    // adding custom tag mappers
    this.customTagMappers.forEach(mapper => parser.addTagMapper(mapper));

    parser.push(xhr.responseText);
    parser.end();
    parser.manifest.uri = url;
    parser.manifest.id = id;
    // m3u8-parser does not attach an attributes property to media playlists so make
    // sure that the property is attached to avoid undefined reference errors
    parser.manifest.attributes = parser.manifest.attributes || {};

    // merge this playlist into the master
github videojs / http-streaming / src / playlist-loader.js View on Github external
if (error) {
        this.error = {
          status: req.status,
          message: `HLS playlist request error at URL: ${this.srcUrl}.`,
          responseText: req.responseText,
          // MEDIA_ERR_NETWORK
          code: 2
        };
        if (this.state === 'HAVE_NOTHING') {
          this.started = false;
        }
        return this.trigger('error');
      }

      const parser = new M3u8Parser();

      // adding custom tag parsers
      this.customTagParsers.forEach(customParser => parser.addParser(customParser));

      // adding custom tag mappers
      this.customTagMappers.forEach(mapper => parser.addTagMapper(mapper));

      parser.push(req.responseText);
      parser.end();

      this.state = 'HAVE_MASTER';

      this.srcUrl = resolveManifestRedirect(this.handleManifestRedirects, this.srcUrl, req);

      parser.manifest.uri = this.srcUrl;
github IrosTheBeggar / mStream / modules / file-explorer.js View on Github external
function readPlaylistSongs(pathString) {
    const parser = new m3u8Parser.Parser();
    const fileContents = fs.readFileSync(pathString).toString();
    parser.push(fileContents);
    parser.end();
    let items = parser.manifest.segments.map(segment => { return segment.uri; });
    if (items.length === 0) {
      items = fileContents.split(/\r?\n/).filter(Boolean);
    }
    return items.map(item => { return item.replace(/\\/g, "/"); });
  }
github Andro999b / torrent-player / server / service / transcode / HLSTranscoder.js View on Github external
async loadProgress() {
        const exists = await fs.exists(this.m3uPath)

        if (exists) {
            const buf = await fs.readFile(this.m3uPath)
            const parser = new m3u8.Parser()

            parser.push(buf.toString('utf8'))
            parser.end()

            const { segments } = parser.manifest
            const start_time = segments.reduce(
                (acc, seg) => acc + seg.duration, 0
            )

            return { start_time }
        } else {
            return { start_time: 0 }
        }
    }
github Novage / p2p-media-loader / p2p-media-loader-hlsjs / lib / segment-manager.ts View on Github external
public processPlaylist(requestUrl: string, content: string, responseUrl: string): void {
        const parser = new Parser();
        parser.push(content);
        parser.end();

        const playlist = new Playlist(requestUrl, responseUrl, parser.manifest);

        if (playlist.manifest.playlists) {
            this.masterPlaylist = playlist;

            for (const [key, variantPlaylist] of this.variantPlaylists) {
                const {streamSwarmId, found, index} = this.getStreamSwarmId(variantPlaylist.requestUrl);
                if (!found) {
                    this.variantPlaylists.delete(key);
                } else {
                    variantPlaylist.streamSwarmId = streamSwarmId;
                    variantPlaylist.streamId = "V" + index.toString();
                }
github simplymemes / crunchyroll-dl / index.js View on Github external
const parsem3u8 = (manifest) => {
  let parser = new m3u8Parser.Parser()

  parser.push(manifest)
  parser.end()
  return parser.manifest
}
github Andro999b / torrent-player / server / web / videoStreamConcat.js View on Github external
router.get('/', asyncHandler(async (req, res) => {
    const { manifestUrl, extractor } = req.query

    let time = 0
    const dlnaTimeSeek = req.header('TimeSeekRange.dlna.org')
    if (dlnaTimeSeek) {
        const ranges = parseRange(dlnaTimeSeek)
        time = ranges[0].start
    } else if (req.query.start) {
        time = parseInt(req.query.start)
    }

    let playlistUrl = manifestUrl
    if(!manifestUrl.endsWith('mpd')) {
        const parser = new m3u8.Parser()

        const res = await superagent
            .get(getExtractorUrl(playlistUrl, extractor))
            .buffer(true)

        parser.push(res.text)
        parser.end()

        const { playlists } = parser.manifest

        if(playlists && playlists.length > 0) {
            playlistUrl = playlists[0].uri //getExtractorUrl(playlists[0].uri, extractor)
        }
    }

    if(playlistUrl.startsWith('/')) {

m3u8-parser

m3u8 parser

Apache-2.0
Latest version published 3 months ago

Package Health Score

84 / 100
Full package analysis

Popular m3u8-parser functions