aboutsummaryrefslogtreecommitdiff
path: root/src/plugins
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2021-08-25 18:48:34 +0200
committerdec05eba <dec05eba@protonmail.com>2021-08-25 18:48:34 +0200
commit0a26a319b241978ee317bbe768eb61c4eb7a39d9 (patch)
treebfa56141b5140c1f25c81925d5fc616012bd22a3 /src/plugins
parent48da6508416dd80c68c9213a242a2542af2574fe (diff)
Faster mangakatana search on exact match
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/MangaGeneric.cpp16
-rw-r--r--src/plugins/Youtube.cpp12
2 files changed, 14 insertions, 14 deletions
diff --git a/src/plugins/MangaGeneric.cpp b/src/plugins/MangaGeneric.cpp
index 738c6dc..87b4f1d 100644
--- a/src/plugins/MangaGeneric.cpp
+++ b/src/plugins/MangaGeneric.cpp
@@ -169,7 +169,8 @@ namespace QuickMedia {
std::string target_url;
std::string website_data;
- if(download_to_string(url, website_data, args, true, fail_on_http_error) != DownloadResult::OK)
+ std::vector<std::string> website_headers;
+ if(download_to_string(url, website_data, args, true, fail_on_http_error, false, &website_headers) != DownloadResult::OK)
return PluginResult::NET_ERR;
if(website_data.empty())
@@ -199,17 +200,10 @@ namespace QuickMedia {
goto cleanup;
if(!text_query.url_field && !new_result_items.empty()) {
- if(target_url.empty()) {
- std::string response_headers;
- DownloadResult download_result = download_head_to_string(url, response_headers, true);
- if(download_result != DownloadResult::OK) {
- result = -1;
- goto cleanup;
- }
-
- target_url = header_extract_value(response_headers, "location");
+ if(target_url.empty() && !website_headers.empty()) {
+ target_url = header_extract_value(website_headers.front(), "location");
if(target_url.empty()) {
- fprintf(stderr, "Failed to extract target location from %s HEAD\n", url.c_str());
+ fprintf(stderr, "Failed to extract target location from %s\n", url.c_str());
result = -1;
goto cleanup;
}
diff --git a/src/plugins/Youtube.cpp b/src/plugins/Youtube.cpp
index 4934c43..b490e97 100644
--- a/src/plugins/Youtube.cpp
+++ b/src/plugins/Youtube.cpp
@@ -237,20 +237,26 @@ namespace QuickMedia {
std::vector<CommandArg> additional_args = get_cookies();
additional_args.push_back({"--no-buffer", ""});
+ std::vector<std::string> response_headers;
const int max_redirects = 5;
for(int i = 0; i < max_redirects; ++i) {
std::string response_body;
- std::string response_headers;
+ response_headers.clear();
download_to_string(playback_url, response_body, additional_args, true, true, false, &response_headers, 4096);
- std::string content_type = header_extract_value(response_headers, "content-type");
+ if(response_headers.empty()) {
+ fprintf(stderr, "Youtube video header not found\n");
+ return "";
+ }
+
+ std::string content_type = header_extract_value(response_headers.back(), "content-type");
if(content_type.empty()) {
fprintf(stderr, "Failed to find content-type in youtube video header\n");
return "";
}
if(string_starts_with(content_type, "video") || string_starts_with(content_type, "audio")) {
- std::string content_length_str = header_extract_value(response_headers, "content-length");
+ std::string content_length_str = header_extract_value(response_headers.back(), "content-length");
if(content_length_str.empty())
return "";