-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for key=value pairs in EXTINF directive (fixes #43)
- Loading branch information
1 parent
0d72efd
commit 0e3eb81
Showing
6 changed files
with
607 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
src/main/kotlin/net/bjoernpetersen/m3u/model/M3uMetadata.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package net.bjoernpetersen.m3u.model | ||
|
||
/** | ||
* Additional key-value data for an M3U entry. Basically just a wrapper around a regular Map with | ||
* some convenience accessors for commonly-used keys. | ||
*/ | ||
class M3uMetadata(private val data: Map<String, String>) : Map<String, String> by data { | ||
/** | ||
* Gets a value for commonly used logo keys. If this is present, it's usually a URL. | ||
* | ||
* The returned value will never be a blank string. | ||
*/ | ||
val logo: String? | ||
get() = data["logo"].notBlankOrNull() ?: data["tvg-logo"].notBlankOrNull() | ||
|
||
companion object { | ||
/** | ||
* Obtain an empty instance of M3uMetadata. | ||
*/ | ||
@JvmStatic | ||
fun empty() = M3uMetadata(emptyMap()) | ||
} | ||
} | ||
|
||
private fun String?.notBlankOrNull(): String? = this?.ifBlank { null } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.