diff --git a/doc/user.xml b/doc/user.xml index 103f5f6c3..43e7c6d35 100644 --- a/doc/user.xml +++ b/doc/user.xml @@ -2497,6 +2497,21 @@ run The Tidal password. + + + + audioquality + Q + + + The Tidal "audioquality" parameter. Possible + values: HI_RES, + LOSSLESS, + HIGH, + LOW. Default is + HIGH. + + diff --git a/src/input/plugins/TidalInputPlugin.cxx b/src/input/plugins/TidalInputPlugin.cxx index 3079288e5..c5b604885 100644 --- a/src/input/plugins/TidalInputPlugin.cxx +++ b/src/input/plugins/TidalInputPlugin.cxx @@ -40,6 +40,7 @@ static constexpr Domain tidal_domain("tidal"); static TidalSessionManager *tidal_session; +static const char *tidal_audioquality; class TidalInputStream final : public ProxyInputStream, TidalSessionHandler, TidalTrackHandler { @@ -102,6 +103,7 @@ TidalInputStream::OnTidalSession() noexcept tidal_session->GetToken(), tidal_session->GetSession().c_str(), track_id.c_str(), + tidal_audioquality, handler); track_request->Start(); } catch (...) { @@ -178,7 +180,7 @@ InitTidalInput(EventLoop &event_loop, const ConfigBlock &block) if (password == nullptr) throw PluginUnavailable("No Tidal password configured"); - // TODO: "audioquality" setting + tidal_audioquality = block.GetBlockValue("audioquality", "HIGH"); tidal_session = new TidalSessionManager(event_loop, base_url, token, username, password); diff --git a/src/input/plugins/TidalTrackRequest.cxx b/src/input/plugins/TidalTrackRequest.cxx index 710385a4d..5a54bddd5 100644 --- a/src/input/plugins/TidalTrackRequest.cxx +++ b/src/input/plugins/TidalTrackRequest.cxx @@ -63,21 +63,24 @@ public: }; static std::string -MakeTrackUrl(const char *base_url, const char *track_id) +MakeTrackUrl(const char *base_url, const char *track_id, + const char *audioquality) noexcept { - // TODO: add "audioquality" parameter to this function return std::string(base_url) + "/tracks/" + track_id - + "/urlpostpaywall?assetpresentation=FULL&audioquality=LOW&urlusagemode=STREAM"; + + "/urlpostpaywall?assetpresentation=FULL&audioquality=" + + audioquality + "&urlusagemode=STREAM"; } TidalTrackRequest::TidalTrackRequest(CurlGlobal &curl, const char *base_url, const char *token, const char *session, const char *track_id, + const char *audioquality, TidalTrackHandler &_handler) - :request(curl, MakeTrackUrl(base_url, track_id).c_str(), *this), + :request(curl, MakeTrackUrl(base_url, track_id, audioquality).c_str(), + *this), handler(_handler) { request_headers.Append((std::string("X-Tidal-Token:") diff --git a/src/input/plugins/TidalTrackRequest.hxx b/src/input/plugins/TidalTrackRequest.hxx index 12f5a6f4b..fbd7bd780 100644 --- a/src/input/plugins/TidalTrackRequest.hxx +++ b/src/input/plugins/TidalTrackRequest.hxx @@ -55,6 +55,7 @@ public: const char *base_url, const char *token, const char *session, const char *track_id, + const char *audioquality, TidalTrackHandler &_handler); ~TidalTrackRequest() noexcept;