input/tidal: add setting "audioquality"

This commit is contained in:
Max Kellermann 2018-01-26 19:18:13 +01:00
parent f55b1415d4
commit b56bfbae26
4 changed files with 26 additions and 5 deletions

View File

@ -2497,6 +2497,21 @@ run</programlisting>
The Tidal password.
</entry>
</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>
</tgroup>
</informaltable>

View File

@ -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);

View File

@ -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:")

View File

@ -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;