Skip to content

feat: --all-album-links switch to fetch and show purchase links for every album inline - #14

Open
Zesseth with Copilot wants to merge 2 commits into
mainfrom
copilot/add-switch-fetch-all-album-links
Open

feat: --all-album-links switch to fetch and show purchase links for every album inline#14
Zesseth with Copilot wants to merge 2 commits into
mainfrom
copilot/add-switch-fetch-all-album-links

Conversation

Copilot AI commented Mar 6, 2026

Copy link
Copy Markdown
Contributor

Default mode only fetches purchase links for non-lossless albums (the shopping list). This adds an opt-in --all-album-links flag that fetches and displays Bandcamp/Qobuz links for every album inline in the library tree, with no separate shopping list section.

Changes

  • New --all-album-links flag — parsed alongside existing flags; documented in help output and README
  • Deferred tree rendering — when the flag is active, per-album scan output is suppressed; links are fetched for all albums with the same progress UX as the shopping list search, then the full tree is printed with links appended inline per album
  • No shopping list box — the SHOPPING LIST terminal section is skipped entirely in this mode; links are already visible inline
  • MD reportbandcamp_results/qobuz_results are 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 a qobuz_supplement_only kwarg to cover both display modes (shopping list supplements Qobuz only on artist-page BC hits; all-album-links mode shows Qobuz whenever found)
# Fetch and display links for every album — lossless and lossy alike
python3 album_browser.py ~/Music --all-album-links

Example inline output:

  🎤 Artist B
     ├── 💿 Only Lossless  [FLAC]  (1 tracks, 2 KB)  🔗 BC: https://artistb.bandcamp.com/album/only-lossless
Original prompt

This section details on the original issue you should resolve

<issue_title>Feature Request: Optional Switch to Fetch Links for All Albums</issue_title>
<issue_description>
Overview
Add an optional command-line switch that changes the scan behavior to fetch and display links for all albums, regardless of their audio format — instead of only listing albums that are not in lossless formats.

Desired Behavior
When the switch is active, the scan runs normally but collects links to every album found

Album links are displayed inline as part of the album listing output — no separate "links summary" section is needed

This switch is opt-in only and must not alter the default behavior in any way

Default Behavior (unchanged)
The existing scan logic remains intact when the switch is not used. Only albums missing lossless formats are reported, as before.

Proposed Switch Example
text
--all-album-links
Acceptance Criteria
New optional switch (e.g. --all-album-links) is implemented

When active, links are fetched for all albums and shown inline in the album list

No separate links summary section is generated during this mode

Default scan behavior is completely unaffected when switch is not used

Switch is documented in help output / README</issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

…bums inline

Co-authored-by: Zesseth <13746676+Zesseth@users.noreply.github.com>
Copilot AI changed the title [WIP] Add optional switch to fetch links for all albums feat: --all-album-links switch to fetch and show purchase links for every album inline Mar 6, 2026
@Zesseth
Zesseth marked this pull request as ready for review March 6, 2026 15:29
@Zesseth
Zesseth self-requested a review as a code owner March 6, 2026 15:29
Copilot AI review requested due to automatic review settings March 6, 2026 15:29

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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-links flag 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.

Comment thread test_album_browser.py
Comment on lines 201 to +204
if __name__ == "__main__":
unittest.main()


Copilot AI Mar 6, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
if __name__ == "__main__":
unittest.main()

Copilot uses AI. Check for mistakes.
Comment thread album_browser.py
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"]:

Copilot AI Mar 6, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
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

Copilot uses AI. Check for mistakes.
Comment thread album_browser.py
Comment on lines +559 to +563
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)

Copilot AI Mar 6, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
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.

Feature Request: Optional Switch to Fetch Links for All Albums

3 participants