real lrclib crash fix

This commit is contained in:
eevee
2024-06-10 16:37:00 +03:00
parent 7d4c49adbc
commit d8935809cd

View File

@@ -35,12 +35,14 @@ class LyricsHelper {
.dropLast()
if plain.timeSynced {
lyricLines = lines.map { line in
let match = line.firstMatch(
"\\[(?<minute>\\d{2}):(?<seconds>\\d{2}\\.?\\d*)\\] ?(?<content>.*)"
)!
lyricLines = lines.compactMap { line in
guard let match = line.firstMatch(
"\\[(?<minute>\\d*):(?<seconds>\\d*\\.?\\d*)\\] ?(?<content>.*)"
) else {
return nil
}
var captures: [String: String] = [:]
@@ -52,6 +54,10 @@ class LyricsHelper {
captures[name] = String(line[substringRange])
}
}
if captures.count != 3 {
return nil
}
let minute = Int(captures["minute"]!)!
let seconds = Float(captures["seconds"]!)!