mirror of
https://gitlab.futo.org/videostreaming/grayjay.git
synced 2025-04-30 14:44:27 +02:00
Merge branch 'm3u8-parse-fix' into 'master'
fixed m3u8 parsing bug that caused Patreon video downloads to crash Grayjay See merge request videostreaming/grayjay!39
This commit is contained in:
commit
65afe5a0e6
@ -182,13 +182,14 @@ class HLS {
|
|||||||
|
|
||||||
private fun parseAttributes(content: String): Map<String, String> {
|
private fun parseAttributes(content: String): Map<String, String> {
|
||||||
val attributes = mutableMapOf<String, String>()
|
val attributes = mutableMapOf<String, String>()
|
||||||
val attributePairs = content.substringAfter(":").splitToSequence(',')
|
val maybeAttributePairs = content.substringAfter(":").splitToSequence(',')
|
||||||
|
|
||||||
var currentPair = StringBuilder()
|
var currentPair = StringBuilder()
|
||||||
for (pair in attributePairs) {
|
for (pair in maybeAttributePairs) {
|
||||||
currentPair.append(pair)
|
currentPair.append(pair)
|
||||||
if (currentPair.count { it == '\"' } % 2 == 0) { // Check if the number of quotes is even
|
if (currentPair.count { it == '\"' } % 2 == 0) { // Check if the number of quotes is even
|
||||||
val (key, value) = currentPair.toString().split('=')
|
val key = currentPair.toString().substringBefore("=")
|
||||||
|
val value = currentPair.toString().substringAfter("=")
|
||||||
attributes[key.trim()] = value.trim().removeSurrounding("\"")
|
attributes[key.trim()] = value.trim().removeSurrounding("\"")
|
||||||
currentPair = StringBuilder() // Reset for the next attribute
|
currentPair = StringBuilder() // Reset for the next attribute
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user