aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2023-12-14 18:10:34 +0100
committerdec05eba <dec05eba@protonmail.com>2023-12-14 18:10:34 +0100
commit5ba885fb9ce0bdf3bb575c462a203ff3b309e016 (patch)
tree6923d79380a077dc2616a4bd4c70d2ff86e8c41a
parent23c0756da4322a4a11f1b16b6398930bb1a29264 (diff)
Dont redirect invidious website to youtube (non video page), redirect invidious to youtube on 4chan/saucenao
-rw-r--r--README.md5
m---------depends/mglpp0
-rw-r--r--src/QuickMedia.cpp8
-rw-r--r--src/plugins/Info.cpp20
4 files changed, 19 insertions, 14 deletions
diff --git a/README.md b/README.md
index bb4484d..bf69a6b 100644
--- a/README.md
+++ b/README.md
@@ -24,8 +24,9 @@ EXAMPLES:
tabbed -c -k quickmedia launcher -e
```
## Installation
-If you are running arch linux then you can install QuickMedia from aur (https://aur.archlinux.org/packages/quickmedia-git/), otherwise you will need to first install [sibs](https://git.dec05eba.com/sibs/) and then run `./install.sh` as root.\
-`atr` and curl needs to be installed to run the `install.sh` script.\
+If you are running arch linux then you can install QuickMedia from aur: https://aur.archlinux.org/packages/quickmedia-git/, otherwise you will need to first install [sibs](https://git.dec05eba.com/sibs/) and then run `./install.sh` as root.\
+There is also an unofficial ebuild for gentoo users: https://gitea.plan9.rocks/9/overlay-from-plan9/raw/branch/master/net-im/quickmedia/quickmedia-9999.ebuild.\
+`tar` and curl needs to be installed to run the `install.sh` script.\
Installing `lld` (the LLVM linker) can improve compile times.
## Dependencies
### Libraries
diff --git a/depends/mglpp b/depends/mglpp
-Subproject 3070a4267f1ec136e1e35cc4b78f2995e0da4e9
+Subproject b4bd4748c0a4806b0cde7df73e591f324d10650
diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp
index 55871b4..99e68df 100644
--- a/src/QuickMedia.cpp
+++ b/src/QuickMedia.cpp
@@ -6657,6 +6657,7 @@ namespace QuickMedia {
if(url.empty())
return;
+ std::string original_url = url;
url = invidious_url_to_youtube_url(url);
std::string youtube_channel_id;
@@ -6695,9 +6696,10 @@ namespace QuickMedia {
return;
}
}
- std::string url_modified = url;
- if(strncmp(url.c_str(), "http://", 7) != 0 && strncmp(url.c_str(), "https://", 8) != 0)
- url_modified = "https://" + url;
+
+ std::string url_modified = std::move(original_url);
+ if(strncmp(url_modified.c_str(), "http://", 7) != 0 && strncmp(url_modified.c_str(), "https://", 8) != 0)
+ url_modified = "https://" + url_modified;
const char *args[] = { launch_program, url_modified.c_str(), nullptr };
exec_program_async(args, nullptr);
}
diff --git a/src/plugins/Info.cpp b/src/plugins/Info.cpp
index d4ee5f1..29e3a63 100644
--- a/src/plugins/Info.cpp
+++ b/src/plugins/Info.cpp
@@ -12,14 +12,14 @@ namespace QuickMedia {
static const char *GOOGLE_SEARCH_URL = "google-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;
+ std::string video_id;
+ return youtube_url_extract_id(url, video_id);
}
static bool is_youtube_channel_url(const std::string &url) {
- return url.find("youtube.com/c/") != std::string::npos || url.find("youtu.be/c/") != std::string::npos
- || url.find("youtube.com/channel/") != std::string::npos || url.find("youtu.be/channel/") != std::string::npos
- || url.find("youtube.com/@") != std::string::npos || url.find("youtu.be/@") != std::string::npos
- || url.find("youtube.com/user") != std::string::npos || url.find("youtu.be/user") != std::string::npos;
+ std::string channel_id;
+ std::string channel_url;
+ return youtube_url_extract_channel_id(url, channel_id, channel_url);
}
static PluginResult open_with_browser(const std::string &url) {
@@ -41,6 +41,8 @@ namespace QuickMedia {
}
PluginResult InfoPage::submit(const SubmitArgs &args, std::vector<Tab> &result_tabs) {
+ std::string converted_url = invidious_url_to_youtube_url(args.url);
+
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));
@@ -50,11 +52,11 @@ namespace QuickMedia {
const std::string search_term = args.url.substr(strlen(GOOGLE_SEARCH_URL));
const std::string search_url = "https://www.google.com/search?q=" + url_param_encode(search_term);
return open_with_browser(search_url);
- } else if(is_youtube_channel_url(args.url)) {
- YoutubeChannelPage::create_each_type(program, args.url, "", "Channel", result_tabs);
+ } else if(is_youtube_channel_url(converted_url)) {
+ YoutubeChannelPage::create_each_type(program, std::move(converted_url), "", "Channel", result_tabs);
return PluginResult::OK;
- } else if(is_youtube_url(args.url)) {
- result_tabs.push_back(Tab{nullptr, std::make_unique<YoutubeVideoPage>(program, args.url, false), nullptr});
+ } else if(is_youtube_url(converted_url)) {
+ result_tabs.push_back(Tab{nullptr, std::make_unique<YoutubeVideoPage>(program, std::move(converted_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});