aboutsummaryrefslogtreecommitdiff
path: root/src/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/Info.cpp20
1 files changed, 11 insertions, 9 deletions
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});