aboutsummaryrefslogtreecommitdiff
path: root/src/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/Info.cpp15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/plugins/Info.cpp b/src/plugins/Info.cpp
index b1943b3..a68033f 100644
--- a/src/plugins/Info.cpp
+++ b/src/plugins/Info.cpp
@@ -1,5 +1,6 @@
#include "../../plugins/Info.hpp"
#include "../../plugins/Saucenao.hpp"
+#include "../../plugins/Youtube.hpp"
#include "../../include/StringUtils.hpp"
#include "../../include/Program.hpp"
#include "../../include/Notification.hpp"
@@ -7,11 +8,18 @@
namespace QuickMedia {
static const char *REVERSE_IMAGE_SEARCH_URL = "reverse-image-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;
+ }
+
PluginResult InfoPage::submit(const std::string&, const std::string &url, std::vector<Tab> &result_tabs) {
if(string_starts_with(url, REVERSE_IMAGE_SEARCH_URL)) {
std::string image_url = url.substr(strlen(REVERSE_IMAGE_SEARCH_URL));
result_tabs.push_back(Tab{create_body(), std::make_unique<SaucenaoPage>(program, image_url, false), nullptr});
return PluginResult::OK;
+ } else if(is_youtube_url(url)) {
+ result_tabs.push_back(Tab{nullptr, std::make_unique<YoutubeVideoPage>(program, url), nullptr});
+ return PluginResult::OK;
} else {
const char *launch_program = "xdg-open";
if(!is_program_executable_by_name("xdg-open")) {
@@ -33,7 +41,12 @@ namespace QuickMedia {
// static
std::shared_ptr<BodyItem> InfoPage::add_url(const std::string &url) {
- auto body_item = BodyItem::create("Open " + url + " in a browser");
+ std::string title;
+ if(is_youtube_url(url))
+ title = "Play " + url;
+ else
+ title = "Open " + url + " in a browser";
+ auto body_item = BodyItem::create(std::move(title));
body_item->url = url;
return body_item;
}