feat(subsonic): scan status, artist and album info, lyrics, ratings and users
release / go (push) Failing after 1m15s
release / web (push) Successful in 1m18s
release / govulncheck (push) Successful in 21s
release / integration (push) Successful in 3m57s
release / Attach APK to the Release (tag releases only) (push) Canceled after 0s
release / Build + push container image (push) Canceled after 0s
release / Verify release artifacts (tag releases only) (push) Canceled after 0s
release / android (push) Canceled after 4m33s
release / Build signed APK (push) Canceled after 4m9s

The last Subsonic methods apps call that Minstrel didn't answer:

- getScanStatus counts the songs whose files are present and says
  whether a scan is running; startScan, for an admin, starts the scan the
  web app's Rescan starts, and answers "scanning" straight away since the
  scan records itself a moment later.
- getArtistInfo and getArtistInfo2 give the artist's MusicBrainz id and the
  artists in this library that sound like them, from an artist, album or
  song id; getAlbumInfo and getAlbumInfo2 give the album's MusicBrainz id.
  Minstrel fetches no biographies or outside images, so none are sent.
- getLyrics (by artist and title) and getLyricsBySongId (OpenSubsonic
  songLyrics, now declared) read lyrics when asked: a .lrc file beside the
  song gives timed lyrics, otherwise the song's own lyrics tag.
- setRating accepts a rating and keeps none: a like is Minstrel's only
  rating, and a low rating is never read as a dislike.
- getUsers lists every user, for an admin only.

ArtistRef no longer fixes its XML element name, so it can appear as
similarArtist; every field holding it names the element.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-25 17:43:13 -05:00
co-authored by Claude Opus 5.5
parent b801f81058
commit f87aba5b86
14 changed files with 1022 additions and 18 deletions
+87
View File
@@ -108,6 +108,18 @@ func (q *Queries) CountMissingTracks(ctx context.Context) (int64, error) {
return count, err
}
const countPlayableTracks = `-- name: CountPlayableTracks :one
SELECT count(*) FROM tracks WHERE missing_since IS NULL
`
// The songs whose files are present, for the Subsonic getScanStatus count.
func (q *Queries) CountPlayableTracks(ctx context.Context) (int64, error) {
row := q.db.QueryRow(ctx, countPlayableTracks)
var count int64
err := row.Scan(&count)
return count, err
}
const countSuspectSourceTracks = `-- name: CountSuspectSourceTracks :one
SELECT COUNT(*) FROM tracks t
WHERE t.missing_since IS NULL
@@ -1025,6 +1037,81 @@ func (q *Queries) ListTracksByAlbum(ctx context.Context, arg ListTracksByAlbumPa
return items, nil
}
const listTracksByArtistAndTitle = `-- name: ListTracksByArtistAndTitle :many
SELECT t.id, t.title, t.album_id, t.artist_id, t.track_number, t.disc_number, t.duration_ms, t.file_path, t.file_size, t.file_format, t.bitrate, t.mbid, t.genre, t.added_at, t.updated_at, t.tag_source, t.tag_sources_version, t.tag_read_version, t.missing_since, t.mbid_source, t.song_id, t.song_key, t.source_verdict, t.source_verdict_at, t.emptied_at, t.removed_reason, t.removed_by, t.artist_credit
FROM tracks t
JOIN artists ar ON ar.id = t.artist_id
WHERE lower(t.title) = lower($1::text)
AND ($2::text = ''
OR lower(ar.name) = lower($2::text)
OR lower(coalesce(t.artist_credit, '')) = lower($2::text))
AND t.missing_since IS NULL
ORDER BY t.id
LIMIT 20
`
type ListTracksByArtistAndTitleParams struct {
Title string
ArtistName string
}
type ListTracksByArtistAndTitleRow struct {
Track Track
}
// Songs matching a title, and an artist when one is given, both regardless
// of case, for the Subsonic getLyrics, which names the song rather than
// giving an id. The artist matches the filing artist or the song's own
// credit ("Low Tide Choir feat. Ruby Calloway").
func (q *Queries) ListTracksByArtistAndTitle(ctx context.Context, arg ListTracksByArtistAndTitleParams) ([]ListTracksByArtistAndTitleRow, error) {
rows, err := q.db.Query(ctx, listTracksByArtistAndTitle, arg.Title, arg.ArtistName)
if err != nil {
return nil, err
}
defer rows.Close()
var items []ListTracksByArtistAndTitleRow
for rows.Next() {
var i ListTracksByArtistAndTitleRow
if err := rows.Scan(
&i.Track.ID,
&i.Track.Title,
&i.Track.AlbumID,
&i.Track.ArtistID,
&i.Track.TrackNumber,
&i.Track.DiscNumber,
&i.Track.DurationMs,
&i.Track.FilePath,
&i.Track.FileSize,
&i.Track.FileFormat,
&i.Track.Bitrate,
&i.Track.Mbid,
&i.Track.Genre,
&i.Track.AddedAt,
&i.Track.UpdatedAt,
&i.Track.TagSource,
&i.Track.TagSourcesVersion,
&i.Track.TagReadVersion,
&i.Track.MissingSince,
&i.Track.MbidSource,
&i.Track.SongID,
&i.Track.SongKey,
&i.Track.SourceVerdict,
&i.Track.SourceVerdictAt,
&i.Track.EmptiedAt,
&i.Track.RemovedReason,
&i.Track.RemovedBy,
&i.Track.ArtistCredit,
); err != nil {
return nil, err
}
items = append(items, i)
}
if err := rows.Err(); err != nil {
return nil, err
}
return items, nil
}
const listTracksMissingMbidWithPath = `-- name: ListTracksMissingMbidWithPath :many
SELECT id, file_path
FROM tracks