Skip to content

Split Apple Music provider into modular structure#3715

Merged
MarvinSchenkel merged 7 commits intomusic-assistant:devfrom
dmoo500:refactor/apple-music-split-modules
Apr 20, 2026
Merged

Split Apple Music provider into modular structure#3715
MarvinSchenkel merged 7 commits intomusic-assistant:devfrom
dmoo500:refactor/apple-music-split-modules

Conversation

@dmoo500
Copy link
Copy Markdown
Contributor

@dmoo500 dmoo500 commented Apr 16, 2026

Summary

Refactors the Apple Music provider from a 1464-line monolith (__init__.py) into a modular structure following the pattern established by the Tidal provider.

New module structure

File Responsibility
__init__.py setup() + get_config_entries() only (MusicKit OAuth flow, unchanged)
provider.py Thin AppleMusicProvider class delegating to manager classes
constants.py All constants (SUPPORTED_FEATURES, CONF_*, etc.)
api_client.py AppleMusicAPIClient — all HTTP communication with the Apple Music API
parsers.py Standalone parse functions for artist/album/track/playlist/station
library.py AppleMusicLibraryManager — library CRUD and ratings
media.py AppleMusicMediaManager — catalog reads and search
recommendations.py AppleMusicRecommendationManager — recommendations, stations, similar tracks
streaming.py AppleMusicStreamingManager — Widevine decryption and stream URL resolution

Motivation

This is a prerequisite for adding podcast support inside the Apple Music provider (as suggested in discussion #5215), without the new code getting lost in an already large file.

No functional changes — this is a pure structural refactor.

Copilot AI review requested due to automatic review settings April 16, 2026 15:10
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Refactors the Apple Music provider into a modular layout (API client, parsers, and manager classes) to replace the prior monolithic implementation and make future feature additions (e.g., podcasts) easier to maintain.

Changes:

  • Introduces AppleMusicProvider as a thin facade delegating to dedicated manager modules (library/media/recommendations/streaming).
  • Adds a standalone AppleMusicAPIClient and shared parse helpers for Apple Music API objects.
  • Centralizes provider constants and updates helper imports to the new module structure.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
music_assistant/providers/apple_music/init.py Keeps setup/config-entry logic and exports the provider in the new structure.
music_assistant/providers/apple_music/provider.py New provider facade delegating behavior to manager classes.
music_assistant/providers/apple_music/api_client.py New centralized HTTP client and Apple Music ID/type utilities.
music_assistant/providers/apple_music/constants.py Centralizes provider constants and supported feature set.
music_assistant/providers/apple_music/parsers.py New standalone parsers for artist/album/track/playlist/station objects.
music_assistant/providers/apple_music/media.py New catalog/search/media lookup manager.
music_assistant/providers/apple_music/library.py New library CRUD/ratings manager.
music_assistant/providers/apple_music/recommendations.py New recommendations/stations/similar tracks manager.
music_assistant/providers/apple_music/streaming.py New streaming + Widevine decryption manager.
music_assistant/providers/apple_music/helpers/browse.py Updates type-check import to the new provider module path.

Comment thread music_assistant/providers/apple_music/media.py
Comment thread music_assistant/providers/apple_music/streaming.py
Comment thread music_assistant/providers/apple_music/recommendations.py
Comment thread music_assistant/providers/apple_music/streaming.py Outdated
Comment thread music_assistant/providers/apple_music/library.py Outdated
Comment thread music_assistant/providers/apple_music/parsers.py Outdated
Comment thread music_assistant/providers/apple_music/streaming.py Outdated
Comment thread music_assistant/providers/apple_music/streaming.py Outdated
Comment thread music_assistant/providers/apple_music/streaming.py
…-strings, safe dict access, cdm.close() in finally
@dmoo500 dmoo500 marked this pull request as draft April 16, 2026 15:22
@dmoo500 dmoo500 marked this pull request as ready for review April 16, 2026 15:34
Copilot AI review requested due to automatic review settings April 16, 2026 15:35
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 10 out of 10 changed files in this pull request and generated no new comments.

Comment thread music_assistant/providers/apple_music/api_client.py Outdated
Comment thread music_assistant/providers/apple_music/provider.py Outdated
Comment thread music_assistant/providers/apple_music/api_client.py Outdated
Comment thread music_assistant/providers/apple_music/provider.py Outdated
Copy link
Copy Markdown
Contributor

@MarvinSchenkel MarvinSchenkel left a comment

Choose a reason for hiding this comment

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

Love the refactor, makes things way easier to digest. Few minor comments

Copilot AI review requested due to automatic review settings April 17, 2026 09:21
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 12 out of 12 changed files in this pull request and generated 4 comments.

Comment thread music_assistant/providers/apple_music/media.py
Comment thread music_assistant/providers/apple_music/media.py
Comment thread music_assistant/providers/apple_music/library.py
Comment thread music_assistant/providers/apple_music/library.py
Copilot AI review requested due to automatic review settings April 17, 2026 09:40
@dmoo500
Copy link
Copy Markdown
Contributor Author

dmoo500 commented Apr 17, 2026

@MarvinSchenkel Thanks! All comments have been addressed — the wrapper methods in provider.py are removed, browse.py now calls provider.api_client and parse_playlist directly, and helpers/utils.py holds the ID helpers cleanly. Let me know if anything else needs adjusting.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 13 out of 13 changed files in this pull request and generated 3 comments.

Comment thread music_assistant/providers/apple_music/parsers.py
Comment thread music_assistant/providers/apple_music/parsers.py
Comment thread music_assistant/providers/apple_music/parsers.py
@dmoo500 dmoo500 requested a review from MarvinSchenkel April 17, 2026 09:57
Copy link
Copy Markdown
Contributor

@MarvinSchenkel MarvinSchenkel left a comment

Choose a reason for hiding this comment

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

Awesome stuff, thanks a bunch @dmoo500 👏

@MarvinSchenkel MarvinSchenkel enabled auto-merge (squash) April 20, 2026 10:03
@MarvinSchenkel MarvinSchenkel merged commit 5d74245 into music-assistant:dev Apr 20, 2026
6 checks passed
@dmoo500 dmoo500 deleted the refactor/apple-music-split-modules branch May 3, 2026 11:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants