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
@@ -0,0 +1,240 @@
|
||||
package win.taptap.musicmanager.api
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
import win.taptap.musicmanager.db.MoodRecord
|
||||
import win.taptap.musicmanager.db.MoodSeedRecord
|
||||
import win.taptap.musicmanager.db.SongRecord
|
||||
|
||||
@Serializable
|
||||
data class ApiErrorBody(val error: ApiError)
|
||||
|
||||
@Serializable
|
||||
data class ApiError(val code: String, val message: String)
|
||||
|
||||
@Serializable
|
||||
data class LoginRequest(
|
||||
val username: String,
|
||||
val password: String,
|
||||
val deviceName: String = "Unknown device",
|
||||
val platform: String = "unknown",
|
||||
)
|
||||
|
||||
@Serializable
|
||||
data class UserDto(
|
||||
val name: String,
|
||||
val admin: Boolean,
|
||||
val musicFolders: List<Int>,
|
||||
val longformFolders: List<Int>,
|
||||
)
|
||||
|
||||
@Serializable
|
||||
data class LoginResponse(
|
||||
val token: String,
|
||||
val expiresAt: String,
|
||||
val user: UserDto,
|
||||
)
|
||||
|
||||
@Serializable
|
||||
data class DeviceDto(
|
||||
val id: String,
|
||||
val deviceName: String,
|
||||
val platform: String,
|
||||
val createdAt: String,
|
||||
val lastUsedAt: String,
|
||||
val expiresAt: String,
|
||||
val current: Boolean,
|
||||
)
|
||||
|
||||
@Serializable
|
||||
data class SongDto(
|
||||
val id: String,
|
||||
val title: String,
|
||||
val artist: String,
|
||||
val album: String,
|
||||
val albumId: String,
|
||||
val trackNumber: Int? = null,
|
||||
val discNumber: Int = 1,
|
||||
val year: Int? = null,
|
||||
val duration: Int,
|
||||
val bitRate: Int,
|
||||
val size: Long,
|
||||
val suffix: String,
|
||||
val genres: List<String> = emptyList(),
|
||||
val folderId: Int,
|
||||
val relativePath: String,
|
||||
val updatedAt: String,
|
||||
)
|
||||
|
||||
fun SongRecord.toDto(): SongDto = SongDto(
|
||||
id = id,
|
||||
title = title,
|
||||
artist = displayArtist,
|
||||
album = albumName,
|
||||
albumId = albumId,
|
||||
trackNumber = trackNumber,
|
||||
discNumber = discNumber,
|
||||
year = year,
|
||||
duration = duration,
|
||||
bitRate = bitRate,
|
||||
size = size,
|
||||
suffix = suffix,
|
||||
genres = genres,
|
||||
folderId = folderId,
|
||||
relativePath = relativePath,
|
||||
updatedAt = updatedAt,
|
||||
)
|
||||
|
||||
@Serializable
|
||||
data class SeedDto(
|
||||
val song: SongDto,
|
||||
val origin: String,
|
||||
val addedAt: String,
|
||||
)
|
||||
|
||||
@Serializable
|
||||
data class MoodDto(
|
||||
val id: String,
|
||||
val name: String,
|
||||
val description: String? = null,
|
||||
val query: String? = null,
|
||||
val genres: List<String> = emptyList(),
|
||||
val targetSize: Int,
|
||||
val refreshHours: Int,
|
||||
val ytEnabled: Boolean,
|
||||
val lastDiscoveryAt: String? = null,
|
||||
val createdAt: String,
|
||||
val changedAt: String,
|
||||
val lastError: String? = null,
|
||||
val seedCount: Int,
|
||||
val newRecommendations: Int,
|
||||
)
|
||||
|
||||
fun MoodRecord.toDto(): MoodDto = MoodDto(
|
||||
id = id,
|
||||
name = name,
|
||||
description = description,
|
||||
query = query,
|
||||
genres = genres,
|
||||
targetSize = targetSize,
|
||||
refreshHours = refreshHours,
|
||||
ytEnabled = ytEnabled,
|
||||
lastDiscoveryAt = lastDiscoveryAt,
|
||||
createdAt = createdAt,
|
||||
changedAt = changedAt,
|
||||
lastError = lastError,
|
||||
seedCount = seedCount,
|
||||
newRecommendations = newRecommendations,
|
||||
)
|
||||
|
||||
@Serializable
|
||||
data class MoodDetailDto(
|
||||
val mood: MoodDto,
|
||||
val seeds: List<SeedDto>,
|
||||
val recommendations: List<RecommendationDto> = emptyList(),
|
||||
)
|
||||
|
||||
@Serializable
|
||||
data class CreateMoodRequest(
|
||||
val name: String,
|
||||
val description: String? = null,
|
||||
val query: String? = null,
|
||||
val genres: List<String> = emptyList(),
|
||||
val targetSize: Int = 30,
|
||||
val refreshHours: Int = 24,
|
||||
val ytEnabled: Boolean = true,
|
||||
val seedSongIds: List<String> = emptyList(),
|
||||
)
|
||||
|
||||
@Serializable
|
||||
data class UpdateMoodRequest(
|
||||
val name: String? = null,
|
||||
val description: String? = null,
|
||||
val clearDescription: Boolean = false,
|
||||
val query: String? = null,
|
||||
val clearQuery: Boolean = false,
|
||||
val genres: List<String>? = null,
|
||||
val targetSize: Int? = null,
|
||||
val refreshHours: Int? = null,
|
||||
val ytEnabled: Boolean? = null,
|
||||
)
|
||||
|
||||
@Serializable
|
||||
data class AddSeedRequest(val songId: String, val origin: String = "manual")
|
||||
|
||||
@Serializable
|
||||
data class AddToMoodRequest(val songId: String, val moodId: String? = null)
|
||||
|
||||
@Serializable
|
||||
data class AddToMoodResponse(
|
||||
val mood: MoodDto,
|
||||
val added: Boolean,
|
||||
)
|
||||
|
||||
@Serializable
|
||||
data class LibraryPage(
|
||||
val songs: List<SongDto>,
|
||||
val deletedSongIds: List<String> = emptyList(),
|
||||
val revision: String,
|
||||
val nextCursor: String? = null,
|
||||
val nextSince: String? = null,
|
||||
)
|
||||
|
||||
@Serializable
|
||||
data class SearchResponse(val songs: List<SongDto>)
|
||||
|
||||
@Serializable
|
||||
data class StartSessionRequest(val limit: Int? = null)
|
||||
|
||||
@Serializable
|
||||
data class NextTracksRequest(
|
||||
val limit: Int? = null,
|
||||
val excludeSongIds: List<String> = emptyList(),
|
||||
)
|
||||
|
||||
@Serializable
|
||||
data class SessionDto(
|
||||
val id: String,
|
||||
val moodId: String,
|
||||
val moodName: String,
|
||||
val startedAt: String,
|
||||
val closedAt: String? = null,
|
||||
val queue: List<SongDto> = emptyList(),
|
||||
)
|
||||
|
||||
@Serializable
|
||||
data class PlaybackEvent(
|
||||
val songId: String,
|
||||
val type: String,
|
||||
val positionSeconds: Int? = null,
|
||||
)
|
||||
|
||||
@Serializable
|
||||
data class PlaybackEventsRequest(val events: List<PlaybackEvent>)
|
||||
|
||||
@Serializable
|
||||
data class PlaybackEventsResponse(val accepted: Int)
|
||||
|
||||
@Serializable
|
||||
data class ScanStatusDto(
|
||||
val scanning: Boolean,
|
||||
val count: Long,
|
||||
val error: String? = null,
|
||||
)
|
||||
|
||||
@Serializable
|
||||
data class RecommendationDto(
|
||||
val videoId: String,
|
||||
val title: String,
|
||||
val artist: String,
|
||||
val album: String? = null,
|
||||
val duration: Int? = null,
|
||||
val thumbnail: String? = null,
|
||||
val state: String,
|
||||
val matchedSong: SongDto? = null,
|
||||
val timesAdded: Int,
|
||||
val firstSeen: String,
|
||||
val lastSeen: String,
|
||||
)
|
||||
|
||||
fun seedDto(seed: MoodSeedRecord, song: SongRecord): SeedDto =
|
||||
SeedDto(song = song.toDto(), origin = seed.origin, addedAt = seed.addedAt)
|
||||
Reference in new issue
Block a user