Commit b56bfbae authored by Max Kellermann's avatar Max Kellermann

input/tidal: add setting "audioquality"

parent f55b1415
...@@ -2497,6 +2497,21 @@ run</programlisting> ...@@ -2497,6 +2497,21 @@ run</programlisting>
The Tidal password. The Tidal password.
</entry> </entry>
</row> </row>
<row>
<entry>
<varname>audioquality</varname>
<parameter>Q</parameter>
</entry>
<entry>
The Tidal "audioquality" parameter. Possible
values: <parameter>HI_RES</parameter>,
<parameter>LOSSLESS</parameter>,
<parameter>HIGH</parameter>,
<parameter>LOW</parameter>. Default is
<parameter>HIGH</parameter>.
</entry>
</row>
</tbody> </tbody>
</tgroup> </tgroup>
</informaltable> </informaltable>
......
...@@ -40,6 +40,7 @@ ...@@ -40,6 +40,7 @@
static constexpr Domain tidal_domain("tidal"); static constexpr Domain tidal_domain("tidal");
static TidalSessionManager *tidal_session; static TidalSessionManager *tidal_session;
static const char *tidal_audioquality;
class TidalInputStream final class TidalInputStream final
: public ProxyInputStream, TidalSessionHandler, TidalTrackHandler { : public ProxyInputStream, TidalSessionHandler, TidalTrackHandler {
...@@ -102,6 +103,7 @@ TidalInputStream::OnTidalSession() noexcept ...@@ -102,6 +103,7 @@ TidalInputStream::OnTidalSession() noexcept
tidal_session->GetToken(), tidal_session->GetToken(),
tidal_session->GetSession().c_str(), tidal_session->GetSession().c_str(),
track_id.c_str(), track_id.c_str(),
tidal_audioquality,
handler); handler);
track_request->Start(); track_request->Start();
} catch (...) { } catch (...) {
...@@ -178,7 +180,7 @@ InitTidalInput(EventLoop &event_loop, const ConfigBlock &block) ...@@ -178,7 +180,7 @@ InitTidalInput(EventLoop &event_loop, const ConfigBlock &block)
if (password == nullptr) if (password == nullptr)
throw PluginUnavailable("No Tidal password configured"); throw PluginUnavailable("No Tidal password configured");
// TODO: "audioquality" setting tidal_audioquality = block.GetBlockValue("audioquality", "HIGH");
tidal_session = new TidalSessionManager(event_loop, base_url, token, tidal_session = new TidalSessionManager(event_loop, base_url, token,
username, password); username, password);
......
...@@ -63,21 +63,24 @@ public: ...@@ -63,21 +63,24 @@ public:
}; };
static std::string 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) return std::string(base_url)
+ "/tracks/" + "/tracks/"
+ track_id + track_id
+ "/urlpostpaywall?assetpresentation=FULL&audioquality=LOW&urlusagemode=STREAM"; + "/urlpostpaywall?assetpresentation=FULL&audioquality="
+ audioquality + "&urlusagemode=STREAM";
} }
TidalTrackRequest::TidalTrackRequest(CurlGlobal &curl, TidalTrackRequest::TidalTrackRequest(CurlGlobal &curl,
const char *base_url, const char *token, const char *base_url, const char *token,
const char *session, const char *session,
const char *track_id, const char *track_id,
const char *audioquality,
TidalTrackHandler &_handler) 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) handler(_handler)
{ {
request_headers.Append((std::string("X-Tidal-Token:") request_headers.Append((std::string("X-Tidal-Token:")
......
...@@ -55,6 +55,7 @@ public: ...@@ -55,6 +55,7 @@ public:
const char *base_url, const char *token, const char *base_url, const char *token,
const char *session, const char *session,
const char *track_id, const char *track_id,
const char *audioquality,
TidalTrackHandler &_handler); TidalTrackHandler &_handler);
~TidalTrackRequest() noexcept; ~TidalTrackRequest() noexcept;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment