From 01e027f4aa42ab919012516c44d154ed814f8e1e Mon Sep 17 00:00:00 2001 From: eevee Date: Wed, 17 Jul 2024 20:23:04 +0300 Subject: [PATCH] kinda fix for #246 --- .../EeveeSpotify/Lyrics/CustomLyrics.x.swift | 5 ++++- .../EeveeSpotify/Lyrics/Models/LyricsDto.swift | 17 +++++++++++++++-- .../Models/Headers/SPTPlayerTrack.swift | 1 + 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/Sources/EeveeSpotify/Lyrics/CustomLyrics.x.swift b/Sources/EeveeSpotify/Lyrics/CustomLyrics.x.swift index 74b43000..e60500f2 100644 --- a/Sources/EeveeSpotify/Lyrics/CustomLyrics.x.swift +++ b/Sources/EeveeSpotify/Lyrics/CustomLyrics.x.swift @@ -26,7 +26,8 @@ class LyricsFullscreenViewControllerHook: ClassHook { if UserDefaults.lyricsSource == .musixmatch && lastLyricsError == nil - && !lastLyricsWasRomanized { + && !lastLyricsWasRomanized + && !lastLyricsAreEmpty { return } @@ -41,6 +42,7 @@ class LyricsFullscreenViewControllerHook: ClassHook { // private var lastLyricsWasRomanized = false +private var lastLyricsAreEmpty = false private var lastLyricsError: LyricsError? = nil private var hasShownRestrictedPopUp = false @@ -212,6 +214,7 @@ func getCurrentTrackLyricsData(originalLyrics: Lyrics? = nil) throws -> Data { } lastLyricsWasRomanized = lyricsDto.romanized + lastLyricsAreEmpty = lyricsDto.lines.isEmpty let lyrics = Lyrics.with { $0.colors = getLyricsColors() diff --git a/Sources/EeveeSpotify/Lyrics/Models/LyricsDto.swift b/Sources/EeveeSpotify/Lyrics/Models/LyricsDto.swift index 88e8cacb..f0276b06 100644 --- a/Sources/EeveeSpotify/Lyrics/Models/LyricsDto.swift +++ b/Sources/EeveeSpotify/Lyrics/Models/LyricsDto.swift @@ -11,13 +11,26 @@ struct LyricsDto { $0.timeSynchronized = timeSynced $0.restriction = .unrestricted $0.providedBy = "\(source) (EeveeSpotify)" - $0.lines = lines.map { line in + } + + lyricsData.lines = lines.isEmpty + ? [ + LyricsLine.with { + $0.content = "This song is instrumental." + }, + LyricsLine.with { + $0.content = "Let the music play..." + }, + LyricsLine.with { + $0.content = "" + } + ] + : lines.map { line in LyricsLine.with { $0.content = line.content $0.offsetMs = Int32(line.offsetMs ?? 0) } } - } if let translation = translation { lyricsData.translation = LyricsTranslation.with { diff --git a/Sources/EeveeSpotify/Models/Headers/SPTPlayerTrack.swift b/Sources/EeveeSpotify/Models/Headers/SPTPlayerTrack.swift index 70d7364f..244f86a0 100644 --- a/Sources/EeveeSpotify/Models/Headers/SPTPlayerTrack.swift +++ b/Sources/EeveeSpotify/Models/Headers/SPTPlayerTrack.swift @@ -2,6 +2,7 @@ import Foundation @objc protocol SPTPlayerTrack { func setMetadata(_ metadata: [String:String]) + func metadata() -> [String:String] func extractedColorHex() -> String func trackTitle() -> String func artistTitle() -> String