aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2023-12-14 18:10:34 +0100
committerdec05eba <dec05eba@protonmail.com>2023-12-14 18:10:34 +0100
commit5ba885fb9ce0bdf3bb575c462a203ff3b309e016 (patch)
tree6923d79380a077dc2616a4bd4c70d2ff86e8c41a /src
parent23c0756da4322a4a11f1b16b6398930bb1a29264 (diff)
Dont redirect invidious website to youtube (non video page), redirect invidious to youtube on 4chan/saucenao
Diffstat (limited to 'src')
-rw-r--r--src/QuickMedia.cpp8
-rw-r--r--src/plugins/Info.cpp20
2 files changed, 16 insertions, 12 deletions
diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp
index 55871b4..99e68df 100644
--- a/src/QuickMedia.cpp
+++ b/src/QuickMedia.cpp
@@ -6657,6 +6657,7 @@ namespace QuickMedia {
if(url.empty())
return;
+ std::string original_url = url;
url = invidious_url_to_youtube_url(url);
std::string youtube_channel_id;
@@ -6695,9 +6696,10 @@ namespace QuickMedia {
return;
}
}
- std::string url_modified = url;
- if(strncmp(url.c_str(), "http://", 7) != 0 && strncmp(url.c_str(), "https://", 8) != 0)
- url_modified = "https://" + url;
+
+ std::string url_modified = std::move(original_url);
+ if(strncmp(url_modified.c_str(), "http://", 7) != 0 && strncmp(url_modified.c_str(), "https://", 8) != 0)
+ url_modified = "https://" + url_modified;
const char *args[] = { launch_program, url_modified.c_str(), nullptr };
exec_program_async(args, nullptr);
}
diff --git a/src/plugins/Info.cpp b/src/plugins/Info.cpp
index d4ee5f1..29e3a63 100644
--- a/src/plugins/Info.cpp
+++ b/src/plugins/Info.cpp
@@ -12,14 +12,14 @@ namespace QuickMedia {
static const char *GOOGLE_SEARCH_URL = "google-search://";
static bool is_youtube_url(const std::string &url) {
- return url.find("youtube.com/") != std::string::npos || url.find("youtu.be/") != std::string::npos;
+ std::string video_id;
+ return youtube_url_extract_id(url, video_id);
}
static bool is_youtube_channel_url(const std::string &url) {
- return url.find("youtube.com/c/") != std::string::npos || url.find("youtu.be/c/") != std::string::npos
- || url.find("youtube.com/channel/") != std::string::npos || url.find("youtu.be/channel/") != std::string::npos
- || url.find("youtube.com/@") != std::string::npos || url.find("youtu.be/@") != std::string::npos
- || url.find("youtube.com/user") != std::string::npos || url.find("youtu.be/user") != std::string::npos;
+ std::string channel_id;
+ std::string channel_url;
+ return youtube_url_extract_channel_id(url, channel_id, channel_url);
}
static PluginResult open_with_browser(const std::string &url) {
@@ -41,6 +41,8 @@ namespace QuickMedia {
}
PluginResult InfoPage::submit(const SubmitArgs &args, std::vector<Tab> &result_tabs) {
+ std::string converted_url = invidious_url_to_youtube_url(args.url);
+
std::string board_id, thread_id, post_id;
if(string_starts_with(args.url, REVERSE_IMAGE_SEARCH_URL)) {
std::string image_url = args.url.substr(strlen(REVERSE_IMAGE_SEARCH_URL));
@@ -50,11 +52,11 @@ namespace QuickMedia {
const std::string search_term = args.url.substr(strlen(GOOGLE_SEARCH_URL));
const std::string search_url = "https://www.google.com/search?q=" + url_param_encode(search_term);
return open_with_browser(search_url);
- } else if(is_youtube_channel_url(args.url)) {
- YoutubeChannelPage::create_each_type(program, args.url, "", "Channel", result_tabs);
+ } else if(is_youtube_channel_url(converted_url)) {
+ YoutubeChannelPage::create_each_type(program, std::move(converted_url), "", "Channel", result_tabs);
return PluginResult::OK;
- } else if(is_youtube_url(args.url)) {
- result_tabs.push_back(Tab{nullptr, std::make_unique<YoutubeVideoPage>(program, args.url, false), nullptr});
+ } else if(is_youtube_url(converted_url)) {
+ result_tabs.push_back(Tab{nullptr, std::make_unique<YoutubeVideoPage>(program, std::move(converted_url), false), nullptr});
return PluginResult::OK;
} else if(fourchan_extract_url(args.url, board_id, thread_id, post_id)) {
result_tabs.push_back(Tab{create_body(), std::make_unique<FourchanThreadPage>(program, std::move(board_id), std::move(thread_id), std::move(post_id), ""), nullptr});