diff --git a/Sources/EeveeSpotify/CustomLyrics.x.swift b/Sources/EeveeSpotify/CustomLyrics.x.swift index 5ffae4c..bc76839 100644 --- a/Sources/EeveeSpotify/CustomLyrics.x.swift +++ b/Sources/EeveeSpotify/CustomLyrics.x.swift @@ -106,7 +106,7 @@ func getCurrentTrackLyricsData() throws -> Data { if source != .genius && UserDefaults.geniusFallback { - NSLog("[EeveeSpotify] Unable to load lyrics from \(source), trying Genius as fallback") + NSLog("[EeveeSpotify] Unable to load lyrics from \(source): \(error), trying Genius as fallback") source = .genius plainLyrics = try LyricsRepository.getLyrics( diff --git a/Sources/EeveeSpotify/Helpers/LyricsHelper.swift b/Sources/EeveeSpotify/Helpers/LyricsHelper.swift index 55f729c..f4f4956 100644 --- a/Sources/EeveeSpotify/Helpers/LyricsHelper.swift +++ b/Sources/EeveeSpotify/Helpers/LyricsHelper.swift @@ -50,8 +50,7 @@ class LyricsHelper { let matchRange = match.range(withName: name) if let substringRange = Range(matchRange, in: line) { - let capture = String(line[substringRange]) - captures[name] = capture + captures[name] = String(line[substringRange]) } } diff --git a/Sources/EeveeSpotify/Lyrics/LyricsRepository.swift b/Sources/EeveeSpotify/Lyrics/LyricsRepository.swift index 653fb3b..d90a762 100644 --- a/Sources/EeveeSpotify/Lyrics/LyricsRepository.swift +++ b/Sources/EeveeSpotify/Lyrics/LyricsRepository.swift @@ -13,7 +13,8 @@ struct LyricsRepository { source: LyricsSource ) throws -> PlainLyrics { - let query = "\(title.strippedTrackTitle) \(artist)" + let strippedTitle = title.strippedTrackTitle + let query = "\(strippedTitle) \(artist)" switch source { @@ -23,7 +24,7 @@ struct LyricsRepository { guard let song = ( hits.first( - where: { $0.result.title.containsInsensitive(title) } + where: { $0.result.title.containsInsensitive(strippedTitle) } ) ?? hits.first )?.result else { throw LyricsError.NoSuchSong @@ -38,14 +39,14 @@ struct LyricsRepository { guard let song = ( hits.first( - where: { $0.name.containsInsensitive(title) } + where: { $0.name.containsInsensitive(strippedTitle) } ) ?? hits.first ) else { throw LyricsError.NoSuchSong } return PlainLyrics( - content: song.syncedLyrics ?? song.plainLyrics, + content: song.syncedLyrics ?? song.plainLyrics ?? "", timeSynced: song.syncedLyrics != nil ) diff --git a/Sources/EeveeSpotify/Lyrics/Models/Lrclib/LrclibSong.swift b/Sources/EeveeSpotify/Lyrics/Models/Lrclib/LrclibSong.swift index 74dc483..662c04d 100644 --- a/Sources/EeveeSpotify/Lyrics/Models/Lrclib/LrclibSong.swift +++ b/Sources/EeveeSpotify/Lyrics/Models/Lrclib/LrclibSong.swift @@ -2,6 +2,6 @@ import Foundation struct LrclibSong: Decodable { var name: String - var plainLyrics: String + var plainLyrics: String? var syncedLyrics: String? } \ No newline at end of file diff --git a/Sources/EeveeSpotify/Models/Extensions/Color+Extension.swift b/Sources/EeveeSpotify/Models/Extensions/Color+Extension.swift index b9e5f48..818bf96 100644 --- a/Sources/EeveeSpotify/Models/Extensions/Color+Extension.swift +++ b/Sources/EeveeSpotify/Models/Extensions/Color+Extension.swift @@ -55,7 +55,7 @@ extension Color { var normalized: Color { brightness < 0.5 - ? self.lighter(by: 0.35) + ? self.lighter(by: 0.5 - brightness) : self.darker(by: brightness - 0.5) } diff --git a/Sources/EeveeSpotify/Models/Extensions/String+Extension.swift b/Sources/EeveeSpotify/Models/Extensions/String+Extension.swift index 1725f54..74ec70d 100644 --- a/Sources/EeveeSpotify/Models/Extensions/String+Extension.swift +++ b/Sources/EeveeSpotify/Models/Extensions/String+Extension.swift @@ -16,7 +16,7 @@ extension String { .removeMatches("\\(.*\\)") .removeMatches("- .*") .prefix(30) - //.trimmingCharacters(in: .whitespaces) + .trimmingCharacters(in: .whitespaces) ) } diff --git a/Sources/EeveeSpotify/OfflineObserver.swift b/Sources/EeveeSpotify/OfflineObserver.swift index 9a6cf38..851bac8 100644 --- a/Sources/EeveeSpotify/OfflineObserver.swift +++ b/Sources/EeveeSpotify/OfflineObserver.swift @@ -23,7 +23,7 @@ class OfflineObserver: NSObject, NSFilePresenter { let productState = HookedInstances.productState! - if productState.stringForKey("player-license") == "premium" { + if productState.stringForKey("type") == "premium" { do { try OfflineHelper.backupToEeveeBnk() diff --git a/Sources/EeveeSpotify/Views/EeveeSettingsView.swift b/Sources/EeveeSpotify/Views/EeveeSettingsView.swift index ef53db5..aa5cce0 100644 --- a/Sources/EeveeSpotify/Views/EeveeSettingsView.swift +++ b/Sources/EeveeSpotify/Views/EeveeSettingsView.swift @@ -10,12 +10,12 @@ struct EeveeSettingsView: View { let alert = UIAlertController( title: "Enter User Token", - message: "In order to use Musixmatch, you need to retrieve your user token from the official app. Download Musixmatch from the App Store, sign up, and extract the token using MITM.", + message: "In order to use Musixmatch, you need to retrieve your user token from the official app. Download Musixmatch from the App Store, sign up, then go to Settings > Get help > Copy debug info, and paste it here. You can also extract the token using MITM.", preferredStyle: .alert ) alert.addTextField() { textField in - textField.placeholder = Data.musixmatchTokenPlaceholder + textField.placeholder = "---- Debug Info ---- [Device]: iPhone" } alert.addAction(UIAlertAction(title: "Cancel", style: .cancel) { _ in @@ -23,9 +23,17 @@ struct EeveeSettingsView: View { }) alert.addAction(UIAlertAction(title: "OK", style: .default) { _ in - let token = alert.textFields!.first!.text! + let text = alert.textFields!.first!.text! + let token: String - if !(token ~= "^[a-f0-9]+$") { + if let match = text.firstMatch("\\[UserToken\\]: ([a-f0-9]+)"), + let tokenRange = Range(match.range(at: 1), in: text) { + token = String(text[tokenRange]) + } + else if text ~= "^[a-f0-9]+$" { + token = text + } + else { lyricsSource = oldSource return }