diff options
author | dec05eba <dec05eba@protonmail.com> | 2021-08-15 11:41:06 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2021-08-15 11:41:06 +0200 |
commit | de4825e548b990493b372237cbef9a790bf114c4 (patch) | |
tree | c81a7c281f14d0404cb2a5b57ca5a6f6cd967b54 /src/plugins | |
parent | 0009006c39ce4bfebc3c5260b83063c800cb4fdf (diff) |
Play popular invidious instance urls directly in qm
Replaces popular invidious instance urls with youtube.com
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/Youtube.cpp | 27 |
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"; |