Skip to content
A basic IPTV playlist parser
JavaScript
Branch: master
Clone or download
Latest commit fd1cfc3 Oct 8, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src Fixes 'Cannot read property 'title' of undefined' error Oct 8, 2019
test Added test for playlists with comments Oct 8, 2019
.babelrc Init Oct 6, 2019
.gitignore Init Oct 6, 2019
.travis.yml Init Oct 6, 2019
LICENSE Init Oct 6, 2019
README.md Updated example Oct 7, 2019
package-lock.json Upgrade to new version of m3u8-file-parser Oct 8, 2019
package.json Bump to v0.2.2 Oct 8, 2019

README.md

iptv-playlist-parser

It parses IPTV playlist and converts it to a regular JavaScript object.

Installation

npm install iptv-playlist-parser

Usage

import fs from 'fs'
import parser from 'iptv-playlist-parser'

const playlist = fs.readFileSync('./playlist.m3u', { encoding: 'utf-8'})
const result = parser.parse(playlist)

console.log(result)

Example

Input:

#EXTM3U x-tvg-url="http://example.com/epg.xml.gz"
#EXTINF:-1 tvg-id="cnn.us" tvg-name="CNN" tvg-logo="http://example.com/logo.png" group-title="News",CNN (US)
http://example.com/stream.m3u8

Output:

{
  header: {
    attrs: {
      'x-tvg-url': 'http://example.com/epg.xml.gz'
    },
    raw: '#EXTM3U x-tvg-url="http://example.com/epg.xml.gz"'
  },
  items: [
    { 
      name: 'CNN (US)',
      tvg: {
        id: 'cnn.us',
        name: 'CNN',
        logo: 'http://example.com/logo.png'
      },
      group: {
        title: 'News'
      },
      url: 'http://example.com/stream.m3u8',
      raw: '#EXTINF:-1 tvg-id="cnn.us" tvg-name="CNN" tvg-logo="http://example.com/logo.png" group-title="News",CNN (US)\nhttp://example.com/stream.m3u8'
    }
  ]
}

Testing

npm test

Contribution

If you find a bug or want to contribute to the code or documentation, you can help by submitting an issue or a pull request.

License

MIT

You can’t perform that action at this time.