Fix song title parsing

This commit is contained in:
_ 2020-12-03 16:57:54 -07:00
parent 44a7190b7a
commit e6279779d5

View File

@ -368,7 +368,9 @@ void Utils::DownloadSong(std::string fileId, std::string uri, std::string key, s
std::string metadata = DownloadSpotifyUrl("api.spotify.com", "/v1/tracks/"
+ uri.substr(uri.find("spotify:track:") + 14), authToken);
songInfo->title = strtok((char*)(metadata.substr(metadata.find("is_local\" :") + 55)).c_str(), "\"");
size_t isLocalOff = metadata.find("is_local\" :");
songInfo->title = strtok((char*)(metadata.substr(metadata.find("name\" :", isLocalOff) + 9)).c_str(), "\"");
songInfo->artist = strtok((char*)(metadata.substr(metadata.find("name\" :") + 9)).c_str(), "\"");
songInfo->album = strtok((char*)(metadata.substr(metadata.find(albumSearchPattern) + 404)).c_str(), "\"");
songInfo->coverUrl = strtok((char*)(metadata.substr(metadata.find("height\" :") + 30)).c_str(), "\"");