All Projects → BjoernPetersen → m3u-parser

BjoernPetersen / m3u-parser

Licence: MIT License
A M3U parser written in Kotlin

Programming Languages

kotlin
9241 projects

Projects that are alternatives of or similar to m3u-parser

m3u8
m3u8 file downloader library and chrome & firefox extensions/add-on's
Stars: ✭ 67 (+458.33%)
Mutual labels:  m3u, m3u-parser
m3u8 downloader 4 yingke
映客m3u8格式历史直播记录下载器
Stars: ✭ 50 (+316.67%)
Mutual labels:  m3u
useetv-playlist
No description or website provided.
Stars: ✭ 41 (+241.67%)
Mutual labels:  m3u
IPtv
A collection of private IPtv list as well as Third-party IPtv list. (not updated anymore)
Stars: ✭ 16 (+33.33%)
Mutual labels:  m3u
YouTube to m3u
Grabs m3u from YouTube live.
Stars: ✭ 95 (+691.67%)
Mutual labels:  m3u
iptv-proxy
Reverse proxy on iptv m3u and m3u8 file and xtream codes client api
Stars: ✭ 235 (+1858.33%)
Mutual labels:  m3u
YouTube to m3u
Grab .m3u8 from YouTube live channels and makes .m3u IPTV Playlist from various languages and Events. Tamil / Malayalam / English / Hindi / French / Kids / Sports / Urudu etc.
Stars: ✭ 48 (+300%)
Mutual labels:  m3u
peerstohttp
Simple torrent proxy to http stream controlled over REST-like api
Stars: ✭ 30 (+150%)
Mutual labels:  m3u
iptvtools
A set of scripts that help to better IPTV experience.
Stars: ✭ 103 (+758.33%)
Mutual labels:  m3u
megacubo
A intuitive, multi-language and cross-platform IPTV player. Available for Windows, Android, Linux & macOS.
Stars: ✭ 134 (+1016.67%)
Mutual labels:  m3u
iptv-playlist-aggregator
Aggregator for IPTV playlists from multiple sources
Stars: ✭ 35 (+191.67%)
Mutual labels:  m3u
Iptv M3u Maker
IPTV 国内+国外 电视台直播源m3u文件, 收集&汇总&本地源脚本
Stars: ✭ 1,979 (+16391.67%)
Mutual labels:  m3u
Iptv
Collection of publicly available IPTV channels from all over the world
Stars: ✭ 45,053 (+375341.67%)
Mutual labels:  m3u
Tvlist Awesome M3u M3u8
直播源相关资源汇总 📺 💯 IPTV、M3U —— 勤洗手、戴口罩,祝愿所有人百毒不侵
Stars: ✭ 5,304 (+44100%)
Mutual labels:  m3u
ustvgo to m3u
Grabs m3u links from ustvgo.tv
Stars: ✭ 35 (+191.67%)
Mutual labels:  m3u

m3u-parser

GitHub (pre-)release GitHub license CircleCI branch codebeat badge codecov

A parser for simple and extended M3U playlist files written in Kotlin.

This parser can also be used in Java projects.

Due to the underspecified nature of the M3U format, the parser tries to accept all files it gets, as weird as they may are. This especially includes extended M3U files with missing "#EXTM3U" headers and mixed extended/simple files.

Dependency configuration

The library is available in Maven Central. Java 8 or higher is required to use it.

Gradle

Kotlin DSL

build.gradle.kts

dependencies {
    implementation("com.github.bjoernpetersen:musicbot:${Lib.M3U_PARSER}")
    // or
    implementation(
        group = "com.github.bjoernpetersen",
        name = "m3u-parser",
        version = Lib.M3U_PARSER
    )
}

Groovy DSL

build.gradle

dependencies {
    implementation "com.github.bjoernpetersen:m3u-parser:$m3uParserVersion"
}

Maven

pom.xml

<dependency>
    <groupId>com.github.bjoernpetersen</groupId>
    <artifactId>m3u-parser</artifactId>
    <version>${m3uParser.version}</version>
</dependency>

Usage

// Simply pass in a file
val m3uFile = Paths.get("myplaylist.m3u")
val fileEntries: List<M3uEntry> = M3uParser.parse(m3uFile)

// You may also pass in an InputStreamReader
val m3uStream: InputStream = javaClass.getResourceAsStream("myplaylist.m3u")
val m3uReader: InputStreamReader = m3uStream.reader()
val streamEntries: List<M3uEntry> = M3uParser.parse(m3uReader)

// Passing in the content of an M3U file as a String also works
val someApi = TODO("Not a real API object")
// Returns a playlist in the M3U format
val m3uContent: String = someApi.getPlaylist("Best of Willy Astor")
val entries: List<M3uEntry> = M3uParser.parse(m3uContent)

Nested playlists

If your M3U file contains the path of another playlist file

MyPlaylist.m3u

AnotherPlayList.m3u

then you'll get a M3uEntry with a MediaPath location for that file. To get the contents of that playlist, you'll need to pass it to the parser again:

val nestedM3uLocation: MediaPath = TODO("...")
M3uParser.parse(nestedM3uLocation.path)

You can use the M3uParser.resolveNestedPlaylists() method to recursively parse all nested playlist file references:

val entries: List<M3uEntry> = M3uParser.parse(Paths.get("playlist.m3u"))
// Doesn't contain any .m3u file references anymore
val resolvedEntries: List<M3uEntry> = M3uParser.resolveNestedPlaylists(entries)

License

This project is released under the MIT License. That includes every file in this repository, unless explicitly stated otherwise at the top of a file. A copy of the license text can be found in the LICENSE file.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].