From 1de2ff02bb746607727900180b6f32ded0cd7856 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Wed, 23 Nov 2022 18:54:18 +0100 Subject: Allow opening 4chan post directly --- src/plugins/Info.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/plugins/Info.cpp') 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 &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(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(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(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 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; -- cgit v1.2.3