feat: rebuild AudioManager around downloadable moods
CI / chart (push) Successful in 3s
CI / test (push) Successful in 2m2s
CI / chart-push (push) Successful in 4s
CI / image (push) Successful in 3m20s

- V8 wipe migration and the shared song store keyed by YouTube video id
- media store, indexer, downloader, recommendation top-up and refcounted GC
- mood songs plus the recommendation lifecycle and mixed radio pools
- new search, song and recommendation API; remove library/longform/seed routes
- chart PVC/media env, docs, Nix, README and an end-to-end smoke test
This commit is contained in:
TapTap committed 2026-11-15 21:37:39 +00:00
1 parent 50d8b6c580
commit 824eb36dd2
59 files changed
+3838 -5276

No files matched your search

@@ -13,9 +13,11 @@ class AppConfigTest {
assertEquals(8080, config.port)
assertEquals(Path.of("./data"), config.dataDir)
assertEquals(Path.of("./config/library.yaml"), config.libraryConfigPath)
assertEquals(Path.of("./config/users.yaml"), config.usersFile)
assertEquals("ffmpeg", config.ffmpegPath)
assertEquals("yt-dlp", config.ytDlpPath)
assertEquals(Path.of("./data/media"), config.mediaDir)
assertEquals(Path.of("./data/downloads"), config.downloadDir)
assertEquals(Path.of("./data/musicmanager.db"), config.databasePath)
}
@@ -25,17 +27,21 @@ class AppConfigTest {
mapOf(
"PORT" to "9090",
"DATA_DIR" to "/var/lib/musicmanager",
"LIBRARY_CONFIG" to "/etc/musicmanager/library.yaml",
"USERS_FILE" to "/run/secrets/users.yaml",
"FFMPEG_PATH" to "/usr/bin/ffmpeg",
"YTDLP_PATH" to "/usr/local/bin/yt-dlp",
"MEDIA_DIR" to "/mnt/media",
"DOWNLOAD_DIR" to "/var/tmp/downloads",
),
)
assertEquals(9090, config.port)
assertEquals(Path.of("/var/lib/musicmanager"), config.dataDir)
assertEquals(Path.of("/etc/musicmanager/library.yaml"), config.libraryConfigPath)
assertEquals(Path.of("/run/secrets/users.yaml"), config.usersFile)
assertEquals("/usr/bin/ffmpeg", config.ffmpegPath)
assertEquals("/usr/local/bin/yt-dlp", config.ytDlpPath)
assertEquals(Path.of("/mnt/media"), config.mediaDir)
assertEquals(Path.of("/var/tmp/downloads"), config.downloadDir)
}
@Test
@@ -1,127 +0,0 @@
package win.taptap.musicmanager.config
import java.nio.file.Files
import kotlin.io.path.createTempDirectory
import kotlin.test.Test
import kotlin.test.assertEquals
import kotlin.test.assertFailsWith
import kotlin.test.assertTrue
class LibraryConfigTest {
private val validYaml = """
library:
folders:
- id: 1
name: "Music"
type: music
path: "./media/music"
- id: 10
name: "Long-form"
type: longform
path: "./media/longform"
""".trimIndent()
@Test
fun `parses folders and resolves absolute paths`() {
val config = LibraryConfig.parse(validYaml)
assertEquals(2, config.folders.size)
assertEquals(setOf(10), config.longformFolderIds)
assertEquals(FolderType.MUSIC, config.folders[0].type)
assertEquals(FolderType.LONGFORM, config.folders[1].type)
assertTrue(config.folders[0].path.isAbsolute)
assertEquals(1, config.byId(1)?.id)
}
@Test
fun `rejects duplicate folder ids`() {
val yaml = """
library:
folders:
- id: 1
name: A
type: music
path: /music/a
- id: 1
name: B
type: music
path: /music/b
""".trimIndent()
assertFailsWith<IllegalArgumentException> { LibraryConfig.parse(yaml) }
}
@Test
fun `rejects duplicate folder paths`() {
val yaml = """
library:
folders:
- id: 1
name: A
type: music
path: /music/a
- id: 2
name: B
type: music
path: /music/a
""".trimIndent()
assertFailsWith<IllegalArgumentException> { LibraryConfig.parse(yaml) }
}
@Test
fun `rejects unknown folder types`() {
val yaml = """
library:
folders:
- id: 1
name: A
type: video
path: /music/a
""".trimIndent()
assertFailsWith<IllegalArgumentException> { LibraryConfig.parse(yaml) }
}
@Test
fun `validatePaths fails for a missing root`() {
val root = createTempDirectory("musicmanager-test")
try {
val yaml = """
library:
folders:
- id: 1
name: A
type: music
path: "${root.resolve("missing")}"
""".trimIndent()
assertFailsWith<IllegalArgumentException> {
LibraryConfig.parse(yaml).validatePaths()
}
} finally {
root.toFile().deleteRecursively()
}
}
@Test
fun `validatePaths accepts existing readable roots`() {
val root = createTempDirectory("musicmanager-test")
try {
val music = Files.createDirectories(root.resolve("music"))
val yaml = """
library:
folders:
- id: 1
name: A
type: music
path: "$music"
""".trimIndent()
LibraryConfig.parse(yaml).validatePaths()
} finally {
root.toFile().deleteRecursively()
}
}
}
@@ -8,48 +8,26 @@ import kotlin.test.assertTrue
class UsersConfigTest {
private val library = LibraryConfig.parse(
"""
library:
folders:
- id: 1
name: "Music A"
type: music
path: /music/a
- id: 2
name: "Music B"
type: music
path: /music/b
- id: 10
name: "Long-form"
type: longform
path: /longform
""".trimIndent(),
)
private val usersYaml = """
users:
- name: alice
password: "secret-a"
admin: true
folders: [1]
- name: bob
password: "secret-b"
folders: [1, 2]
""".trimIndent()
@Test
fun `parses users and shares long-form folders`() {
val users = UsersConfig.parse(usersYaml)
users.validateAgainst(library)
fun `parses users and ignores old folder assignments`() {
val users = UsersConfig.parse(
"""
users:
- name: alice
password: "secret-a"
admin: true
folders: [1]
- name: bob
password: "secret-b"
""".trimIndent(),
)
val alice = users.byName("alice")!!
val bob = users.byName("bob")!!
assertTrue(alice.admin)
assertFalse(bob.admin)
assertEquals(setOf(1, 10), alice.visibleFolderIds(library))
assertEquals(setOf(1, 2, 10), bob.visibleFolderIds(library))
assertEquals(2, users.users.size)
}
@Test
@@ -57,7 +35,6 @@ class UsersConfigTest {
val yaml = """
users:
- name: alice
folders: [1]
""".trimIndent()
assertFailsWith<IllegalArgumentException> { UsersConfig.parse(yaml) }
@@ -69,56 +46,27 @@ class UsersConfigTest {
users:
- name: alice
password: a
folders: [1]
- name: alice
password: b
folders: [2]
""".trimIndent()
assertFailsWith<IllegalArgumentException> { UsersConfig.parse(yaml) }
}
@Test
fun `rejects unknown folder references`() {
val users = UsersConfig.parse(
"""
users:
- name: alice
password: a
folders: [99]
""".trimIndent(),
)
assertFailsWith<IllegalArgumentException> { users.validateAgainst(library) }
}
@Test
fun `rejects a user with no visible folders`() {
val emptyLibrary = LibraryConfig.parse(
"""
library:
folders:
- id: 1
name: "Music"
type: music
path: /music
""".trimIndent(),
)
val users = UsersConfig.parse(
"""
users:
- name: alice
password: a
folders: []
""".trimIndent(),
)
assertFailsWith<IllegalArgumentException> { users.validateAgainst(emptyLibrary) }
fun `rejects an empty user list`() {
assertFailsWith<IllegalArgumentException> { UsersConfig.parse("users: []") }
}
@Test
fun `does not expose passwords in toString`() {
val alice = UsersConfig.parse(usersYaml).byName("alice")!!
val alice = UsersConfig.parse(
"""
users:
- name: alice
password: "secret-a"
""".trimIndent(),
).byName("alice")!!
assertFalse(alice.toString().contains("secret-a"))
assertTrue(alice.toString().contains("password=***"))