aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Downloader.cpp4
-rw-r--r--src/QuickMedia.cpp14
-rw-r--r--src/plugins/Youtube.cpp27
3 files changed, 37 insertions, 8 deletions
diff --git a/src/Downloader.cpp b/src/Downloader.cpp
index 450bff3..fc16e07 100644
--- a/src/Downloader.cpp
+++ b/src/Downloader.cpp
@@ -27,7 +27,7 @@ namespace QuickMedia {
const char *args[] = { "curl",
"-H", "Accept-Language: en-US,en;q=0.5", "-H", "Connection: keep-alive", "--compressed",
"-H", "user-agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36",
- "-g", "-s", "-L", "-f", "-o", output_filepath_tmp.data.c_str(),
+ "--no-buffer", "-g", "-s", "-L", "-f", "-o", output_filepath_tmp.data.c_str(),
"-D", "/dev/stdout",
"--", url.c_str(), nullptr };
@@ -37,7 +37,7 @@ namespace QuickMedia {
const char *args[] = { "curl",
"-H", "Accept-Language: en-US,en;q=0.5", "-H", "Connection: keep-alive", "--compressed",
"-H", "user-agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36",
- "-g", "-s", "-L", "-f", "-o", output_filepath_tmp.data.c_str(),
+ "--no-buffer", "-g", "-s", "-L", "-f", "-o", output_filepath_tmp.data.c_str(),
"--", url.c_str(), nullptr };
if(exec_program_pipe(args, &read_program) != 0)
diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp
index 6a37b1d..d006f3d 100644
--- a/src/QuickMedia.cpp
+++ b/src/QuickMedia.cpp
@@ -397,8 +397,9 @@ namespace QuickMedia {
for(int i = 1; i < argc; ++i) {
if(!plugin_name) {
std::string youtube_video_id_dummy;
- if(youtube_url_extract_id(argv[i], youtube_video_id_dummy)) {
- youtube_url = argv[i];
+ std::string youtube_url_converted = invidious_url_to_youtube_url(argv[i]);
+ if(youtube_url_extract_id(youtube_url_converted, youtube_video_id_dummy)) {
+ youtube_url = std::move(youtube_url_converted);
plugin_name = "youtube";
}
@@ -5514,16 +5515,18 @@ namespace QuickMedia {
bool avatar_applied = false;
- auto launch_url = [this, matrix_chat_page, &tabs, MESSAGES_TAB_INDEX, &redraw, &avatar_applied](const std::string &url) mutable {
+ auto launch_url = [this, matrix_chat_page, &tabs, MESSAGES_TAB_INDEX, &redraw, &avatar_applied](std::string url) mutable {
if(url.empty())
return;
+ url = invidious_url_to_youtube_url(url);
+
std::string video_id;
if(youtube_url_extract_id(url, video_id)) {
watched_videos.clear();
page_stack.push(PageType::CHAT);
current_page = PageType::VIDEO_CONTENT;
- auto youtube_video_page = std::make_unique<YoutubeVideoPage>(this, url);
+ auto youtube_video_page = std::make_unique<YoutubeVideoPage>(this, std::move(url));
// TODO: Use real title
video_content_page(matrix_chat_page, youtube_video_page.get(), "", false, tabs[MESSAGES_TAB_INDEX].body.get(), tabs[MESSAGES_TAB_INDEX].body->get_selected_item());
redraw = true;
@@ -6688,9 +6691,10 @@ namespace QuickMedia {
return 0;
}
- void Program::download_page(const std::string &url) {
+ void Program::download_page(std::string url) {
window.setTitle("QuickMedia - Select where you want to save " + std::string(url));
+ url = invidious_url_to_youtube_url(url);
const bool download_use_youtube_dl = url_should_download_with_youtube_dl(url);
std::string filename;
std::string video_id;
diff --git a/src/plugins/Youtube.cpp b/src/plugins/Youtube.cpp
index ce1c153..be405b1 100644
--- a/src/plugins/Youtube.cpp
+++ b/src/plugins/Youtube.cpp
@@ -19,6 +19,30 @@ extern "C" {
namespace QuickMedia {
static const char *youtube_client_version = "x-youtube-client-version: 2.20210622.10.00";
+ static const std::array<std::string, 10> invidious_urls = {
+ "yewtu.be",
+ "invidious.snopyta.org",
+ "invidious.kavin.rocks",
+ "vid.puffyan.us",
+ "invidious.exonip.de",
+ "ytprivate.com",
+ "invidious.silkky.cloud",
+ "invidious-us.kavin.rocks",
+ "inv.riverside.rocks",
+ "y.com.cm"
+ };
+
+ std::string invidious_url_to_youtube_url(const std::string &url) {
+ std::string result = url;
+ for(const std::string &invidious_url : invidious_urls) {
+ const size_t index = url.find(invidious_url);
+ if(index != std::string::npos) {
+ result.replace(index, invidious_url.size(), "youtube.com");
+ break;
+ }
+ }
+ return result;
+ }
bool youtube_url_extract_id(const std::string &youtube_url, std::string &youtube_video_id) {
size_t index = youtube_url.find("youtube.com/watch?v=");
@@ -2033,6 +2057,7 @@ namespace QuickMedia {
}
void YoutubeVideoPage::set_url(std::string new_url) {
+ new_url = invidious_url_to_youtube_url(new_url);
youtube_url_remove_timestamp(new_url, timestamp);
VideoPage::set_url(std::move(new_url));
}
@@ -2226,7 +2251,7 @@ namespace QuickMedia {
if(chosen_audio_format->base.mime_type.find("mp4") != std::string::npos)
ext = ".m4a";
else if(chosen_audio_format->base.mime_type.find("webm") != std::string::npos)
- ext = ".webm";
+ ext = ".opus"; // TODO: Detect if vorbis (.ogg) or opus (.opus)
else if(chosen_audio_format->base.mime_type.find("opus") != std::string::npos)
ext = ".opus";