feat: scrape album editorial notes (closes #8)#9
Merged
Conversation
Split the 1109-line main.go into four domain-focused files: main.go keeps the entry point and all capability methods (acts as the plugin's manifest of what it implements), helpers.go holds shared infrastructure (config, KVStore, HTTP, image URL rewriting), artist.go contains artist resolution and page scraping, and album.go contains album resolution and editorial notes scraping. main_test.go is split similarly, with shared test helpers (resetMocks, mustMarshal, setupTaylorSwiftCache) colocated with the suite entry point in plugin_suite_test.go. A single package-level BeforeEach(resetMocks) replaces the per-Describe wiring.
Contributor
|
Download the plugin for this PR: apple-music.zip Built from 97b4292 on 2026-04-27T21:10:55Z |
There was a problem hiding this comment.
Pull request overview
Adds an Album Info capability to return Apple Music album URLs plus scraped editorial notes, and refactors the codebase into smaller domain-focused files with matching test splits.
Changes:
- Implement
GetAlbumInfo(gated byenable_album_info) with caching and country fallback for scraping editorial notes. - Refactor: split the previous large
main.gointohelpers.go,artist.go, andalbum.go(and split tests accordingly). - Update plugin docs and manifest (new config flag, version bump to 0.2.0).
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| README.md | Documents the new Album Info capability and data sources. |
| manifest.json | Bumps version and adds enable_album_info config/UI control. |
| main.go | Adds metadata.AlbumInfoProvider + GetAlbumInfo; routes album images through shared album match resolver. |
| helpers.go | Centralizes config/KV/HTTP helpers and image URL rewriting. |
| artist.go | Moves artist resolution and artist-page scraping/parsing logic out of main.go. |
| album.go | Adds album match resolution (artwork + canonical URL) and album editorial-notes scraping/parsing. |
| plugin_suite_test.go | Introduces suite-wide mock reset + shared mustMarshal. |
| main_test.go | Keeps capability-method tests; adds GetAlbumInfo specs. |
| helpers_test.go | Adds unit tests for shared helper functions. |
| artist_test.go | Adds unit tests for artist resolution and parsing helpers. |
| album_test.go | Adds unit tests for album matching, URL normalization, and editorial-notes parsing. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
The cachedAlbumMatch struct added CollectionViewURL in 0.2.0, but pre-0.2.0 entries stored only artworkUrl. After upgrade, those entries unmarshal with CollectionViewURL == "", causing GetAlbumInfo to return nil until the cache TTL expires. Treat such entries as a cache miss so the URL gets populated on re-fetch. Also relax the post-lookup check: accept a match when either ArtworkURL100 or CollectionViewURL is populated, instead of requiring artwork. GetAlbumInfo doesn't need artwork, and this guards against Apple returning URL-only entries in the future.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
GetAlbumInfocapability that returns the Apple Music album URL and editorial notes for an album, closing [Feature Request] Scrape Album details #8.main.go(1109 lines) into four domain-focused files (main.go,helpers.go,artist.go,album.go) with a matching test-file split, keeping all capability methods inmain.goso a reader immediately sees what the plugin implements.Details
Album info capability
The plugin now implements
metadata.AlbumInfoProvider. Gated behind a newenable_album_infomanifest flag (defaulttrue). The Apple Music URL comes from the iTunes Lookup API'scollectionViewUrlfield; editorial notes are scraped from theserialized-server-datascript block on the album page atdata[0].data.sections[*].items[*].modalPresentationDescriptor.paragraphText.Caching: dedicated
album_info:{artist}:{album}KVStore key caches the{url, description}pair with the configured TTL. On cache hit, neither the iTunes Lookup KV read nor the album page fetch runs. Cached only when at least one country fetch succeeds — all-failures path is not cached so the next call retries.Country fallback: reuses the existing pattern — iterates configured countries, rewriting the URL's country segment, until editorial notes are found. Empty description (album has no notes) is a valid cacheable result.
Non-obvious finding: Apple's JSON-LD
descriptionfield on album pages is always a generic"Listen to X by Y on Apple Music..."string, even for famous albums. Real editorial notes only live in the embedded server data block.Version bumped
0.1.1→0.2.0.File split
main.gogrew past 1000 lines. Split by domain:main.goGet*capability methodshelpers.gonormalizeNameartist.gofetchArtistPagealbum.goserialized-server-datascraping,fetchAlbumDescriptionTest files mirror the split. Shared test helpers (
resetMocks,mustMarshal,setupTaylorSwiftCache) live inplugin_suite_test.goalongside a single package-levelBeforeEach(resetMocks).Test plan
go test -race ./...— 112/112 Ginkgo specs passgo vet ./...— cleanmake package—apple-music.ndpbuilds cleanly (1.1 MB, unchanged size)apple-music.ndpinto a local Navidrome, enableenable_album_info, trigger album metadata refresh on a few albums with known editorial notes (e.g. Taylor Swift's Lover, The Beatles' Abbey Road), and confirm descriptions + Apple Music URL appear in the album detail view.countries = "us,br,fi"and requesting an album only available in a non-US storefront (e.g. the issue's example, Karnivool's IN VERSES atfi).