diff --git a/Sources/EeveeSpotify/Lyrics/CustomLyrics.x.swift b/Sources/EeveeSpotify/Lyrics/CustomLyrics.x.swift index d374333..f4b6136 100644 --- a/Sources/EeveeSpotify/Lyrics/CustomLyrics.x.swift +++ b/Sources/EeveeSpotify/Lyrics/CustomLyrics.x.swift @@ -28,6 +28,8 @@ class EncoreButtonHook: ClassHook { } } +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 diff --git a/Sources/EeveeSpotify/Lyrics/DataSources/MusixmatchLyricsDataSource.swift b/Sources/EeveeSpotify/Lyrics/DataSources/MusixmatchLyricsDataSource.swift index ac7d0f9..06d2ffd 100644 --- a/Sources/EeveeSpotify/Lyrics/DataSources/MusixmatchLyricsDataSource.swift +++ b/Sources/EeveeSpotify/Lyrics/DataSources/MusixmatchLyricsDataSource.swift @@ -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) } diff --git a/Sources/EeveeSpotify/Lyrics/Models/LyricsError.swift b/Sources/EeveeSpotify/Lyrics/Models/LyricsError.swift index d8a8401..05a0d22 100644 --- a/Sources/EeveeSpotify/Lyrics/Models/LyricsError.swift +++ b/Sources/EeveeSpotify/Lyrics/Models/LyricsError.swift @@ -1,7 +1,8 @@ import Foundation -enum LyricsError: Swift.Error { +enum LyricsError: Error { case NoCurrentTrack + case MusixmatchRestricted case InvalidMusixmatchToken case DecodingError case NoSuchSong