aboutsummaryrefslogtreecommitdiff
path: root/src/plugins/Info.cpp
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2022-11-23 18:54:18 +0100
committerdec05eba <dec05eba@protonmail.com>2022-11-23 18:54:22 +0100
commit1de2ff02bb746607727900180b6f32ded0cd7856 (patch)
tree0f9f634674d5f48a65e84c8067461e53d83700e2 /src/plugins/Info.cpp
parent89c41c1488854858e02ff6bd48a6518161fa05a5 (diff)
Allow opening 4chan post directly
Diffstat (limited to 'src/plugins/Info.cpp')
-rw-r--r--src/plugins/Info.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/plugins/Info.cpp b/src/plugins/Info.cpp
index 1ad7320..d4ee5f1 100644
--- a/src/plugins/Info.cpp
+++ b/src/plugins/Info.cpp
@@ -1,6 +1,7 @@
#include "../../plugins/Info.hpp"
#include "../../plugins/Saucenao.hpp"
#include "../../plugins/Youtube.hpp"
+#include "../../plugins/Fourchan.hpp"
#include "../../include/StringUtils.hpp"
#include "../../include/Program.hpp"
#include "../../include/Notification.hpp"
@@ -40,6 +41,7 @@ namespace QuickMedia {
}
PluginResult InfoPage::submit(const SubmitArgs &args, std::vector<Tab> &result_tabs) {
+ 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));
result_tabs.push_back(Tab{create_body(), std::make_unique<SaucenaoPage>(program, image_url, false), nullptr});
@@ -54,6 +56,9 @@ namespace QuickMedia {
} else if(is_youtube_url(args.url)) {
result_tabs.push_back(Tab{nullptr, std::make_unique<YoutubeVideoPage>(program, args.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});
+ return PluginResult::OK;
} else {
return open_with_browser(args.url);
}
@@ -75,13 +80,18 @@ namespace QuickMedia {
// static
std::shared_ptr<BodyItem> InfoPage::add_url(const std::string &url) {
+ std::string board_id, thread_id, comment_id;
std::string title;
+
if(is_youtube_channel_url(url))
title = "Open youtube channel " + url;
else if(is_youtube_url(url))
title = "Play " + url;
+ else if(fourchan_extract_url(url, board_id, thread_id, comment_id))
+ title = "Open " + url;
else
title = "Open " + url + " in a browser";
+
auto body_item = BodyItem::create(std::move(title));
body_item->url = url;
return body_item;