summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMax Kellermann <max@musicpd.org>2018-01-21 12:29:52 +0100
committerMax Kellermann <max@musicpd.org>2018-01-21 12:29:52 +0100
commit12a2285ba52efef375a8335f232c1fedd4453489 (patch)
tree12f2b838865800c40ae0244cd6600914537e2ecc /src
parent1c023eac70c35b3ef2f5a4d4e3e2fbe83b25c94f (diff)
input/tidal: create JSON parser on demand
Diffstat (limited to 'src')
-rw-r--r--src/input/plugins/TidalLoginRequest.cxx3
-rw-r--r--src/input/plugins/TidalTrackRequest.cxx3
2 files changed, 4 insertions, 2 deletions
diff --git a/src/input/plugins/TidalLoginRequest.cxx b/src/input/plugins/TidalLoginRequest.cxx
index 4b1671298..71e4ce7e6 100644
--- a/src/input/plugins/TidalLoginRequest.cxx
+++ b/src/input/plugins/TidalLoginRequest.cxx
@@ -49,7 +49,6 @@ TidalLoginRequest::TidalLoginRequest(CurlGlobal &curl,
const char *username, const char *password,
TidalLoginHandler &_handler) noexcept
:request(curl, MakeLoginUrl(base_url).c_str(), *this),
- parser(&parse_callbacks, nullptr, this),
handler(_handler)
{
request_headers.Append((std::string("X-Tidal-Token:")
@@ -76,6 +75,8 @@ TidalLoginRequest::OnHeaders(unsigned status,
auto i = headers.find("content-type");
if (i == headers.end() || i->second.find("/json") == i->second.npos)
throw std::runtime_error("Not a JSON response from Tidal");
+
+ parser = {&parse_callbacks, nullptr, this};
}
void
diff --git a/src/input/plugins/TidalTrackRequest.cxx b/src/input/plugins/TidalTrackRequest.cxx
index d009a61a1..c0b8d540d 100644
--- a/src/input/plugins/TidalTrackRequest.cxx
+++ b/src/input/plugins/TidalTrackRequest.cxx
@@ -53,7 +53,6 @@ TidalTrackRequest::TidalTrackRequest(CurlGlobal &curl,
const char *track_id,
TidalTrackHandler &_handler) noexcept
:request(curl, MakeTrackUrl(base_url, track_id).c_str(), *this),
- parser(&parse_callbacks, nullptr, this),
handler(_handler)
{
request_headers.Append((std::string("X-Tidal-Token:")
@@ -78,6 +77,8 @@ TidalTrackRequest::OnHeaders(unsigned status,
auto i = headers.find("content-type");
if (i == headers.end() || i->second.find("/json") == i->second.npos)
throw std::runtime_error("Not a JSON response from Tidal");
+
+ parser = {&parse_callbacks, nullptr, this};
}
void