diff --git a/scripts/psv/curl/fix_curlformoption.patch b/scripts/psv/curl/fix_curlformoption.patch deleted file mode 100644 index 7678e0d5a..000000000 --- a/scripts/psv/curl/fix_curlformoption.patch +++ /dev/null @@ -1,17 +0,0 @@ -diff --git a/lib/formdata.c b/lib/formdata.c -index f5ed3653dfabc..3128f495b1b70 100644 ---- a/lib/formdata.c -+++ b/lib/formdata.c -@@ -251,8 +251,10 @@ CURLFORMcode FormAdd(struct curl_httppost **httppost, - } - } - else { -- /* This is not array-state, get next option */ -- option = va_arg(params, CURLformoption); -+ /* This is not array-state, get next option. This gets an 'int' with -+ va_arg() because CURLformoption might be a smaller type than int and -+ might cause compiler warnings and wrong behavior. */ -+ option = va_arg(params, int); - if(CURLFORM_END == option) - break; - } diff --git a/wiliwili/include/api/bilibili/api.h b/wiliwili/include/api/bilibili/api.h index e5b45a129..5c3ab69a8 100644 --- a/wiliwili/include/api/bilibili/api.h +++ b/wiliwili/include/api/bilibili/api.h @@ -8,14 +8,14 @@ namespace bilibili { namespace Api { -const std::string _apiBase = "https://api.bilibili.com"; -const std::string _appBase = "https://app.bilibili.com"; -const std::string _vcBase = "https://api.vc.bilibili.com"; -const std::string _bvcBase = "https://bvc.bilivideo.com"; -const std::string _liveBase = "https://api.live.bilibili.com"; -const std::string _passBase = "https://passport.bilibili.com"; -const std::string _bangumiBase = "https://bangumi.bilibili.com"; -const std::string _grpcBase = "https://grpc.biliapi.net"; +const std::string _apiBase = "api.bilibili.com"; +const std::string _appBase = "app.bilibili.com"; +const std::string _vcBase = "api.vc.bilibili.com"; +const std::string _bvcBase = "bvc.bilivideo.com"; +const std::string _liveBase = "api.live.bilibili.com"; +const std::string _passBase = "passport.bilibili.com"; +const std::string _bangumiBase = "bangumi.bilibili.com"; +const std::string _grpcBase = "grpc.biliapi.net"; /// === /// 视频API diff --git a/wiliwili/include/api/bilibili/util/http.hpp b/wiliwili/include/api/bilibili/util/http.hpp index a22772972..aaf381202 100644 --- a/wiliwili/include/api/bilibili/util/http.hpp +++ b/wiliwili/include/api/bilibili/util/http.hpp @@ -42,6 +42,7 @@ class HTTP { static inline int TIMEOUT = 10000; static inline cpr::Proxies PROXIES; static inline cpr::VerifySsl VERIFY; + static inline std::string PROTOCOL = "https://"; static cpr::Response get(const std::string& url, const cpr::Parameters& parameters = {}, int timeout = 10000); @@ -60,7 +61,8 @@ class HTTP { } callback(r); }, - cpr::Url{url}, parameters, payload, CPR_HTTP_BASE); + cpr::Url{pystring::startswith(url, "http") ? url : HTTP::PROTOCOL + url}, + parameters, payload, CPR_HTTP_BASE); } static void __cpr_get(const std::string& url, const cpr::Parameters& parameters = {}, @@ -77,7 +79,8 @@ class HTTP { } callback(r); }, - cpr::Url{url}, parameters, CPR_HTTP_BASE); + cpr::Url{pystring::startswith(url, "http") ? url : HTTP::PROTOCOL + url}, + parameters, CPR_HTTP_BASE); } template diff --git a/wiliwili/source/api/bilibili.cpp b/wiliwili/source/api/bilibili.cpp index 35aac1efc..197096094 100644 --- a/wiliwili/source/api/bilibili.cpp +++ b/wiliwili/source/api/bilibili.cpp @@ -44,6 +44,9 @@ void BilibiliClient::setProxy(const std::string& httpProxy, const std::string& h if (!httpProxy.empty() && !httpsProxy.empty()) HTTP::PROXIES = {{"http", httpProxy}, {"https", httpsProxy}}; } -void BilibiliClient::setTlsVerify(bool value) { HTTP::VERIFY = cpr::VerifySsl{value}; } +void BilibiliClient::setTlsVerify(bool value) { + HTTP::VERIFY = cpr::VerifySsl{value}; + HTTP::PROTOCOL = value ? "https://" : "http://"; +} } // namespace bilibili \ No newline at end of file diff --git a/wiliwili/source/api/home_api.cpp b/wiliwili/source/api/home_api.cpp index 7925ba6ed..3a4e41b05 100644 --- a/wiliwili/source/api/home_api.cpp +++ b/wiliwili/source/api/home_api.cpp @@ -197,7 +197,7 @@ void BilibiliClient::get_pgc_all_filter(const std::function session = std::make_shared(); - session->SetUrl(Api::PGCIndexFilter); + session->SetUrl(HTTP::PROTOCOL + Api::PGCIndexFilter); session->SetParameters({{"type", "2"}, {"index_type", i}}); session->SetHeader(HTTP::HEADERS); session->SetVerifySsl(HTTP::VERIFY); diff --git a/wiliwili/source/utils/image_helper.cpp b/wiliwili/source/utils/image_helper.cpp index 44c478a52..77099633e 100644 --- a/wiliwili/source/utils/image_helper.cpp +++ b/wiliwili/source/utils/image_helper.cpp @@ -143,7 +143,7 @@ std::shared_ptr ImageHelper::with(brls::Image* view) { } void ImageHelper::load(const std::string &url) { - this->imageUrl = url; + this->imageUrl = bilibili::HTTP::VERIFY ? url :pystring::replace(url, "https", "http", 1); #ifdef BOREALIS_USE_GXM std::vector urls = pystring::rsplit(this->imageUrl, "@", 1);