mirror of
https://github.com/whoeevee/EeveeSpotifyReborn.git
synced 2026-01-09 00:23:20 +01:00
imp
This commit is contained in:
@@ -2,4 +2,5 @@ import Foundation
|
||||
|
||||
struct GeniusSong: Decodable {
|
||||
var lyrics: GeniusLyrics
|
||||
}
|
||||
var language: String
|
||||
}
|
||||
|
||||
@@ -145,15 +145,14 @@ struct GeniusLyricsRepository: LyricsRepository {
|
||||
)
|
||||
|
||||
let songInfo = try getSongInfo(song.id)
|
||||
let plainLyrics = songInfo.lyrics.plain
|
||||
let plainLines = plainLyrics.components(separatedBy: "\n")
|
||||
let plainLines = songInfo.lyrics.plain.components(separatedBy: "\n")
|
||||
|
||||
var romanization = LyricsRomanizationStatus.original
|
||||
|
||||
if hasFoundRomanizedLyrics {
|
||||
romanization = .romanized
|
||||
}
|
||||
else if plainLyrics.canBeRomanized {
|
||||
else if songInfo.language.isCanBeRomanizedLanguage {
|
||||
romanization = .canBeRomanized
|
||||
}
|
||||
|
||||
|
||||
@@ -233,7 +233,7 @@ class MusixmatchLyricsRepository: LyricsRepository {
|
||||
if romanized {
|
||||
romanization = .romanized
|
||||
}
|
||||
else if lyricsLines.map({ $0.content }).joined().canBeRomanized {
|
||||
else if subtitleLanguage.isCanBeRomanizedLanguage {
|
||||
romanization = .canBeRomanized
|
||||
}
|
||||
|
||||
@@ -256,6 +256,7 @@ class MusixmatchLyricsRepository: LyricsRepository {
|
||||
|
||||
if let lyricsBody = lyricsMessage["body"] as? [String: Any],
|
||||
let lyrics = lyricsBody["lyrics"] as? [String: Any],
|
||||
let lyricsLanguage = lyrics["lyrics_language"] as? String,
|
||||
let plainLyrics = lyrics["lyrics_body"] as? String {
|
||||
|
||||
if let restricted = lyrics["restricted"] as? Bool, restricted {
|
||||
@@ -268,7 +269,7 @@ class MusixmatchLyricsRepository: LyricsRepository {
|
||||
.dropLast()
|
||||
.map { LyricsLineDto(content: $0.lyricsNoteIfEmpty) },
|
||||
timeSynced: false,
|
||||
romanization: plainLyrics.canBeRomanized ? .canBeRomanized : .original
|
||||
romanization: lyricsLanguage.isCanBeRomanizedLanguage ? .canBeRomanized : .original
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,12 +46,16 @@ extension String {
|
||||
)
|
||||
}
|
||||
|
||||
var isCanBeRomanizedLanguage: Bool {
|
||||
["ja", "ko", "z1"].contains(self) || self.contains("zh")
|
||||
}
|
||||
|
||||
var canBeRomanized: Bool {
|
||||
let languageRecognizer = NLLanguageRecognizer()
|
||||
languageRecognizer.processString(self)
|
||||
|
||||
if let code = languageRecognizer.dominantLanguage?.rawValue {
|
||||
return ["ja", "ko"].contains(code) || code.contains("zh")
|
||||
return code.isCanBeRomanizedLanguage
|
||||
}
|
||||
|
||||
return false
|
||||
|
||||
@@ -21,6 +21,10 @@ extension UserDefaults {
|
||||
return LyricsSource(rawValue: rawValue)!
|
||||
}
|
||||
|
||||
if Locale.isInRegion("JP", orHasLanguage: "ja") {
|
||||
return .petit
|
||||
}
|
||||
|
||||
return .lrclib
|
||||
}
|
||||
set (newSource) {
|
||||
|
||||
Reference in New Issue
Block a user