Remove synchronized lyrics line trimming based on song title
This commit is contained in:
@@ -55,10 +55,7 @@ object KuGou {
|
|||||||
for (info in searchSong(keyword(artist, title))) {
|
for (info in searchSong(keyword(artist, title))) {
|
||||||
if (info.duration >= duration / 1000 - 2 && info.duration <= duration / 1000 + 2) {
|
if (info.duration >= duration / 1000 - 2 && info.duration <= duration / 1000 + 2) {
|
||||||
searchLyrics(info.hash).firstOrNull()?.let { candidate ->
|
searchLyrics(info.hash).firstOrNull()?.let { candidate ->
|
||||||
return@runCatching downloadLyrics(
|
return@runCatching downloadLyrics(candidate.id, candidate.accessKey).normalize()
|
||||||
candidate.id,
|
|
||||||
candidate.accessKey
|
|
||||||
).normalize(title)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -117,7 +114,10 @@ object KuGou {
|
|||||||
|
|
||||||
if (endIndex == -1) return this to ""
|
if (endIndex == -1) return this to ""
|
||||||
|
|
||||||
return removeRange(startIndex, endIndex + 1) to substring(startIndex + startDelimiter.length, endIndex)
|
return removeRange(
|
||||||
|
startIndex,
|
||||||
|
endIndex + 1
|
||||||
|
) to substring(startIndex + startDelimiter.length, endIndex)
|
||||||
}
|
}
|
||||||
|
|
||||||
@JvmInline
|
@JvmInline
|
||||||
@@ -141,7 +141,7 @@ object KuGou {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun normalize(title: String): Lyrics {
|
fun normalize(): Lyrics {
|
||||||
var toDrop = 0
|
var toDrop = 0
|
||||||
var maybeToDrop = 0
|
var maybeToDrop = 0
|
||||||
|
|
||||||
@@ -163,8 +163,7 @@ object KuGou {
|
|||||||
line.containsAt("]Composed by:", 9) ||
|
line.containsAt("]Composed by:", 9) ||
|
||||||
line.containsAt("]Producer:", 9) ||
|
line.containsAt("]Producer:", 9) ||
|
||||||
line.containsAt("]作曲 : ", 9) ||
|
line.containsAt("]作曲 : ", 9) ||
|
||||||
line.containsAt("]作词 : ", 9) ||
|
line.containsAt("]作词 : ", 9)
|
||||||
line.containsAt("]$title", 9)
|
|
||||||
) {
|
) {
|
||||||
toDrop += line.length + 1 + maybeToDrop
|
toDrop += line.length + 1 + maybeToDrop
|
||||||
maybeToDrop = 0
|
maybeToDrop = 0
|
||||||
|
|||||||
Reference in New Issue
Block a user