playlist/SoundCloud: use std::string
This commit is contained in:
parent
dadf3d846b
commit
2f03d2234a
@ -103,9 +103,9 @@ static const char *const key_str[] = {
|
|||||||
|
|
||||||
struct SoundCloudJsonData {
|
struct SoundCloudJsonData {
|
||||||
int key;
|
int key;
|
||||||
char *stream_url = nullptr;
|
std::string stream_url;
|
||||||
long duration;
|
long duration;
|
||||||
char *title = nullptr;
|
std::string title;
|
||||||
int got_url = 0; /* nesting level of last stream_url */
|
int got_url = 0; /* nesting level of last stream_url */
|
||||||
|
|
||||||
std::forward_list<DetachedSong> songs;
|
std::forward_list<DetachedSong> songs;
|
||||||
@ -135,12 +135,10 @@ handle_string(void *ctx, const unsigned char *stringval, size_t stringlen)
|
|||||||
|
|
||||||
switch (data->key) {
|
switch (data->key) {
|
||||||
case Title:
|
case Title:
|
||||||
free(data->title);
|
data->title.assign(s, stringlen);
|
||||||
data->title = xstrndup(s, stringlen);
|
|
||||||
break;
|
break;
|
||||||
case Stream_URL:
|
case Stream_URL:
|
||||||
free(data->stream_url);
|
data->stream_url.assign(s, stringlen);
|
||||||
data->stream_url = xstrndup(s, stringlen);
|
|
||||||
data->got_url = 1;
|
data->got_url = 1;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -195,16 +193,15 @@ handle_end_map(void *ctx)
|
|||||||
/* got_url == 1, track finished, make it into a song */
|
/* got_url == 1, track finished, make it into a song */
|
||||||
data->got_url = 0;
|
data->got_url = 0;
|
||||||
|
|
||||||
char *u = xstrcatdup(data->stream_url, "?client_id=",
|
const std::string u = data->stream_url + "?client_id=" +
|
||||||
soundcloud_config.apikey.c_str());
|
soundcloud_config.apikey;
|
||||||
|
|
||||||
TagBuilder tag;
|
TagBuilder tag;
|
||||||
tag.SetDuration(SignedSongTime::FromMS(data->duration));
|
tag.SetDuration(SignedSongTime::FromMS(data->duration));
|
||||||
if (data->title != nullptr)
|
if (!data->title.empty())
|
||||||
tag.AddItem(TAG_NAME, data->title);
|
tag.AddItem(TAG_NAME, data->title.c_str());
|
||||||
|
|
||||||
data->songs.emplace_front(u, tag.Commit());
|
data->songs.emplace_front(u.c_str(), tag.Commit());
|
||||||
free(u);
|
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -332,8 +329,6 @@ soundcloud_open_uri(const char *uri, Mutex &mutex, Cond &cond)
|
|||||||
|
|
||||||
free(u);
|
free(u);
|
||||||
yajl_free(hand);
|
yajl_free(hand);
|
||||||
free(data.title);
|
|
||||||
free(data.stream_url);
|
|
||||||
|
|
||||||
if (ret == -1)
|
if (ret == -1)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
Loading…
Reference in New Issue
Block a user