Plugin: rewire apple_api.py to the gateway #13
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Context
Plugin rework (see #18).
apple_api.pybecomes a client of the gatewayinstead of Apple; the response shape is fixed by the gateway API (#7) so
the parsing barely changes.
Task
In
/opt/data/git/git.sams.wtf/coop/beets-appleplaylists:AppleAPIClient(service_url: str, service_token: str, session=None)withAuthorization: Bearer <service_token>on all requests{service_url}/api/v1; endpoints/playlistsand/playlists/{id}/tracks(match the gateway's JSON field names exactly:title,artist,album,isrc,track_number)ApplePlaylist/AppleTrackdataclasses and the track-extractionlogic identical so
matching.py/sync.pyare untouchedAppleAPIErrorwith the message"Apple Music gateway login required: run 'beet apple login' or visit
{service_url}/login"
AppleAPIError)Acceptance criteria
tests/test_apple_api.pyupdated to the FakeSession pattern assertingthe request host is
{service_url}/api/v1/...and the bearer header issent; tests pass.
sync.py,matching.py,isrc.pyunchanged by this issue.Implemented in
coop/beets-appleplaylistscommitb5a121c8c728bcf218e5e4561bed603e01e82b44.AppleAPIClient(service_url, service_token, session=None)now targets{service_url}/api/v1/playlistsand/playlists/{id}/tracks, sends the bearer header through the session, maps the gateway's flat track fields, and converts 401/403 and request failures to sanitizedAppleAPIErrormessages.tests/test_apple_api.pycovers endpoint URLs, bearer auth, response mapping, 401/403 login hints, network failures, and server failures.