feat: recommend from Deezer and YouTube Music radios
- Deezer: /artist/{id}/radio for collection artists, affinity 2.0
- YouTube Music: RDAMVM watch playlist via yt-dlp, affinity 2.0
- seed radios from the 2 newest songs of the mood's own catalog
- dedupe candidates by recording, not only by external id
- clean raw YouTube titles and Topic suffixes when indexing
- tests, smoke marker for the RDAMVM path, docs
This commit is contained in:
1 parent
62bcefad20
commit
26c41cc7d9
12 files changed
+296
-44
No files matched your search
@@ -0,0 +1,36 @@
|
||||
package win.taptap.musicmanager.discovery
|
||||
|
||||
private const val NOISE_WORDS =
|
||||
"official|lyrics?|audio|video|visuali[sz]er|mv|hd|4k|remaster(?:ed)?"
|
||||
|
||||
private val TITLE_NOISE = Regex(
|
||||
"\\((?:$NOISE_WORDS)[^)]*\\)" +
|
||||
"|\\[(?:$NOISE_WORDS)[^\\]]*\\]" +
|
||||
"|\\s*\\|\\s*(?:$NOISE_WORDS).*$",
|
||||
RegexOption.IGNORE_CASE,
|
||||
)
|
||||
|
||||
private val WHITESPACE = Regex("\\s+")
|
||||
|
||||
/**
|
||||
* Removes the upload noise that YouTube titles carry ("(Official Video)",
|
||||
* "[4K Remaster]", "| Lyrics"), so a search hit, a download tag and an existing
|
||||
* collection row compare as the same song.
|
||||
*/
|
||||
internal fun cleanTrackTitle(rawTitle: String): String =
|
||||
rawTitle.replace(TITLE_NOISE, "")
|
||||
.replace(WHITESPACE, " ")
|
||||
.trim()
|
||||
.ifEmpty { rawTitle.trim() }
|
||||
|
||||
/**
|
||||
* `"Daft Punk - Get Lucky"` tagged by the plain YouTube extractor still has the
|
||||
* artist in the title. Strip it when it matches the tagged artist.
|
||||
*/
|
||||
internal fun stripArtistPrefix(title: String, artist: String): String {
|
||||
val name = artist.trim()
|
||||
if (name.isEmpty() || name.equals("Unknown artist", ignoreCase = true)) return title
|
||||
val prefix = "$name - "
|
||||
if (!title.startsWith(prefix, ignoreCase = true)) return title
|
||||
return title.substring(prefix.length).trim().ifEmpty { title }
|
||||
}
|
||||
Reference in new issue
Block a user