input/tidal: create JSON parser on demand
This commit is contained in:
parent
1c023eac70
commit
12a2285ba5
|
@ -49,7 +49,6 @@ TidalLoginRequest::TidalLoginRequest(CurlGlobal &curl,
|
||||||
const char *username, const char *password,
|
const char *username, const char *password,
|
||||||
TidalLoginHandler &_handler) noexcept
|
TidalLoginHandler &_handler) noexcept
|
||||||
:request(curl, MakeLoginUrl(base_url).c_str(), *this),
|
:request(curl, MakeLoginUrl(base_url).c_str(), *this),
|
||||||
parser(&parse_callbacks, nullptr, this),
|
|
||||||
handler(_handler)
|
handler(_handler)
|
||||||
{
|
{
|
||||||
request_headers.Append((std::string("X-Tidal-Token:")
|
request_headers.Append((std::string("X-Tidal-Token:")
|
||||||
|
@ -76,6 +75,8 @@ TidalLoginRequest::OnHeaders(unsigned status,
|
||||||
auto i = headers.find("content-type");
|
auto i = headers.find("content-type");
|
||||||
if (i == headers.end() || i->second.find("/json") == i->second.npos)
|
if (i == headers.end() || i->second.find("/json") == i->second.npos)
|
||||||
throw std::runtime_error("Not a JSON response from Tidal");
|
throw std::runtime_error("Not a JSON response from Tidal");
|
||||||
|
|
||||||
|
parser = {&parse_callbacks, nullptr, this};
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -53,7 +53,6 @@ TidalTrackRequest::TidalTrackRequest(CurlGlobal &curl,
|
||||||
const char *track_id,
|
const char *track_id,
|
||||||
TidalTrackHandler &_handler) noexcept
|
TidalTrackHandler &_handler) noexcept
|
||||||
:request(curl, MakeTrackUrl(base_url, track_id).c_str(), *this),
|
:request(curl, MakeTrackUrl(base_url, track_id).c_str(), *this),
|
||||||
parser(&parse_callbacks, nullptr, this),
|
|
||||||
handler(_handler)
|
handler(_handler)
|
||||||
{
|
{
|
||||||
request_headers.Append((std::string("X-Tidal-Token:")
|
request_headers.Append((std::string("X-Tidal-Token:")
|
||||||
|
@ -78,6 +77,8 @@ TidalTrackRequest::OnHeaders(unsigned status,
|
||||||
auto i = headers.find("content-type");
|
auto i = headers.find("content-type");
|
||||||
if (i == headers.end() || i->second.find("/json") == i->second.npos)
|
if (i == headers.end() || i->second.find("/json") == i->second.npos)
|
||||||
throw std::runtime_error("Not a JSON response from Tidal");
|
throw std::runtime_error("Not a JSON response from Tidal");
|
||||||
|
|
||||||
|
parser = {&parse_callbacks, nullptr, this};
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
Loading…
Reference in New Issue