aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md3
-rw-r--r--src/DownloadUtils.cpp49
-rw-r--r--src/QuickMedia.cpp29
-rw-r--r--src/plugins/MediaGeneric.cpp2
4 files changed, 54 insertions, 29 deletions
diff --git a/README.md b/README.md
index 5a38637..66bc922 100644
--- a/README.md
+++ b/README.md
@@ -38,7 +38,8 @@ If you are running arch linux then you can install QuickMedia from aur (https://
`waifu2x-ncnn-vulkan` needs to be installed when using the `--upscale-images` or `--upscale-images-always` option.\
`xdg-utils` which provides `xdg-open` needs to be installed when downloading torrents with `nyaa.si` plugin.\
`ffmpeg (and ffprobe which is included in ffmpeg)` needs to be installed to display webp thumbnails, to upload videos with thumbnails on matrix or to merge video and audio when downloading youtube videos.\
-`fc-match` (which is part of `fontconfig`) needs to be installed when `use_system_fonts` config is set to `true`.
+`fc-match` (which is part of `fontconfig`) needs to be installed when `use_system_fonts` config is set to `true`.\
+`wget` needs to be installed for coom plugins.
## Controls
### General control
Type text and then wait and QuickMedia will automatically search.\
diff --git a/src/DownloadUtils.cpp b/src/DownloadUtils.cpp
index 584d4a3..a4557d2 100644
--- a/src/DownloadUtils.cpp
+++ b/src/DownloadUtils.cpp
@@ -197,22 +197,41 @@ namespace QuickMedia {
result.clear();
mgl::Clock timer;
std::vector<const char*> args;
- args.insert(args.end(), { "curl", "-H", "Accept-Language: en-US,en;q=0.5", "-H", "Connection: keep-alive", "--compressed", "-g", "-s", "-L" });
- if(fail_on_error)
- args.push_back("-f");
- for(const CommandArg &arg : additional_args) {
- args.push_back(arg.option.c_str());
- if(!arg.value.empty())
- args.push_back(arg.value.c_str());
- }
- if(!cloudflare_bypass && use_browser_useragent) {
- args.push_back("-H");
- args.push_back(useragent_str);
+
+ if(cloudflare_bypass) {
+ args.insert(args.end(), { "wget", "--header", "Accept-Language: en-US,en;q=0.5", "-q", "-O", "-" });
+ // TODO:
+ //if(fail_on_error)
+ // args.push_back("-f");
+ // TODO: May not be compatible
+ for(const CommandArg &arg : additional_args) {
+ args.push_back(arg.option.c_str());
+ if(!arg.value.empty())
+ args.push_back(arg.value.c_str());
+ }
+ if(use_browser_useragent) {
+ args.push_back("--header");
+ args.push_back(useragent_str);
+ }
+ // TODO:
+ //if(headers)
+ // args.push_back("-i");
+ } else {
+ args.insert(args.end(), { "curl", "-H", "Accept-Language: en-US,en;q=0.5", "-H", "Connection: keep-alive", "--compressed", "-g", "-s", "-L" });
+ if(fail_on_error)
+ args.push_back("-f");
+ for(const CommandArg &arg : additional_args) {
+ args.push_back(arg.option.c_str());
+ if(!arg.value.empty())
+ args.push_back(arg.value.c_str());
+ }
+ if(use_browser_useragent) {
+ args.push_back("-H");
+ args.push_back(useragent_str);
+ }
+ if(headers)
+ args.push_back("-i");
}
- if(cloudflare_bypass)
- args.insert(args.end(), { "--tls-max", "1.1", "-A", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; FSL 7.0.6" });
- if(headers)
- args.push_back("-i");
args.push_back("--");
args.push_back(url.c_str());
args.push_back(nullptr);
diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp
index d49aa32..1ee0816 100644
--- a/src/QuickMedia.cpp
+++ b/src/QuickMedia.cpp
@@ -1239,7 +1239,7 @@ namespace QuickMedia {
}
} else if(strcmp(plugin_name, "pornhub") == 0) {
check_youtube_dl_installed(plugin_name);
- auto search_page = std::make_unique<MediaGenericSearchPage>(this, "https://www.pornhub.com/", mgl::vec2i(320/1.5f, 180/1.5f), false);
+ auto search_page = std::make_unique<MediaGenericSearchPage>(this, "https://www.pornhub.com/", mgl::vec2i(320/1.5f, 180/1.5f), true);
add_pornhub_handlers(search_page.get());
tabs.push_back(Tab{create_body(false, true), std::move(search_page), create_search_bar("Search...", 500)});
use_youtube_dl = true;
@@ -1253,15 +1253,15 @@ namespace QuickMedia {
check_youtube_dl_installed(plugin_name);
std::vector<CommandArg> extra_commands = {
- { "-H", "Cookie: last_views=%5B%2236247565-" + std::to_string(time(nullptr)) + "%22%5D" }
+ { "--header", "Cookie: last_views=%5B%2236247565-" + std::to_string(time(nullptr)) + "%22%5D" }
};
- auto search_page = std::make_unique<MediaGenericSearchPage>(this, "https://www.xvideos.com/", mgl::vec2i(352/1.5f, 198/1.5f), false, std::move(extra_commands));
+ auto search_page = std::make_unique<MediaGenericSearchPage>(this, "https://www.xvideos.com/", mgl::vec2i(352/1.5f, 198/1.5f), true, std::move(extra_commands));
add_xvideos_handlers(search_page.get());
tabs.push_back(Tab{create_body(false, true), std::move(search_page), create_search_bar("Search...", 500)});
use_youtube_dl = true;
} else if(strcmp(plugin_name, "xhamster") == 0) {
check_youtube_dl_installed(plugin_name);
- auto search_page = std::make_unique<MediaGenericSearchPage>(this, "https://xhamster.com/", mgl::vec2i(240, 135), false);
+ auto search_page = std::make_unique<MediaGenericSearchPage>(this, "https://xhamster.com/", mgl::vec2i(240, 135), true);
add_xhamster_handlers(search_page.get());
tabs.push_back(Tab{create_body(false, true), std::move(search_page), create_search_bar("Search...", 500)});
use_youtube_dl = true;
@@ -3234,16 +3234,16 @@ namespace QuickMedia {
if(video_page->autoplay_next_item())
return;
- // TODO: Make this also work for other video plugins
- if(strcmp(plugin_name, "youtube") != 0 || is_resume_go_back)
- return;
-
std::string url = video_page->get_url();
related_videos_task = AsyncTask<void>([&related_videos, url, video_page]() {
video_page->mark_watched();
related_videos = video_page->get_related_media(url);
});
+ // TODO: Make this also work for other video plugins
+ if(strcmp(plugin_name, "youtube") != 0 || is_resume_go_back)
+ return;
+
std::string video_id;
if(!youtube_url_extract_id(video_page->get_url(), video_id)) {
std::string err_msg = "Failed to extract id of youtube url ";
@@ -3371,6 +3371,11 @@ namespace QuickMedia {
video_player->get_time_in_file(&resume_start_time);
load_video_error_check(std::to_string((int)resume_start_time));
} else if(pressed_keysym == XK_r && pressing_ctrl && !video_page->is_local()) {
+ cursor_hide_timer.restart();
+ if(!cursor_visible)
+ window.set_cursor_visible(true);
+ cursor_visible = true;
+
bool cancelled = false;
if(related_videos_task.valid()) {
XUnmapWindow(disp, video_player_window);
@@ -3396,9 +3401,9 @@ namespace QuickMedia {
}
if(!cancelled) {
- if(!cursor_visible)
- window.set_cursor_visible(true);
- cursor_visible = true;
+ XUnmapWindow(disp, video_player_window);
+ XSync(disp, False);
+ XFlush(disp);
std::vector<Tab> related_pages;
TaskResult related_pages_result = run_task_with_loading_screen([&video_page, &related_videos, &channel_url, &related_pages]{
@@ -3409,7 +3414,7 @@ namespace QuickMedia {
XMapWindow(disp, video_player_window);
XSync(disp, False);
show_notification("QuickMedia", "Failed to get related pages", Urgency::CRITICAL);
- } else if(related_pages_result == TaskResult::TRUE) {
+ } else if(related_pages_result == TaskResult::TRUE && !related_pages.empty()) {
bool page_changed = false;
double resume_start_time = 0.0;
page_loop(related_pages, video_page->get_related_pages_first_tab(), [&](const std::vector<Tab> &new_tabs) {
diff --git a/src/plugins/MediaGeneric.cpp b/src/plugins/MediaGeneric.cpp
index 0b69556..adbac0d 100644
--- a/src/plugins/MediaGeneric.cpp
+++ b/src/plugins/MediaGeneric.cpp
@@ -40,7 +40,7 @@ namespace QuickMedia {
static PluginResult fetch_page_results(const std::string &url, const std::string &website_url, const std::vector<MediaTextQuery> &text_queries, const std::vector<MediaThumbnailQuery> &thumbnail_queries, mgl::vec2i thumbnail_max_size, MediaRelatedCustomHandler *custom_handler, BodyItems &result_items, bool cloudflare_bypass, const std::vector<CommandArg> &extra_commands) {
std::vector<CommandArg> args = extra_commands;
if(!website_url.empty())
- args.push_back({ "-H", "referer: " + website_url });
+ args.push_back({ "--header", "referer: " + website_url });
std::string website_data;
if(download_to_string(url, website_data, args, true, true, cloudflare_bypass) != DownloadResult::OK)