aboutsummaryrefslogtreecommitdiff
path: root/src/plugins/Info.cpp
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2021-05-30 17:01:14 +0200
committerdec05eba <dec05eba@protonmail.com>2021-05-30 17:01:14 +0200
commit664835fcee5f0dc1fa5aba63c845c4561628a20f (patch)
treea296eb4e0dd911e54bc9ba458244263764e1837b /src/plugins/Info.cpp
parent196fd3182672b03f8468e5654736c614242b0f64 (diff)
Add option to only save audio for youtube videos. Use youtube plugin for info urls. Use youtube plugin for urls on matrix
Diffstat (limited to 'src/plugins/Info.cpp')
-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;
}