diff --git a/Sources/EeveeSpotify/Lyrics/Helpers/LyricsHelper.swift b/Sources/EeveeSpotify/Lyrics/Helpers/LyricsHelper.swift index 015556b..82a14bd 100644 --- a/Sources/EeveeSpotify/Lyrics/Helpers/LyricsHelper.swift +++ b/Sources/EeveeSpotify/Lyrics/Helpers/LyricsHelper.swift @@ -35,12 +35,14 @@ class LyricsHelper { .dropLast() if plain.timeSynced { - - lyricLines = lines.map { line in - let match = line.firstMatch( - "\\[(?\\d{2}):(?\\d{2}\\.?\\d*)\\] ?(?.*)" - )! + lyricLines = lines.compactMap { line in + + guard let match = line.firstMatch( + "\\[(?\\d*):(?\\d*\\.?\\d*)\\] ?(?.*)" + ) 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"]!)!