aboutsummaryrefslogtreecommitdiff
path: root/src/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/Youtube.cpp27
1 files changed, 26 insertions, 1 deletions
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";