From d2e0c0a4d819b836690d3c50ddcb3639377abc70 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Thu, 22 Jul 2021 09:20:13 +0200 Subject: Remove removed get_video_info api call until another age restricted video bypass is found. This fixes non-age restricted video playback --- src/plugins/Youtube.cpp | 49 +++++++++++++++++++++++-------------------------- 1 file changed, 23 insertions(+), 26 deletions(-) (limited to 'src/plugins/Youtube.cpp') 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 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 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 cookies = get_cookies(); - additional_args.insert(additional_args.end(), cookies.begin(), cookies.end()); + std::vector 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() { -- cgit v1.2.3