mirror of
https://github.com/whoeevee/EeveeSpotifyReborn.git
synced 2026-01-09 00:23:20 +01:00
This commit is contained in:
@@ -28,6 +28,8 @@ class EncoreButtonHook: ClassHook<UIButton> {
|
||||
}
|
||||
}
|
||||
|
||||
private var hasShownRestrictedPopUp = false
|
||||
|
||||
func getCurrentTrackLyricsData(originalLyrics: Lyrics? = nil) throws -> Data {
|
||||
|
||||
guard let track = HookedInstances.currentTrack else {
|
||||
@@ -59,6 +61,21 @@ func getCurrentTrackLyricsData(originalLyrics: Lyrics? = nil) throws -> Data {
|
||||
buttonText: "OK"
|
||||
)
|
||||
break
|
||||
|
||||
case .MusixmatchRestricted:
|
||||
|
||||
if !hasShownRestrictedPopUp {
|
||||
|
||||
PopUpHelper.showPopUp(
|
||||
delayed: false,
|
||||
message: "The tweak is unable to load lyrics from Musixmatch because they are restricted. It's likely a copyright issue due to the US IP address, so you should change it if you're in the US or use a VPN.",
|
||||
buttonText: "OK"
|
||||
)
|
||||
|
||||
hasShownRestrictedPopUp.toggle()
|
||||
}
|
||||
|
||||
break
|
||||
|
||||
default:
|
||||
break
|
||||
|
||||
@@ -79,9 +79,15 @@ struct MusixmatchLyricsDataSource {
|
||||
let subtitlesBody = subtitlesMessage["body"] as? [String: Any],
|
||||
let subtitlesList = subtitlesBody["subtitle_list"] as? [Any],
|
||||
let firstSubtitle = subtitlesList.first as? [String: Any],
|
||||
let subtitle = firstSubtitle["subtitle"] as? [String: Any],
|
||||
let subtitleBody = subtitle["subtitle_body"] as? String {
|
||||
let subtitle = firstSubtitle["subtitle"] as? [String: Any] {
|
||||
|
||||
if let restricted = subtitle["restricted"] as? Bool, restricted {
|
||||
throw LyricsError.MusixmatchRestricted
|
||||
}
|
||||
|
||||
if let subtitleBody = subtitle["subtitle_body"] as? String {
|
||||
return PlainLyrics(content: subtitleBody, timeSynced: true)
|
||||
}
|
||||
}
|
||||
|
||||
guard
|
||||
@@ -93,6 +99,10 @@ struct MusixmatchLyricsDataSource {
|
||||
else {
|
||||
throw LyricsError.DecodingError
|
||||
}
|
||||
|
||||
if let restricted = lyrics["restricted"] as? Bool, restricted {
|
||||
throw LyricsError.MusixmatchRestricted
|
||||
}
|
||||
|
||||
return PlainLyrics(content: plainLyrics, timeSynced: false)
|
||||
}
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import Foundation
|
||||
|
||||
enum LyricsError: Swift.Error {
|
||||
enum LyricsError: Error {
|
||||
case NoCurrentTrack
|
||||
case MusixmatchRestricted
|
||||
case InvalidMusixmatchToken
|
||||
case DecodingError
|
||||
case NoSuchSong
|
||||
|
||||
Reference in New Issue
Block a user