spotify is wild

This commit is contained in:
eevee
2025-11-02 19:30:03 +03:00
parent d95f2e8c1f
commit 7ff296342d
4 changed files with 15 additions and 6 deletions

View File

@@ -41,6 +41,7 @@ class SPTDataLoaderServiceHook: ClassHook<NSObject>, SpotifySessionDelegate {
if url.isLyrics {
respondWithCustomData(
try getLyricsDataForCurrentTrack(
url.path,
originalLyrics: try? Lyrics(serializedBytes: buffer)
),
task: task,
@@ -98,7 +99,7 @@ class SPTDataLoaderServiceHook: ClassHook<NSObject>, SpotifySessionDelegate {
}
do {
let data = try getLyricsDataForCurrentTrack()
let data = try getLyricsDataForCurrentTrack(url.path)
let okResponse = HTTPURLResponse(url: url, statusCode: 200, httpVersion: "2.0", headerFields: [:])!
orig.URLSession(session, dataTask: task, didReceiveResponse: okResponse, completionHandler: handler)

View File

@@ -31,7 +31,7 @@ private func loadCustomLyricsForCurrentTrack() throws -> Lyrics {
primaryArtist: EeveeSpotify.hookTarget == .lastAvailableiOS14
? track.artistTitle()
: track.artistName(),
spotifyTrackId: track.URI().spt_trackIdentifier()
spotifyTrackId: track.trackIdentifier
)
let options = UserDefaults.lyricsOptions
@@ -120,7 +120,7 @@ private func loadCustomLyricsForCurrentTrack() throws -> Lyrics {
return lyrics
}
func getLyricsDataForCurrentTrack(originalLyrics: Lyrics? = nil) throws -> Data {
func getLyricsDataForCurrentTrack(_ originalPath: String, originalLyrics: Lyrics? = nil) throws -> Data {
guard
let track = statefulPlayer?.currentTrack() ??
nowPlayingScrollViewController?.loadedTrack
@@ -128,6 +128,10 @@ func getLyricsDataForCurrentTrack(originalLyrics: Lyrics? = nil) throws -> Data
throw LyricsError.noCurrentTrack
}
if !originalPath.contains(track.trackIdentifier) {
throw LyricsError.trackMismatch
}
var lyrics = try loadCustomLyricsForCurrentTrack()
let lyricsColorsSettings = UserDefaults.lyricsColors

View File

@@ -0,0 +1,5 @@
extension SPTPlayerTrack {
var trackIdentifier: String {
self.URI().spt_trackIdentifier()
}
}

View File

@@ -2,6 +2,7 @@ import Foundation
enum LyricsError: Error, CustomStringConvertible {
case noCurrentTrack
case trackMismatch
case musixmatchRestricted
case invalidMusixmatchToken
case decodingError
@@ -20,11 +21,9 @@ enum LyricsError: Error, CustomStringConvertible {
return "invalid_musixmatch_token".localized
case .decodingError:
return "decoding_error".localized
case .noCurrentTrack:
return "no_current_track".localized
case .unknownError:
return "unknown_error".localized
case .invalidSource:
default:
return ""
}
}