Gathering detailed insights and metrics for @tunarr/playlist
Gathering detailed insights and metrics for @tunarr/playlist
Gathering detailed insights and metrics for @tunarr/playlist
Gathering detailed insights and metrics for @tunarr/playlist
An extremely fast M3U playlist parser and generator for Node and the browser.
npm install @tunarr/playlist
Typescript
Module System
Node Version
NPM Version
70.7
Supply Chain
98.8
Quality
75.9
Maintenance
100
Vulnerability
100
License
TypeScript (96.6%)
JavaScript (2.29%)
Shell (1.11%)
Total Downloads
7,740
Last Day
21
Last Week
155
Last Month
684
Last Year
7,740
MIT License
27 Stars
55 Commits
6 Forks
2 Watchers
4 Branches
2 Contributors
Updated on May 08, 2025
Minified
Minified + Gzipped
Latest Version
1.1.0
Package Id
@tunarr/playlist@1.1.0
Unpacked Size
22.35 kB
Size
7.21 kB
File Count
7
NPM Version
10.2.4
Node Version
20.11.1
Published on
Jun 08, 2024
Cumulative downloads
Total Downloads
Last Day
-8.7%
21
Compared to previous day
Last Week
-4.9%
155
Compared to previous week
Last Month
-1.6%
684
Compared to previous month
Last Year
0%
7,740
Compared to previous year
An extremely fast M3U playlist parser and generator for Node and the browser.
Lightweight, dependency-free, and easy to use.
#EXTINF
& #EXTM3U
attributeTo install this library, use the following command:
1# pnpm 2pnpm add @iptv/playlist 3 4# npm 5npm install @iptv/playlist 6 7# yarn 8yarn add @iptv/playlist
To use this library in your project, first import the functions you need:
1import { parseM3U, writeM3U } from "@iptv/playlist";
Then, you can parse an M3U file and receive back an M3uPlaylist
object:
Examples will be based on this M3U file, it can be found in the tests/fixtures directory.
1#EXTM3U 2#EXTINF:-1 tvg-id="Channel1" tvg-name="Channel 1" tvg-language="English" group-title="News",Channel 1 3http://server:port/channel1
1const m3u = `...`; // M3U file contents 2const playlist: M3uPlaylist = parseM3U(m3u); 3const channels: M3uChannel[] = playlist.channels;
1{ 2 channels: [ 3 { 4 tvgId: 'Channel1', 5 tvgName: 'Channel 1', 6 tvgLanguage: 'English', 7 groupTitle: 'News', 8 duration: -1, 9 name: 'Channel 1', 10 url: 'http://server:port/channel1', 11 extras: { 12 'your-custom-attribute': 'your-custom-value' 13 } 14 }, 15 ], 16 headers: {} 17}
You can also generate an M3U file from a M3uPlaylist
object:
1const playlistObject: M3uPlaylist = { 2 channels: [ 3 { 4 tvgId: "Channel1", 5 tvgName: "Channel 1", 6 tvgLanguage: "English", 7 groupTitle: "News", 8 duration: -1, 9 name: "Channel 1", 10 url: "http://server:port/channel1", 11 extras: { 12 "your-custom-attribute": "your-custom-value", 13 }, 14 }, 15 ], 16 headers: {}, 17}; 18const m3u = writeM3U(playlistObject); 19console.log(m3u); // #EXTM3U ...
This library supports all standard attributes for the #EXTINF
and #EXTM3U
tags. They will be parsed, camelCased and added as properties on the M3uChannel
object.
This library supports any custom attributes you may have in your M3U file. They will be parsed and generated as an object under the extras
property of the M3uChannel
object.
1#EXTM3U 2#EXTINF:-1 tvg-id="Channel1" tvg-name="Channel 1" tvg-language="English" group-title="News" custom-attribute="hello",Channel 1 3http://server:port/channel1
1const m3u = `...`; // M3U file contents 2const playlist: M3uPlaylist = parseM3U(m3u); 3const channel: M3uChannel = playlist.channels[0]; 4console.log(channel.extras); // { 'custom-attribute': 'hello' }
This library has been optimized for parsing and generating M3U files quickly and efficiently. In my benchmarks, it performs better than iptv-playlist-parser, iptv-playlist-generator and m3u-parser-generator.
Library | Ops/sec | |
---|---|---|
🟢 | @iptv/playlist | 1,363,859 |
m3u-parser-generator | 607,573 | |
🔴 | iptv-playlist-parser | 244,150 |
Library | Ops/sec | |
---|---|---|
🟢 | @iptv/playlist | 10,514,760 |
iptv-playlist-generator | 3,119,304 | |
🔴 | m3u-parser-generator | 1,816,358 |
Channels | 1 | 100 | 500 | 1,000 | 10,000 | 100,000 | 1,000,000 | |
---|---|---|---|---|---|---|---|---|
🟢 | @iptv/playlist | ~11 μs | ~201 μs | ~894 μs | ~1.94 ms | ~5.41 ms | ~67 ms | ~681 ms |
m3u-parser-generator | ~17 μs | ~226 μs | ~1.23 ms | ~3.66 ms | ~17 ms | ~153 ms | ~1.68 s | |
🔴 | iptv-playlist-parser | ~116 μs | ~513 μs | ~2.61 ms | ~5.17 ms | ~57 ms | ~385 ms | ~3.94 s |
I used nanobench to get the above times.
These benchmarks were run on a 2021 MacBook Pro M1 Max (10 cores) with 64 GB of RAM.
Even though it's fast and it won't block for long, this will block your main thread whilst it runs. I'd like to add support for running the parser in a worker so it doesn't block at all.
This library is designed to parse and generate media player playlist files only. It is not designed to be a generic m3u parser or generator. It will not parse or generate HLS playlists.
Contributions are welcome! Even better if they align with the future goals.
You'll need to be able to run the tests and benchmarks. To do so, you will need to run the ./create-fixtures.sh
script in the tests/fixtures
directory to generate the necessary fixture files.
To be accepted your PR must pass all tests and not negatively impact the benchmarks. Some commands to help you:
pnpm run test
- Run the vitest suitepnpm run benny
- Run benchmarks with bennypnpm run benchmark
- Run benchmarks with vitestpnpm run nanobench
- Run additional timing benchmarksThis project uses Changesets to manage releases. For you, this just means your PR must come with an appropriate changeset file. If you're not sure how to do this, just ask and I'll be happy to help, or read the changesets documentation on adding a changeset.
This library is licensed under the MIT License and is free to use in both open source and commercial projects.
No vulnerabilities found.
No security vulnerabilities found.