This commit is contained in:
eevee
2024-06-20 22:46:33 +03:00
parent 4eea82f876
commit d71f0b8e9a
3 changed files with 31 additions and 3 deletions
@@ -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