From f98b0197c2986253ff2fa4cccd91decf505c7505 Mon Sep 17 00:00:00 2001 From: eevee Date: Thu, 30 May 2024 15:03:55 +0300 Subject: [PATCH] original lyrics colors when possible --- Sources/EeveeSpotify/DataLoaderServiceHooks.x.swift | 4 +++- Sources/EeveeSpotify/Lyrics/CustomLyrics.x.swift | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Sources/EeveeSpotify/DataLoaderServiceHooks.x.swift b/Sources/EeveeSpotify/DataLoaderServiceHooks.x.swift index c39314be..f848f797 100644 --- a/Sources/EeveeSpotify/DataLoaderServiceHooks.x.swift +++ b/Sources/EeveeSpotify/DataLoaderServiceHooks.x.swift @@ -85,7 +85,9 @@ class SPTDataLoaderServiceHook: ClassHook { orig.URLSession( session, dataTask: task, - didReceiveData: try getCurrentTrackLyricsData() + didReceiveData: try getCurrentTrackLyricsData( + originalLyrics: try? Lyrics(serializedData: data) + ) ) orig.URLSession(session, task: task, didCompleteWithError: nil) diff --git a/Sources/EeveeSpotify/Lyrics/CustomLyrics.x.swift b/Sources/EeveeSpotify/Lyrics/CustomLyrics.x.swift index e81c025a..b3531b73 100644 --- a/Sources/EeveeSpotify/Lyrics/CustomLyrics.x.swift +++ b/Sources/EeveeSpotify/Lyrics/CustomLyrics.x.swift @@ -28,7 +28,7 @@ class EncoreButtonHook: ClassHook { } } -func getCurrentTrackLyricsData() throws -> Data { +func getCurrentTrackLyricsData(originalLyrics: Lyrics? = nil) throws -> Data { guard let track = HookedInstances.currentTrack else { throw LyricsError.NoCurrentTrack @@ -67,7 +67,7 @@ func getCurrentTrackLyricsData() throws -> Data { } let lyrics = try Lyrics.with { - $0.colors = LyricsColors.with { + $0.colors = originalLyrics?.colors ?? LyricsColors.with { $0.backgroundColor = Color(hex: track.extractedColorHex()).normalized.uInt32 $0.lineColor = Color.black.uInt32 $0.activeLineColor = Color.white.uInt32