diff options
author | dec05eba <dec05eba@protonmail.com> | 2021-05-30 17:01:14 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2021-05-30 17:01:14 +0200 |
commit | 664835fcee5f0dc1fa5aba63c845c4561628a20f (patch) | |
tree | a296eb4e0dd911e54bc9ba458244263764e1837b /src/plugins | |
parent | 196fd3182672b03f8468e5654736c614242b0f64 (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')
-rw-r--r-- | src/plugins/Info.cpp | 15 |
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; } |