fix(subsonic): answer what the OpenSubsonic spec and Subsonic apps require

- getOpenSubsonicExtensions answers, without credentials, as the spec
  requires of a server that says openSubsonic=true; it lists
  apiKeyAuthentication. An apiKey sent with u is error 43 and an unknown
  apiKey error 44, the extension's codes; a wrong key still counts toward the
  sign-in throttle.
- search3 with an empty query (or two quote marks) matches everything, paged
  in a stable order, so apps that keep a copy of the library (Symfonium) can
  download it. A page of songs reads its albums and artists in two queries,
  not two per song.
- getAlbumList2 serves type=starred and highest (the listener's liked
  albums) and byYear (oldest first, newest first for a backwards range).
- Internet radio, podcasts, bookmarks, shares, chat and now-playing answer
  with an empty list instead of "Method not implemented", so an app shows an
  empty tab rather than an error.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-25 13:14:31 -05:00
co-authored by Claude Opus 5.5
parent 1efc65ee10
commit cd78529ae8
14 changed files with 575 additions and 50 deletions
+66
View File
@@ -166,6 +166,72 @@ func (q *Queries) ListAlbumsByGenreWithArtist(ctx context.Context, arg ListAlbum
return items, nil
}
const listAlbumsByYearOrdered = `-- name: ListAlbumsByYearOrdered :many
SELECT albums.id, albums.title, albums.sort_title, albums.artist_id, albums.release_date, albums.mbid, albums.cover_art_path, albums.created_at, albums.updated_at, albums.cover_art_source, albums.cover_art_sources_version, albums.release_group_mbid, albums.announced_at FROM albums
WHERE albums.release_date IS NOT NULL
AND EXTRACT(YEAR FROM albums.release_date)::int
BETWEEN LEAST($1::int, $2::int)
AND GREATEST($1::int, $2::int)
AND EXISTS (
SELECT 1 FROM tracks
WHERE tracks.album_id = albums.id
AND tracks.missing_since IS NULL
)
ORDER BY CASE WHEN $1::int <= $2::int THEN albums.release_date END ASC,
CASE WHEN $1::int > $2::int THEN albums.release_date END DESC,
albums.sort_title, albums.id
LIMIT $4 OFFSET $3
`
type ListAlbumsByYearOrderedParams struct {
FromYear int32
ToYear int32
Off int32
Lim int32
}
// Subsonic getAlbumList2 type=byYear: albums released within an inclusive
// year range, oldest first, or newest first when the caller asks for the
// range backwards (fromYear > toYear), as the Subsonic API defines it.
func (q *Queries) ListAlbumsByYearOrdered(ctx context.Context, arg ListAlbumsByYearOrderedParams) ([]Album, error) {
rows, err := q.db.Query(ctx, listAlbumsByYearOrdered,
arg.FromYear,
arg.ToYear,
arg.Off,
arg.Lim,
)
if err != nil {
return nil, err
}
defer rows.Close()
var items []Album
for rows.Next() {
var i Album
if err := rows.Scan(
&i.ID,
&i.Title,
&i.SortTitle,
&i.ArtistID,
&i.ReleaseDate,
&i.Mbid,
&i.CoverArtPath,
&i.CreatedAt,
&i.UpdatedAt,
&i.CoverArtSource,
&i.CoverArtSourcesVersion,
&i.ReleaseGroupMbid,
&i.AnnouncedAt,
); err != nil {
return nil, err
}
items = append(items, i)
}
if err := rows.Err(); err != nil {
return nil, err
}
return items, nil
}
const listAlbumsByYearRangeWithArtist = `-- name: ListAlbumsByYearRangeWithArtist :many
SELECT albums.id, albums.title, albums.sort_title, albums.artist_id, albums.release_date, albums.mbid, albums.cover_art_path, albums.created_at, albums.updated_at, albums.cover_art_source, albums.cover_art_sources_version, albums.release_group_mbid, albums.announced_at, artists.name AS artist_name
FROM albums