mirror of
https://github.com/whoeevee/EeveeSpotifyReborn.git
synced 2026-01-09 00:23:20 +01:00
Use Romaji Lyrics when avaible with Genius toggle. (#227)
* Update GeniusLyricsRepository.swift * Update GeniusLyricsRepository.swift * Update EeveeSettingsViewController+LyricsSections.swift * Update UserDefaults+Extension.swift * Update GeniusLyricsRepository.swift * Update GeniusLyricsRepository.swift * Update GeniusLyricsRepository.swift * Update UserDefaults+Extension.swift * Update EeveeSettingsViewController+LyricsSections.swift * Update EeveeSettingsViewController+LyricsSections.swift
This commit is contained in:
@@ -104,19 +104,39 @@ struct GeniusLyricsRepository: LyricsRepository {
|
||||
|
||||
func getLyrics(_ query: LyricsSearchQuery) throws -> LyricsDto {
|
||||
let strippedTitle = query.title.strippedTrackTitle
|
||||
let hits = try searchSong("\(strippedTitle) \(query.primaryArtist)")
|
||||
var queries = [
|
||||
"\(strippedTitle) \(query.primaryArtist)"
|
||||
]
|
||||
|
||||
guard let song = mostRelevantHitResult(hits: hits, strippedTitle: strippedTitle) else {
|
||||
if UserDefaults.romanizedLyrics {
|
||||
queries = [
|
||||
"\(strippedTitle) \(query.primaryArtist) (Romanized)",
|
||||
"\(strippedTitle) \(query.primaryArtist)"
|
||||
]
|
||||
}
|
||||
var hits: [GeniusHit] = []
|
||||
|
||||
for searchQuery in queries {
|
||||
do {
|
||||
hits = try searchSong(searchQuery)
|
||||
if !hits.isEmpty {
|
||||
break
|
||||
}
|
||||
} catch {
|
||||
// Continue to the next query if the current one fails
|
||||
}
|
||||
}
|
||||
|
||||
guard !hits.isEmpty,
|
||||
let song = mostRelevantHitResult(hits: hits, strippedTitle: strippedTitle) else {
|
||||
throw LyricsError.NoSuchSong
|
||||
}
|
||||
|
||||
|
||||
let songInfo = try getSongInfo(song.id)
|
||||
let plainLines = songInfo.lyrics.plain.components(separatedBy: "\n")
|
||||
|
||||
|
||||
return LyricsDto(
|
||||
lines: mapLyricsLines(plainLines).map {
|
||||
line in LyricsLineDto(content: line)
|
||||
},
|
||||
lines: mapLyricsLines(plainLines).map { line in LyricsLineDto(content: line) },
|
||||
timeSynced: false
|
||||
)
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ extension UserDefaults {
|
||||
private static let lyricsSourceKey = "lyricsSource"
|
||||
private static let musixmatchTokenKey = "musixmatchToken"
|
||||
private static let geniusFallbackKey = "geniusFallback"
|
||||
private static let romanizedLyricsKey = "romanizedLyrics"
|
||||
private static let fallbackReasonsKey = "fallbackReasons"
|
||||
private static let darkPopUpsKey = "darkPopUps"
|
||||
private static let patchTypeKey = "patchType"
|
||||
@@ -43,6 +44,15 @@ extension UserDefaults {
|
||||
defaults.set(fallback, forKey: geniusFallbackKey)
|
||||
}
|
||||
}
|
||||
|
||||
static var romanizedLyrics: Bool {
|
||||
get {
|
||||
defaults.object(forKey: romanizedLyricsKey) as? Bool ?? false
|
||||
}
|
||||
set (romanized) {
|
||||
defaults.set(romanized, forKey: romanizedLyricsKey)
|
||||
}
|
||||
}
|
||||
|
||||
static var fallbackReasons: Bool {
|
||||
get {
|
||||
|
||||
@@ -104,6 +104,18 @@ If the tweak is unable to find a song or process the lyrics, you'll see a "Could
|
||||
|
||||
UserDefaults.lyricsSource = newSource
|
||||
}
|
||||
|
||||
if lyricsSource == .genius {
|
||||
Section {
|
||||
Toggle(
|
||||
"Use Romanized (Romaji) Lyrics when Available",
|
||||
isOn: Binding<Bool>(
|
||||
get: { UserDefaults.romanizedLyrics },
|
||||
set: { UserDefaults.romanizedLyrics = $0 }
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
if lyricsSource != .genius {
|
||||
Section(
|
||||
|
||||
Reference in New Issue
Block a user