input/tidal: move code to ExtractTidalTrackId()

This commit is contained in:
Max Kellermann 2018-01-26 16:59:09 +01:00
parent 93765fcb30
commit fce061b544
1 changed files with 18 additions and 6 deletions

View File

@ -190,18 +190,30 @@ FinishTidalInput()
delete tidal_session;
}
gcc_pure
static const char *
ExtractTidalTrackId(const char *uri)
{
const char *track_id = StringAfterPrefix(uri, "tidal://track/");
if (track_id == nullptr) {
track_id = StringAfterPrefix(uri, "https://listen.tidal.com/track/");
if (track_id == nullptr)
return nullptr;
}
if (*track_id == 0)
return nullptr;
return track_id;
}
static InputStreamPtr
OpenTidalInput(const char *uri, Mutex &mutex, Cond &cond)
{
assert(tidal_session != nullptr);
const char *track_id;
track_id = StringAfterPrefix(uri, "tidal://track/");
const char *track_id = ExtractTidalTrackId(uri);
if (track_id == nullptr)
track_id = StringAfterPrefix(uri, "https://listen.tidal.com/track/");
if (track_id == nullptr || *track_id == 0)
return nullptr;
// TODO: validate track_id