GitHub - MarketingPipeline/IPTV-Parser.js: A JavaScript library to easily parse...
source link: https://github.com/MarketingPipeline/IPTV-Parser.js
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
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 under the hood with some extra functionallity & improved error handling.
Example usage
Note: Any errors will be returned in a JSON key called
iptv_parser_error
Parse M3U8 from URL
import {ParseM3U} from 'https://cdn.jsdelivr.net/gh/MarketingPipeline/IPTV-Parser.js/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`, "URL")
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
import {ParseM3U} from 'https://cdn.jsdelivr.net/gh/MarketingPipeline/IPTV-Parser.js/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.
https://cdn.jsdelivr.net/gh/MarketingPipeline/IPTV-Parser.js/dist/iptv-parser.min.js
Import
import {ParseM3U} from 'https://cdn.jsdelivr.net/gh/MarketingPipeline/IPTV-Parser.js/dist/iptv-parser.min.js';
Contributing
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 who participate in this project.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK