Skip to content

Add Apple Music cover art provider plugin - #435

Open
MosheWelcher wants to merge 3 commits into
metabrainz:2.0from
MosheWelcher:2.0
Open

MosheWelcher wants to merge 3 commits into
metabrainz:2.0from
MosheWelcher:2.0

Conversation

@MosheWelcher

@MosheWelcher MosheWelcher commented Sep 6, 2026 •

Copy link
Copy Markdown

Overview

This pull request introduces a new cover art provider plugin that fetches high-resolution front cover art directly from the public iTunes Search API. This provides a highly reliable fallback alternative for environments where coverartarchive.org or archive.org are experiencing downtime or network unreachability.

Key Features

  • Zero Authentication: Operates entirely on the public itunes.apple.com endpoint, requiring no user accounts or API keys.
  • Configurable Plugin Options: Introduces an AppleMusicOptionsPage UI allowing users to set target image resolutions (from 600x600 up to 3000x3000), specify a localized store country code (defaulting to "US"), and adjust the match confidence threshold.
  • Cross-Version Compatibility: Declares support for Picard API versions 2.0 through 2.13 and seamlessly handles network imports for both PyQt5 (Picard 2.x) and PyQt6 (Picard 3.x).

Technical Implementation

  • Intelligent Scoring Logic: Because the iTunes API matches on string text rather than precise MBIDs, the plugin implements a score_candidate function to evaluate API results against existing Picard tags. It normalizes strings, checks for exact and prefix matches, and heavily weights track count parity to confirm accuracy.
  • Edition Handling: The scoring engine isolates bracketed suffixes (e.g., "deluxe", "remastered", "anniversary") to differentiate between standard and special editions of the same album, breaking ties to ensure plain albums do not incorrectly receive deluxe cover variants.
  • Dynamic Upscaling: The upscale_artwork_url function intercepts the default 100x100 thumbnail URL provided by Apple and dynamically rewrites the URL string via regex to fetch the user-configured high-resolution square image directly from mzstatic.com.
  • Safety Thresholds: Any API result scoring below the user-defined threshold (defaulting to 90) is strictly discarded, ensuring incorrect covers are never silently attached to a release.
    @phw @rdswift Thank you for responding promptly

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.

1 participant