feat(subsonic): browsing, search, media, playlist, annotation endpoints
Thin adapters over the existing services/repositories (no business logic): - system: ping (auth check), getLicense - browsing: getArtists/getArtist/getAlbum, getAlbumList(2) (newest/alpha/random), getSong, getGenres, getMusicFolders/getIndexes/getMusicDirectory (one folder) - search: search3 (delegates to the library repos) - media: stream + download (reuse StreamingService, honor Range); getCoverArt returns a placeholder until the cover pipeline lands - playlists: get/create/update/delete over the playlist repo (owner-scoped) - annotation: star/unstar → append-only like log, scrobble → play history, setRating → clean no-op - all endpoints also accept the .view suffix and GET+POST for client compat Repo support: album list ordering (newest/random), track genre facets. README documents the mandatory-HTTPS requirement and app-password workflow. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -87,6 +87,21 @@ class SqlAlchemyTrackRepository:
|
||||
await self._session.delete(row)
|
||||
await self._session.flush()
|
||||
|
||||
async def genres(self) -> list[tuple[str, int]]:
|
||||
"""Distinct non-null genres with their song counts, most common first.
|
||||
|
||||
Defined before ``list`` — the method named ``list`` shadows the builtin
|
||||
in later annotations within the class body."""
|
||||
rows = (
|
||||
await self._session.execute(
|
||||
select(TrackModel.genre, func.count(TrackModel.id).label("cnt"))
|
||||
.where(TrackModel.genre.is_not(None))
|
||||
.group_by(TrackModel.genre)
|
||||
.order_by(func.count(TrackModel.id).desc())
|
||||
)
|
||||
).all()
|
||||
return [(row.genre, row.cnt) for row in rows]
|
||||
|
||||
async def list(
|
||||
self,
|
||||
*,
|
||||
|
||||
Reference in New Issue
Block a user