Improvement of MusicMe music provider for API signin, and fix the parsing of the "streamable" fields and playlists ids#4029
Open
mintgrey wants to merge 7 commits into
Open
Improvement of MusicMe music provider for API signin, and fix the parsing of the "streamable" fields and playlists ids#4029mintgrey wants to merge 7 commits into
mintgrey wants to merge 7 commits into
Conversation
Contributor
|
@JulienDeveaux could you please have a look at this? |
Contributor
There was a problem hiding this comment.
Pull request overview
Improves the existing MusicMe music provider by adding an API-based signin alternative to the existing scraped-web login, broadening the "streamable" filter from == 2 to != 0 so albums/tracks flagged with other non-zero values are not hidden, and stripping the pl- prefix from playlist IDs so the dataservice playlist endpoints work for those entries.
Changes:
- Adds a
SIGNIN_BY_APIboolean config entry and a new_signin_by_apimethod that authenticates by hitting/medialibrary/signinvia_api_get. - Replaces all
streamable == 2checks withstreamable != 0in search, browse, recommendations, top tracks, radio track selection, and parsers. - Normalizes playlist IDs in
_parse_playlistby stripping apl-prefix; updates one streaming test fixture to match the new streamable semantics.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
| music_assistant/providers/musicme/constants.py | Adds the SIGNIN_BY_API config key constant. |
| music_assistant/providers/musicme/init.py | Registers the new boolean config entry for API signin. |
| music_assistant/providers/musicme/provider.py | Branches init between web login and new _signin_by_api; loosens streamable checks; strips pl- from playlist ids. |
| tests/providers/musicme/test_streaming.py | Updates a fixture from streamable: 1 to streamable: 0 to match new semantics. |
Comments suppressed due to low confidence (1)
music_assistant/providers/musicme/provider.py:60
- [PROBLEM] The import group is no longer alphabetically sorted (
SIGNIN_BY_APIshould come afterPARTNER_ID). Ruff/isort in pre-commit will flag this.
from .constants import (
SIGNIN_BY_API,
CLIENT_JSON,
DATASERVICE_BASE,
LOGIN_URL,
PARTNER_ID,
STREAM_BASE,
VALID_ID_RE,
WEB_BASE,
Comment on lines
+782
to
+790
| async def _signin_by_api(self) -> None: | ||
| login = self.config.get_value(CONF_USERNAME) | ||
| password = self.config.get_value(CONF_PASSWORD) | ||
|
|
||
| response = await self._api_get( | ||
| f"/medialibrary/signin" | ||
| f"?channel=65777&lang=fr&format=json&client=%7B%22type%22%3A%22desktop-web%22%2C%22context%22%3A%22pro.bib.musicme.com%22%7D" | ||
| f"&key=sKTBA7ybW3nvCUQ6&nocrypt=0&login={login}&password={password}" | ||
| ) |
Comment on lines
+786
to
+790
| response = await self._api_get( | ||
| f"/medialibrary/signin" | ||
| f"?channel=65777&lang=fr&format=json&client=%7B%22type%22%3A%22desktop-web%22%2C%22context%22%3A%22pro.bib.musicme.com%22%7D" | ||
| f"&key=sKTBA7ybW3nvCUQ6&nocrypt=0&login={login}&password={password}" | ||
| ) |
Comment on lines
+792
to
+803
| if response and "results" in response: | ||
| results = response.get("results", {}) | ||
| if results and "user" in results: | ||
| self._user_id = results.get("user").get("id") | ||
|
|
||
| if not self._user_id: | ||
| msg = "Login failed — no user.id in MusicMe API response" | ||
| raise LoginFailed(msg) | ||
|
|
||
| self.logger.info( | ||
| "Successfully logged in to MusicMe" | ||
| ) |
Comment on lines
+45
to
+51
| ConfigEntry( | ||
| key=SIGNIN_BY_API, | ||
| type=ConfigEntryType.BOOLEAN, | ||
| label="Signin by API", | ||
| required=False, | ||
| description="If checked, the signin will be made by API call, if unchecked, login will be made by HTTP authentication.", | ||
| ), |
Comment on lines
573
to
577
| item_id=barcode, | ||
| provider_domain=self.domain, | ||
| provider_instance=self.instance_id, | ||
| available=album_obj.get("streamable", 0) == 2, | ||
| available=album_obj.get("streamable", 0) != 0, | ||
| audio_format=AudioFormat( |
| def _parse_playlist(self, playlist_obj: dict[str, Any]) -> Playlist: | ||
| """Parse a MusicMe playlist object to a Music Assistant Playlist.""" | ||
| playlist_id = str(playlist_obj.get("id", "")) | ||
| playlist_id = (str(playlist_obj.get("id", ""))).removeprefix("pl-") |
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.
What does this implement/fix?
This PR adds/corrects 3 functionalities as discussed in Discussion #5421 :
The modifications are tested locally for several days on my HA/MA installation, and it works like a charm !
Types of changes
bugfixnew-featureenhancementnew-providerbreaking-changerefactordocumentationmaintenancecidependenciesChecklist
pre-commit run --all-filespasses.pytestpasses, and tests have been added/updated undertests/where applicable.music-assistant/modelsis linked.music-assistant/frontendis linked.P.S. This is my first PR on github, I'm listening for any advice or correction !