diff options
author | dec05eba <dec05eba@protonmail.com> | 2022-04-06 18:55:06 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2022-04-06 18:55:06 +0200 |
commit | c1ee0d53ddfccd74112ac9db066e345861a7aea9 (patch) | |
tree | bdf11d0b4980b4bcbd088ee74545901354a94f07 /src | |
parent | 19c58ef32be910c5c0c9f37740d0601e37eaafa7 (diff) |
Soundcloud: fix client_id extraction (no more &, ends with " instead)
Diffstat (limited to 'src')
-rw-r--r-- | src/plugins/Soundcloud.cpp | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/src/plugins/Soundcloud.cpp b/src/plugins/Soundcloud.cpp index 0412aa6..e088f73 100644 --- a/src/plugins/Soundcloud.cpp +++ b/src/plugins/Soundcloud.cpp @@ -382,15 +382,24 @@ namespace QuickMedia { async_download_tasks.push_back(AsyncTask<std::string>([script_source]() -> std::string { std::string website_data; DownloadResult download_result = download_to_string(script_source, website_data, {}, true); - if(download_result != DownloadResult::OK) return ""; + if(download_result != DownloadResult::OK) + return ""; size_t index = website_data.find("client_id="); - if(index == std::string::npos) return ""; + if(index == std::string::npos) + return ""; index += 10; - size_t end = website_data.find('&', index); - if(end == std::string::npos) end = website_data.size(); - return website_data.substr(index, end - index); + const size_t start_next_arg = website_data.find('&', index); + const size_t start_end_of_str = website_data.find('"', index); + if(start_next_arg == std::string::npos && start_end_of_str == std::string::npos) + return ""; + + size_t min_end = start_next_arg; + if(min_end == std::string::npos || start_end_of_str < min_end) + min_end = start_end_of_str; + + return website_data.substr(index, min_end - index); })); } |