feat: --all-album-links switch to fetch and show purchase links for every album inline#14
Conversation
…bums inline Co-authored-by: Zesseth <13746676+Zesseth@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Adds an opt-in --all-album-links mode to AlbumBrowser to fetch purchase links for every scanned album and display them inline in the rendered library tree, while keeping the default “shopping list for non-lossless albums” behavior unchanged.
Changes:
- Added
--all-album-linksflag with deferred tree rendering and inline link suffixes for all albums. - Extracted link formatting into
_build_link_suffix()and reused it for the shopping list output. - Updated documentation and added integration-style
main()tests for the new flag behavior.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| album_browser.py | Implements --all-album-links, deferred rendering + inline links, and refactors link formatting into _build_link_suffix(). |
| test_album_browser.py | Adds integration-style tests validating link-fetch behavior and suppression of the shopping list box in all-album-links mode. |
| README.md | Documents the new --all-album-links option and adds an example invocation. |
| if __name__ == "__main__": | ||
| unittest.main() | ||
|
|
||
|
|
There was a problem hiding this comment.
unittest.main() is invoked before the newly added integration tests are defined, so running this file directly (python test_album_browser.py) will exit before TestAllAlbumLinksFlag is registered/executed. Move the if __name__ == "__main__": unittest.main() block to the very end of the file (or remove it and rely on unittest discovery) so the new tests run in all invocation modes.
| if __name__ == "__main__": | |
| unittest.main() |
| all_links: dict[tuple[str, str], dict] = {} | ||
| all_album_entries: list[tuple[str, str]] = [] | ||
| for artist_info in artists_data: | ||
| for album in artist_info["albums"]: |
There was a problem hiding this comment.
In --all-album-links mode, all_album_entries is built from every entry in artist_info["albums"], which includes the pseudo-album (Loose tracks) (see where is_loose is set). That will trigger external Bandcamp/Qobuz searches for (Loose tracks), which is not a real album and can waste requests / slow down scans. Consider filtering out is_loose entries (or names like (Loose tracks)) when building all_album_entries and when appending link suffixes.
| for album in artist_info["albums"]: | |
| for album in artist_info["albums"]: | |
| # Skip pseudo-album used for loose tracks to avoid useless external lookups | |
| if album.get("is_loose") or album.get("name") == "(Loose tracks)": | |
| continue |
| if (not found or bc_artist_only) and not no_qobuz: | ||
| if not no_bandcamp: | ||
| time.sleep(RATE_LIMIT) | ||
| url, match_type = search_qobuz(artist, album) | ||
| all_links[(artist, album)]["qb"] = (url, match_type) |
There was a problem hiding this comment.
In --all-album-links mode, Qobuz is only searched as a fallback when Bandcamp didn’t return an album match (if (not found or bc_artist_only) ...). This means albums with a confirmed Bandcamp album URL will never have a Qobuz URL fetched/shown inline, which conflicts with the PR description claim that all-album-links mode “shows Qobuz whenever found”. Either update the implementation to also query Qobuz even when Bandcamp finds an album (opt-in cost: more requests), or adjust the PR/docs to reflect fallback-only behavior.
Default mode only fetches purchase links for non-lossless albums (the shopping list). This adds an opt-in
--all-album-linksflag that fetches and displays Bandcamp/Qobuz links for every album inline in the library tree, with no separate shopping list section.Changes
--all-album-linksflag — parsed alongside existing flags; documented in help output and READMESHOPPING LISTterminal section is skipped entirely in this mode; links are already visible inlinebandcamp_results/qobuz_resultsare derived from the all-links fetch, so the report's shopping list section still receives accurate links for lossy albums_build_link_suffix()helper — extracted repeated BC/Qobuz link-formatting logic into a private helper with aqobuz_supplement_onlykwarg to cover both display modes (shopping list supplements Qobuz only on artist-page BC hits; all-album-links mode shows Qobuz whenever found)Example inline output:
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.