aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/plugins/Youtube.cpp45
1 files changed, 40 insertions, 5 deletions
diff --git a/src/plugins/Youtube.cpp b/src/plugins/Youtube.cpp
index f8e39cf..e7ff38f 100644
--- a/src/plugins/Youtube.cpp
+++ b/src/plugins/Youtube.cpp
@@ -2378,7 +2378,12 @@ namespace QuickMedia {
return PluginResult::ERR;
}
- std::string request_data[2] = {
+ // The first one works for copyrighted videos and regular videos but only if they can be embedded.
+ // The second one works for age restricted videos and regular videos but only if they can be embedded. It doesn't work for copyrighted videos.
+ // The third one works for all non-copyrighted, non-age restricted videos, embeddable or not.
+
+ const int num_request_types = 3;
+ std::string request_data[num_request_types] = {
R"END(
{
"context": {
@@ -2406,6 +2411,23 @@ R"END(
{
"context": {
"client": {
+ "clientName": "TVHTML5_SIMPLY_EMBEDDED_PLAYER",
+ "clientVersion": "2.0",
+ "hl": "en"
+ },
+ "thirdParty": {
+ "embedUrl": "https://youtube.com/"
+ }
+ },
+ "videoId": "%VIDEO_ID%",
+ "contentCheckOk": true,
+ "racyCheckOk": true
+}
+)END",
+R"END(
+{
+ "context": {
+ "client": {
"clientName": "ANDROID",
"clientVersion": "16.20",
"hl": "en"
@@ -2426,13 +2448,25 @@ R"END(
)END",
};
- for(int i = 0; i < 2; ++i) {
+ std::string client_names[num_request_types] = {
+ "3",
+ "85",
+ "3"
+ };
+
+ std::string client_versions[num_request_types] = {
+ "16.20",
+ "2.0",
+ "16.20"
+ };
+
+ for(int i = 0; i < num_request_types; ++i) {
string_replace_all(request_data[i], "%VIDEO_ID%", video_id);
std::vector<CommandArg> additional_args = {
{ "-H", "Content-Type: application/json" },
- { "-H", "X-YouTube-Client-Name: 3" },
- { "-H", "X-YouTube-Client-Version: 16.20" },
+ { "-H", "X-YouTube-Client-Name: " + client_names[i] },
+ { "-H", "X-YouTube-Client-Version: " + client_versions[i] },
{ "--data-raw", std::move(request_data[i]) }
};
@@ -2441,7 +2475,8 @@ R"END(
Json::Value json_root;
DownloadResult download_result = download_json(json_root, "https://www.youtube.com/youtubei/v1/player?key=" + api_key + "&gl=US&hl=en", additional_args, true);
- if(download_result != DownloadResult::OK) return download_result_to_plugin_result(download_result);
+ if(download_result != DownloadResult::OK)
+ continue;
PluginResult result = parse_video_response(json_root, title, channel_url, chapters, err_str);
if(result == PluginResult::OK) {