Repository navigation
Conversation
Fetching and playing a stream doesn't count as a play, so tracks played through tidalapi never show up in Recently played or in the listening history TIDAL uses for recommendations. The official players report each play as a playback_session event to TIDAL's event producer; tidalapi.playlog builds the same events, following TIDAL's open source SDK (tidal-sdk-android), and Session.report_playback sends them. The events describe the real client (operating system and application version) instead of an official TIDAL app. Fixes EbbLabs#401 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
b278e6a to
e40cdda
Compare
|
A note on why I think this matters beyond Recently played: TIDAL's own SDK puts the play log in its NECESSARY consent category (streaming metrics are PERFORMANCE), and every official player sends it for every play. Without it, plays from tidalapi-based players may not count the way TIDAL's own players' plays do, possibly including what artists get paid for them. I can't confirm how TIDAL uses it, but it seems worth getting right. Two things you may want to weigh: the session's OAuth client is TIDAL's Android app, while the events describe the real client (OS, app version), so they don't fully match. And since |
Fixes #401.
Tracks played through tidalapi never show up in Recently played, and don't count in the listening history TIDAL uses for recommendations. Fetching and playing a stream isn't enough: the official players report every play as a
playback_sessionevent to TIDAL's event producer (https://ec.tidal.com/api/event-batch). The attempt in #401 sent the web player's events totidal.com/api/event-batch, which TIDAL accepts but doesn't show anywhere.This adds
Session.report_playback()and atidalapi.playlogmodule that builds the same events as TIDAL's own players. The layout comes from TIDAL's open source SDK, tidal-sdk-android: theeventproducermodule (an SQSSendMessageBatchform with aHeadersattribute) and theplayer/eventsmodels (PlaybackSession,AudioPlaybackSession,User,Client). The user and client fields come from the access token's claims, as the SDK does.Apart from the client id of the OAuth client the session logged in with, the events describe the real client: the operating system and version from
platform, and an application version the caller passes in (defaults to the tidalapi version). They don't add device details. Reported this way withreport_playback, plays showed up in Recently played within 20 seconds in my tests.ITEMwith the track's own id for a track played on its own. Recently played lists the source.PlaybackActions, as the official players do.report_playbackreturnsFalseif TIDAL rejects them, and raises if they couldn't be sent (offline, server errors), so applications can keep them and try again later. It uses the session's token refresh and backoff.The tests in
tests/test_playlog.pyrun offline and are added to the test workflow. There are also docs inapi.rstand an entry inHISTORY.rst.High Tide, which uses tidalapi, already reports plays this way in a local build.
🤖 Generated with Claude Code