feat!: replace OpenSubsonic with a native mood-first API
Remove the /rest compatibility layer and the playlist model. Moods are now first-class private collections, and playback is driven by short-lived radio sessions whose queues are generated by the server. - Bearer device tokens (hashed) with revocable sessions. - Library snapshot/delta sync with tombstones and per-folder scoping. - Mood CRUD, seeds, preview and recommendations. - Radio batches weighted by seeds, genres, artists, text and playback affinity. - Playback events (started/completed/skipped) and explicit add-to-mood. - Stream, download and cover endpoints with query-token support for browsers. - V5 migration drops playlists and migrates existing moods; scanner writes tombstones and song update timestamps. - Built-in UI rebuilt on the native API with a radio player. - Native API integration tests and a rewritten smoke test (49 checks). - Chart bumped to 0.2.0. BREAKING CHANGE: the OpenSubsonic API and static playlists are gone.
This commit is contained in:
1 parent
28bfdd9d00
commit
b33eb076c1
46 files changed
+3472
-5823
No files matched your search
@@ -12,6 +12,7 @@ import io.ktor.server.plugins.contentnegotiation.ContentNegotiation
|
||||
import io.ktor.server.plugins.partialcontent.PartialContent
|
||||
import io.ktor.server.plugins.statuspages.StatusPages
|
||||
import io.ktor.server.request.path
|
||||
import io.ktor.server.response.respond
|
||||
import io.ktor.server.response.respondRedirect
|
||||
import io.ktor.server.response.respondText
|
||||
import io.ktor.server.routing.get
|
||||
@@ -27,15 +28,16 @@ import org.slf4j.LoggerFactory
|
||||
import win.taptap.musicmanager.config.AppConfig
|
||||
import win.taptap.musicmanager.config.LibraryConfig
|
||||
import win.taptap.musicmanager.config.UsersConfig
|
||||
import win.taptap.musicmanager.api.ApiErrorBody
|
||||
import win.taptap.musicmanager.api.ApiError
|
||||
import win.taptap.musicmanager.api.ApiException
|
||||
import win.taptap.musicmanager.api.apiRoutes
|
||||
import win.taptap.musicmanager.db.ConfigRepository
|
||||
import win.taptap.musicmanager.db.DatabaseFactory
|
||||
import win.taptap.musicmanager.db.MediaRepository
|
||||
import win.taptap.musicmanager.db.MoodRepository
|
||||
import win.taptap.musicmanager.mood.MoodService
|
||||
import win.taptap.musicmanager.radio.RadioService
|
||||
import win.taptap.musicmanager.scanner.CoverArtService
|
||||
import win.taptap.musicmanager.scanner.MediaScanner
|
||||
import win.taptap.musicmanager.subsonic.respondSubsonicError
|
||||
import win.taptap.musicmanager.subsonic.routes.subsonicRoutes
|
||||
import win.taptap.musicmanager.transcoding.FfmpegTranscoder
|
||||
|
||||
private val log = LoggerFactory.getLogger("win.taptap.musicmanager.Application")
|
||||
@@ -53,11 +55,10 @@ fun main() {
|
||||
val applicationScope = CoroutineScope(SupervisorJob() + Dispatchers.IO)
|
||||
val coverArtService = CoverArtService(config.dataDir)
|
||||
val transcoder = FfmpegTranscoder(config.ffmpegPath)
|
||||
val moodService = MoodService(applicationScope)
|
||||
val radioService = RadioService()
|
||||
val scanner = MediaScanner(
|
||||
library = library,
|
||||
coverArtService = coverArtService,
|
||||
onScanFinished = { MoodRepository.markAllStale() },
|
||||
)
|
||||
if (MediaRepository.countSongs() == 0L) {
|
||||
log.info("Song table is empty, starting initial library scan")
|
||||
@@ -84,10 +85,26 @@ fun main() {
|
||||
install(AutoHeadResponse)
|
||||
install(CallLogging)
|
||||
install(StatusPages) {
|
||||
exception<ApiException> { call, cause ->
|
||||
call.respond(
|
||||
cause.status,
|
||||
ApiErrorBody(
|
||||
ApiError(cause.code, cause.message),
|
||||
),
|
||||
)
|
||||
}
|
||||
exception<Throwable> { call, cause ->
|
||||
log.error("Unhandled exception for ${call.request.path()}", cause)
|
||||
if (call.request.path().startsWith("/rest/")) {
|
||||
call.respondSubsonicError(0, "Internal server error")
|
||||
if (call.request.path().startsWith("/api/")) {
|
||||
call.respond(
|
||||
HttpStatusCode.InternalServerError,
|
||||
ApiErrorBody(
|
||||
ApiError(
|
||||
"internal",
|
||||
"Internal server error",
|
||||
),
|
||||
),
|
||||
)
|
||||
} else {
|
||||
call.respondText("Internal server error", status = HttpStatusCode.InternalServerError)
|
||||
}
|
||||
@@ -100,12 +117,12 @@ fun main() {
|
||||
get("/") { call.respondRedirect("/ui") }
|
||||
get("/ui") { call.respondText(webUiHtml, ContentType.Text.Html) }
|
||||
}
|
||||
subsonicRoutes(
|
||||
apiRoutes(
|
||||
users = users,
|
||||
library = library,
|
||||
coverArtService = coverArtService,
|
||||
transcoder = transcoder,
|
||||
moodService = moodService,
|
||||
radioService = radioService,
|
||||
startScan = { scanner.start(applicationScope) },
|
||||
scanStatus = { scanner.status() },
|
||||
)
|
||||
|
||||
Reference in new issue
Block a user