1 parent
9f06af6c80
commit
7975f2b38e
19 files changed
+2020
-747
No files matched your search
@@ -2,6 +2,7 @@
|
||||
|
||||
#include <Void/Data/Json.hpp>
|
||||
#include <Void/Log/Log.hpp>
|
||||
#include <Void/Text/Url.hpp>
|
||||
#include <format>
|
||||
#include <openssl/evp.h>
|
||||
#include <regex>
|
||||
@@ -62,27 +63,6 @@ namespace Echoion::Core
|
||||
return std::regex_search(url, playlist);
|
||||
}
|
||||
|
||||
std::string percentEncode(std::string_view text)
|
||||
{
|
||||
static constexpr char hex[] = "0123456789ABCDEF";
|
||||
std::string out;
|
||||
out.reserve(text.size() * 3);
|
||||
for (unsigned char c : text) {
|
||||
const bool unreserved = (c >= 'A' && c <= 'Z') ||
|
||||
(c >= 'a' && c <= 'z') ||
|
||||
(c >= '0' && c <= '9') || c == '-' ||
|
||||
c == '_' || c == '.' || c == '~';
|
||||
if (unreserved) {
|
||||
out.push_back(static_cast<char>(c));
|
||||
} else {
|
||||
out.push_back('%');
|
||||
out.push_back(hex[c >> 4]);
|
||||
out.push_back(hex[c & 0xF]);
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
std::string str(const Void::Json::Value& v, const char* key)
|
||||
{
|
||||
const auto* f = v.find(key);
|
||||
@@ -198,8 +178,8 @@ namespace Echoion::Core
|
||||
"Yandex Music not configured");
|
||||
}
|
||||
|
||||
auto body =
|
||||
apiGet("/search?type=track&page=0&text=" + percentEncode(query));
|
||||
auto body = apiGet("/search?type=track&page=0&text=" +
|
||||
Void::Encoding::Url::encode(query));
|
||||
if (!body) {
|
||||
return std::unexpected(body.error());
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user