diff options
author | dec05eba <dec05eba@protonmail.com> | 2021-07-22 09:20:13 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2021-07-22 09:20:13 +0200 |
commit | d2e0c0a4d819b836690d3c50ddcb3639377abc70 (patch) | |
tree | 9c30ab3f04320c9926964e75b09fc6fd0b8b9156 /src | |
parent | a76dabb12734154177a78033324b40365e7c6f21 (diff) |
Remove removed get_video_info api call until another age restricted video bypass is found. This fixes non-age restricted video playback
Diffstat (limited to 'src')
-rw-r--r-- | src/plugins/Youtube.cpp | 49 |
1 files changed, 23 insertions, 26 deletions
diff --git a/src/plugins/Youtube.cpp b/src/plugins/Youtube.cpp index cd3fddd..167b201 100644 --- a/src/plugins/Youtube.cpp +++ b/src/plugins/Youtube.cpp @@ -2307,6 +2307,15 @@ R"END( if(!json_root.isObject()) return PluginResult::ERR; + const Json::Value &playability_status_json = json_root["playabilityStatus"]; + if(playability_status_json.isObject()) { + const Json::Value &status_json = playability_status_json["status"]; + if(status_json.isString() && (strcmp(status_json.asCString(), "UNPLAYABLE") == 0 || strcmp(status_json.asCString(), "LOGIN_REQUIRED") == 0)) { + const Json::Value &reason_json = playability_status_json["reason"]; + fprintf(stderr, "Unable to play video, status: %s, reason: %s\n", status_json.asCString(), reason_json.isString() ? reason_json.asCString() : "Unknown"); + } + } + const Json::Value *streaming_data_json = &json_root["streamingData"]; if(!streaming_data_json->isObject()) return PluginResult::ERR; @@ -2400,36 +2409,24 @@ R"END( return PluginResult::ERR; } - Json::Value json_root; - PluginResult result = get_video_info(video_id, json_root); - if(result != PluginResult::OK) - return result; - - // Getting streams might fail for some videos that do not allow videos to be embedded when using get_video_info endpoint. - // TODO: Does that means for videos that do not allow to be embedded and are age restricted wont work? - result = parse_video_response(json_root, title, channel_url, chapters); - if(result == PluginResult::OK) { - return PluginResult::OK; - } else { - std::string request_data = key_api_request_data; - string_replace_all(request_data, "%VIDEO_ID%", video_id); + std::string request_data = key_api_request_data; + string_replace_all(request_data, "%VIDEO_ID%", video_id); - std::vector<CommandArg> additional_args = { - { "-H", "Content-Type: application/json" }, - { "-H", "x-youtube-client-name: 1" }, - { "-H", youtube_client_version }, - { "--data-raw", std::move(request_data) } - }; + std::vector<CommandArg> additional_args = { + { "-H", "Content-Type: application/json" }, + { "-H", "x-youtube-client-name: 1" }, + { "-H", youtube_client_version }, + { "--data-raw", std::move(request_data) } + }; - std::vector<CommandArg> cookies = get_cookies(); - additional_args.insert(additional_args.end(), cookies.begin(), cookies.end()); + 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); + 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); - return parse_video_response(json_root, title, channel_url, chapters); - } + return parse_video_response(json_root, title, channel_url, chapters); } void YoutubeVideoPage::mark_watched() { |