Skip to content

Commit

Permalink
Don't use named capture group lookup (Fixes #42)
Browse files Browse the repository at this point in the history
  • Loading branch information
BjoernPetersen committed Jan 6, 2022
1 parent 58ef96f commit e5e2658
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/main/kotlin/net/bjoernpetersen/m3u/M3uParser.kt
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,11 @@ import kotlin.streams.asSequence
object M3uParser {
private const val COMMENT_START = '#'
private const val EXTENDED_HEADER = "${COMMENT_START}EXTM3U"
private const val SECONDS = "seconds"
private const val TITLE = "title"
// Using group index instead of name, because Android doesn't support named group lookup
private const val SECONDS = 1
private const val TITLE = 2
private const val EXTENDED_INFO =
"""${COMMENT_START}EXTINF:(?<$SECONDS>[-]?\d+).*,(?<$TITLE>.+)"""
"""${COMMENT_START}EXTINF:([-]?\d+).*,(.+)"""

private val logger = KotlinLogging.logger { }

Expand Down Expand Up @@ -124,7 +125,9 @@ object M3uParser {
if (newMatch != null) {
if (match != null) logger.debug { "Ignoring info line: ${match!!.value}" }
match = newMatch
} else logger.debug { "Ignoring comment line $currentLine" }
} else {
logger.debug { "Ignoring comment line $currentLine" }
}

if (filtered.hasNext()) currentLine = filtered.next()
else return entries
Expand Down

0 comments on commit e5e2658

Please sign in to comment.