aboutsummaryrefslogtreecommitdiff
path: root/src/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/Youtube.cpp62
1 files changed, 47 insertions, 15 deletions
diff --git a/src/plugins/Youtube.cpp b/src/plugins/Youtube.cpp
index 74d0cbe..a289b65 100644
--- a/src/plugins/Youtube.cpp
+++ b/src/plugins/Youtube.cpp
@@ -2447,7 +2447,7 @@ namespace QuickMedia {
return PluginResult::ERR;
}
- std::string request_data =
+ std::string request_data[2] = {
R"END(
{
"context": {
@@ -2470,24 +2470,56 @@ R"END(
"contentCheckOk": true,
"racyCheckOk": true
}
-)END";
- string_replace_all(request_data, "%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" },
- { "--data-raw", std::move(request_data) }
+)END",
+R"END(
+{
+ "context": {
+ "client": {
+ "clientName": "ANDROID",
+ "clientVersion": "16.20",
+ "hl": "en"
+ },
+ "thirdParty": {
+ "embedUrl": "https://google.com"
+ }
+ },
+ "videoId": "%VIDEO_ID%",
+ "playbackContext": {
+ "contentPlaybackContext": {
+ "html5Preference": "HTML5_PREF_WANTS"
+ }
+ },
+ "contentCheckOk": true,
+ "racyCheckOk": true
+}
+)END",
};
- std::vector<CommandArg> cookies = get_cookies();
- additional_args.insert(additional_args.end(), cookies.begin(), cookies.end());
+ for(int i = 0; i < 2; ++i) {
+ string_replace_all(request_data[i], "%VIDEO_ID%", video_id);
- 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);
+ std::vector<CommandArg> additional_args = {
+ { "-H", "Content-Type: application/json" },
+ { "-H", "X-YouTube-Client-Name: 3" },
+ { "-H", "X-YouTube-Client-Version: 16.20" },
+ { "--data-raw", std::move(request_data[i]) }
+ };
+
+ std::vector<CommandArg> cookies = get_cookies();
+ additional_args.insert(additional_args.end(), cookies.begin(), cookies.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);
+
+ PluginResult result = parse_video_response(json_root, title, channel_url, chapters, err_str);
+ if(result == PluginResult::OK) {
+ err_str.clear();
+ return PluginResult::OK;
+ }
+ }
- return parse_video_response(json_root, title, channel_url, chapters, err_str);
+ return PluginResult::ERR;
}
void YoutubeVideoPage::mark_watched() {