Skip to content

Lossless Fix: use correct Tidal client credentials and HTTP Basic Auth - #24

Open
bencejuhaasz wants to merge 1 commit into
fezzik-the-giant:masterfrom
bencejuhaasz:master
Open

Lossless Fix: use correct Tidal client credentials and HTTP Basic Auth#24
bencejuhaasz wants to merge 1 commit into
fezzik-the-giant:masterfrom
bencejuhaasz:master

Conversation

@bencejuhaasz

Copy link
Copy Markdown

The app was playing AAC for all tracks, even those available in lossless FLAC on Tidal. Three root causes fixed:

  1. Wrong client credentials: The built-in client_id/client_secret belonged to a client without lossless entitlement. Switched to the same credentials used by tiddl (github.com/oskvr37/tiddl), which are known to work for FLAC access.

  2. Form-field auth produces AAC-only tokens: The OAuth2 /token endpoint was sending client_secret as a form body field instead of using HTTP Basic Auth. The Tidal API uses the authentication method to determine token privileges — form-field auth grants restricted AAC-only tokens, while Basic Auth grants full lossless access.

  3. Quality fallback order was wrong: HI_RES_LOSSLESS was tried first, but it often returns DASH manifests with AAC codec (not FLAC). Since the request succeeded, LOSSLESS was never reached. Now LOSSLESS (raw FLAC via BTS) is tried first, followed by HI_RES_LOSSLESS only if its DASH codec is actually FLAC.

Additional improvements:

  • BtsManifest model now captures codecs/mimeType fields
  • DASH parser finds and prefers FLAC AdaptationSets
  • Multi-segment FLAC handled via local M3U8 playlist
  • HLS playlists include EXT-X-CODECS for proper mpv detection
  • Removed x-tidal-client-version header (tiddl does not send it)
  • auth_generation migration flag forces re-auth on credential changes
  • RIPTIDE_QUALITY_DEBUG env var for diagnostic logging
  • PlaybackInfo model captures audioQuality/bitDepth/sampleRate

…sless FLAC streaming

The app was playing AAC for all tracks, even those available in lossless
FLAC on Tidal. Three root causes fixed:

1. **Wrong client credentials**: The built-in client_id/client_secret
   belonged to a client without lossless entitlement. Switched to the
   same credentials used by tiddl (github.com/oskvr37/tiddl), which
   are known to work for FLAC access.

2. **Form-field auth produces AAC-only tokens**: The OAuth2 /token
   endpoint was sending client_secret as a form body field instead of
   using HTTP Basic Auth. The Tidal API uses the authentication method
   to determine token privileges — form-field auth grants restricted
   AAC-only tokens, while Basic Auth grants full lossless access.

3. **Quality fallback order was wrong**: HI_RES_LOSSLESS was tried
   first, but it often returns DASH manifests with AAC codec (not
   FLAC). Since the request succeeded, LOSSLESS was never reached.
   Now LOSSLESS (raw FLAC via BTS) is tried first, followed by
   HI_RES_LOSSLESS only if its DASH codec is actually FLAC.

Additional improvements:
- BtsManifest model now captures codecs/mimeType fields
- DASH parser finds and prefers FLAC AdaptationSets
- Multi-segment FLAC handled via local M3U8 playlist
- HLS playlists include EXT-X-CODECS for proper mpv detection
- Removed x-tidal-client-version header (tiddl does not send it)
- auth_generation migration flag forces re-auth on credential changes
- RIPTIDE_QUALITY_DEBUG env var for diagnostic logging
- PlaybackInfo model captures audioQuality/bitDepth/sampleRate

Co-Authored-By: Claude <noreply@anthropic.com>
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