mirror of
https://github.com/whoeevee/EeveeSpotifyReborn.git
synced 2026-01-08 23:23:20 +00:00
spotify is wild
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
extension SPTPlayerTrack {
|
||||
var trackIdentifier: String {
|
||||
self.URI().spt_trackIdentifier()
|
||||
}
|
||||
}
|
||||
@@ -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 ""
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user