Skip to content

feat: add GET /library/albums and /library/artists - #405

Merged
devgianlu merged 1 commit into
devgianlu:masterfrom
isnogudus:feature/library-collections
Oct 18, 2026
Merged

devgianlu merged 1 commit into
devgianlu:masterfrom
isnogudus:feature/library-collections

Conversation

@isnogudus

@isnogudus isnogudus commented Sep 27, 2026 •

Copy link
Copy Markdown

Adds GET /library/albums and GET /library/artists, listing the albums saved in the user's library and the artists they follow, most recent first, so a client can browse the whole library through the daemon:

  • The lists come from the collection service added in feat: save to Liked Songs and add to playlists #403: saved albums share the collection set with Liked Songs, followed artists are the artist set.
  • Names, artists, release year and images come from one batched extended-metadata request per 100 entities (ALBUM_V4 / ARTIST_V4), with image URLs built like album_cover_url (honouring image_size). Entries whose metadata does not resolve are still listed by URI.
  • Both lists are cached per user for a minute and paged with offset/limit like /library/playlists; the paging validation is now shared by the three listings.
  • Albums and artists can be opened or played by URI through the existing /context/tracks and /player/play.

Testing

  • Unit tests for the newest-first ordering (skipping removed items and other types), the per-user cache with TTL, paging bounds and the album/artist mapping including missing metadata; API tests for routing and validation.
  • Ran against a real account: 98 saved albums and 38 followed artists with names, years and cover URLs.
  • go mod tidy, go generate ./..., gofmt, build and go test -tags "test_unit test_integration" ./... are clean.

🤖 Generated with Claude Code

@isnogudus
isnogudus force-pushed the feature/library-collections branch 2 times, most recently from 6285332 to f4821e8 Compare October 1, 2026 12:39
@isnogudus
isnogudus force-pushed the feature/library-collections branch 2 times, most recently from ba45010 to c543fdc Compare October 3, 2026 13:32
@isnogudus
isnogudus force-pushed the feature/library-collections branch from c543fdc to 51db3e7 Compare October 14, 2026 20:38
@devgianlu

Copy link
Copy Markdown
Owner

Is the cache really needed? It adds a bunch of complexity

List the albums saved in the user's library and the artists the user
follows, most recent first. The lists come from the collection service
(saved albums share the "collection" set with Liked Songs, followed
artists are the "artist" set) and names, years and images from batched
extended metadata, so neither goes through the rate-limited Web API.
Like /library/playlists, every request reads the list and pages it in
memory; only the requested page's entities are looked up.

The sets are read with the new Spclient.CollectionPage, which pages
through a collection set (PageRequest/PageResponse).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@isnogudus

Copy link
Copy Markdown
Author

Is the cache really needed? It adds a bunch of complexity

No, it isn't. I added it because the collection service only pages by token, and saved albums share the "collection" set with Liked Songs, so every page meant re-reading the whole set and looking up every album. Looking up only the requested page fixes most of that, and on a real library (98 saved albums in a set of ~1200 items, 39 followed artists) a request now takes 0.1–0.3 s.

So I removed it: every request now reads the set and pages it in memory like /library/playlists does, and extended metadata is fetched only for the page's entities. That drops cachedList, its TTL and clock hook, and the two fields on App. Rebased onto current master as well.

@isnogudus
isnogudus force-pushed the feature/library-collections branch from 51db3e7 to d670a72 Compare October 16, 2026 10:28
@devgianlu
devgianlu merged commit bd3fa74 into devgianlu:master Oct 18, 2026
11 checks passed
@devgianlu

Copy link
Copy Markdown
Owner

BTW your git setup is broken in such a way it does not mark you as a contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants