Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/marketingpipeline/iptv-parser.js

A JavaScript library to easily parse M3U / IPTV
https://github.com/marketingpipeline/iptv-parser.js

fetch-iptv free-iptv iptv iptv-m3u iptv-parser iptv-playlist javascript m3u m3u-parser m3u8 m3u8-parser parser xml-parser

Last synced: 28 days ago
JSON representation

A JavaScript library to easily parse M3U / IPTV

Awesome Lists containing this project

README

        

# IPTV-Parser.js



Repo Banner for IPTV-Parser.js




A easy to use, pure vanilla JavaScript M3U / IPTV parser



Show your support!








This is a basic JavaScript library for fetching & parsing M3U files from a URL or path to file. It uses [iptv-list-parser](https://github.com/freearhey/iptv-playlist-parser) under the hood with some extra functionallity & improved error handling.

## Example usage

### Parse M3U8 from URL

```js
import {ParseM3U} from 'https://cdn.jsdelivr.net/gh/MarketingPipeline/IPTV-Parser.js@latest/dist/iptv-parser.min.js';

async function Fetch_IPTV_Links() {
try {
let IPTV_Results = ParseM3U(`https://raw.githubusercontent.com/iptv-org/iptv/master/streams/us_pluto.m3u`)
console.log(await IPTV_Results)
} catch (err) {
console.error(err);
}
}
Fetch_IPTV_Links()
```
will return a JSON object of parsed results.

### Parse M3U8 from string

```js
import {ParseM3U} from 'https://cdn.jsdelivr.net/gh/MarketingPipeline/IPTV-Parser.js@latest/dist/iptv-parser.min.js';

async function Parse_M3U_String() {
try {
let IPTV_Results = ParseM3U(`#EXTM3U x-tvg-url="http://example.com/epg.xml.gz"
#EXTINF:-1 tvg-id="cnn.us" tvg-name="CNN" tvg-url="http://195.154.221.171/epg/guide.xml.gz" timeshift="3" catchup="shift" catchup-days="3" catchup-source="https://m3u-server/hls-apple-s4-c494-abcdef.m3u8?utc=325234234&lutc=3123125324" tvg-logo="http://example.com/logo.png" group-title="News",CNN (US)
#EXTGRP:News
#EXTVLCOPT:http-referrer=http://example.com/
#EXTVLCOPT:http-user-agent=Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_5)
http://example.com/stream.m3u8`)
console.log(await IPTV_Results)
} catch (err) {
console.log(err)
}
}

Parse_M3U_String()
```

will return a JSON object of parsed results.

## Contributing ![GitHub](https://img.shields.io/github/contributors/MarketingPipeline/IPTV-Parser.js)

Want to improve this project? Create a pull request with detailed changes / improvements! If approved you will be added to the list of contributors of this awesome project!

See also the list of
[contributors](https://github.com/MarketingPipeline/IPTV-Parser.js/graphs/contributors) who
participate in this project.

## License ![GitHub](https://img.shields.io/github/license/MarketingPipeline/IPTV-Parser.js)

This project is licensed under the MIT License - see the
[LICENSE](https://github.com/MarketingPipeline/IPTV-Parser.js/blob/main/LICENSE) file for
details.