mirror of
https://github.com/whoeevee/EeveeSpotifyReborn.git
synced 2026-01-09 00:23:20 +01:00
Genius Fallback & slightly improved colors brightness
This commit is contained in:
@@ -89,14 +89,37 @@ func getCurrentTrackLyricsData() throws -> Data {
|
||||
throw LyricsError.NoCurrentTrack
|
||||
}
|
||||
|
||||
let source = UserDefaults.lyricsSource
|
||||
var source = UserDefaults.lyricsSource
|
||||
|
||||
let plainLyrics = try LyricsRepository.getLyrics(
|
||||
title: track.trackTitle(),
|
||||
artist: track.artistTitle(),
|
||||
spotifyTrackId: track.URI().spt_trackIdentifier(),
|
||||
source: source
|
||||
)
|
||||
let plainLyrics: PlainLyrics?
|
||||
|
||||
do {
|
||||
plainLyrics = try LyricsRepository.getLyrics(
|
||||
title: track.trackTitle(),
|
||||
artist: track.artistTitle(),
|
||||
spotifyTrackId: track.URI().spt_trackIdentifier(),
|
||||
source: source
|
||||
)
|
||||
}
|
||||
|
||||
catch {
|
||||
|
||||
if source != .genius && UserDefaults.geniusFallback {
|
||||
|
||||
NSLog("[EeveeSpotify] Unable to load lyrics from \(source), trying Genius as fallback")
|
||||
source = .genius
|
||||
|
||||
plainLyrics = try LyricsRepository.getLyrics(
|
||||
title: track.trackTitle(),
|
||||
artist: track.artistTitle(),
|
||||
spotifyTrackId: track.URI().spt_trackIdentifier(),
|
||||
source: source
|
||||
)
|
||||
}
|
||||
else {
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
let lyrics = try Lyrics.with {
|
||||
$0.colors = LyricsColors.with {
|
||||
@@ -104,7 +127,7 @@ func getCurrentTrackLyricsData() throws -> Data {
|
||||
$0.lineColor = Color.black.uInt32
|
||||
$0.activeLineColor = Color.white.uInt32
|
||||
}
|
||||
$0.data = try LyricsHelper.composeLyricsData(plainLyrics, source: source)
|
||||
$0.data = try LyricsHelper.composeLyricsData(plainLyrics!, source: source)
|
||||
}
|
||||
|
||||
return try lyrics.serializedData()
|
||||
|
||||
@@ -55,7 +55,7 @@ extension Color {
|
||||
|
||||
var normalized: Color {
|
||||
brightness < 0.5
|
||||
? self.lighter(by: 0.5)
|
||||
? self.lighter(by: 0.35)
|
||||
: self.darker(by: brightness - 0.5)
|
||||
}
|
||||
|
||||
|
||||
@@ -6,9 +6,9 @@ extension UserDefaults {
|
||||
|
||||
private static let lyricsSourceKey = "lyricsSource"
|
||||
private static let musixmatchTokenKey = "musixmatchToken"
|
||||
|
||||
static var lyricsSource: LyricsSource {
|
||||
private static let geniusFallbackKey = "geniusFallback"
|
||||
|
||||
static var lyricsSource: LyricsSource {
|
||||
get {
|
||||
if let rawValue = defaults.object(forKey: lyricsSourceKey) as? Int {
|
||||
return LyricsSource(rawValue: rawValue)!
|
||||
@@ -22,7 +22,6 @@ extension UserDefaults {
|
||||
}
|
||||
|
||||
static var musixmatchToken: String {
|
||||
|
||||
get {
|
||||
defaults.string(forKey: musixmatchTokenKey) ?? ""
|
||||
}
|
||||
@@ -30,4 +29,13 @@ extension UserDefaults {
|
||||
defaults.set(token, forKey: musixmatchTokenKey)
|
||||
}
|
||||
}
|
||||
|
||||
static var geniusFallback: Bool {
|
||||
get {
|
||||
defaults.object(forKey: geniusFallbackKey) as? Bool ?? true
|
||||
}
|
||||
set (fallback) {
|
||||
defaults.set(fallback, forKey: geniusFallbackKey)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
import Orion
|
||||
import UIKit
|
||||
|
||||
class SpotifySceneDelegateHook: ClassHook<NSObject> {
|
||||
|
||||
static let targetName = "MusicApp_ContainerWiring.SpotifySceneDelegate"
|
||||
|
||||
func scene(_ scene: UIScene, continueUserActivity userActivity: NSUserActivity) {
|
||||
orig.scene(scene, continueUserActivity: userActivity)
|
||||
}
|
||||
|
||||
func scene(_ scene: UIScene, openURLContexts URLContexts: Set<UIOpenURLContext>) {
|
||||
|
||||
let url = URLContexts.first!.url
|
||||
|
||||
if url.host == "eevee" {
|
||||
|
||||
let userActivity = NSUserActivity(activityType: NSUserActivityTypeBrowsingWeb)
|
||||
userActivity.webpageURL = URL(string: "https:/\(url.path)")
|
||||
|
||||
orig.scene(scene, continueUserActivity: userActivity)
|
||||
return
|
||||
}
|
||||
|
||||
orig.scene(scene, openURLContexts: URLContexts)
|
||||
}
|
||||
}
|
||||
@@ -73,6 +73,20 @@ If the tweak is unable to find a song or process the lyrics, you'll see the orig
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
}
|
||||
}
|
||||
|
||||
if lyricsSource != .genius {
|
||||
Section(
|
||||
footer: Text("Load lyrics from Genius if there is a problem with \(lyricsSource).")
|
||||
) {
|
||||
Toggle(
|
||||
"Genius Fallback",
|
||||
isOn: Binding<Bool>(
|
||||
get: { UserDefaults.geniusFallback },
|
||||
set: { UserDefaults.geniusFallback = $0 }
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.padding(.bottom, 50)
|
||||
|
||||
Reference in New Issue
Block a user