diff options
author | dec05eba <dec05eba@protonmail.com> | 2020-09-12 17:08:49 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2020-09-12 17:08:49 +0200 |
commit | 25db36afb97fa9be2ec61cc992586a483a9f6613 (patch) | |
tree | 31190186d5dd80bea43de8146b051a10c6e69e22 | |
parent | 7dbb67cbae3fa2008c0d324fcaacbcf5d82f71a8 (diff) |
Improve related videos search by using cookies. Age restricted videos dont show up unless you use cookies?
-rw-r--r-- | src/plugins/Youtube.cpp | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/src/plugins/Youtube.cpp b/src/plugins/Youtube.cpp index ce7af0e..46128ec 100644 --- a/src/plugins/Youtube.cpp +++ b/src/plugins/Youtube.cpp @@ -91,8 +91,8 @@ namespace QuickMedia { { "-H", "referer: " + url } }; - /*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()); std::string website_data; if(download_to_string(url + "?pbj=1", website_data, additional_args, use_tor, true) != DownloadResult::OK) @@ -285,8 +285,8 @@ namespace QuickMedia { { "-H", "referer: " + url } }; - /*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()); std::string website_data; if(download_to_string(url + "&pbj=1", website_data, additional_args, use_tor, true) != DownloadResult::OK) @@ -365,8 +365,8 @@ namespace QuickMedia { { "-H", "referer: " + url } }; - /*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()); std::string website_data; if(download_to_string(next_url, website_data, additional_args, use_tor, true) != DownloadResult::OK) @@ -409,6 +409,9 @@ namespace QuickMedia { } std::vector<CommandArg> Youtube::get_cookies() const { + if(use_tor) + return {}; + Path cookies_filepath; if(get_cookies_filepath(cookies_filepath, name) != 0) { fprintf(stderr, "Warning: Failed to create youtube cookies file\n"); @@ -477,8 +480,8 @@ namespace QuickMedia { { "-H", "referer: " + url } }; - /*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()); std::string website_data; if(download_to_string(modified_url + "&pbj=1", website_data, additional_args, use_tor, true) != DownloadResult::OK) @@ -546,10 +549,6 @@ namespace QuickMedia { if(!content_item_json.isObject()) continue; - const Json::Value &compact_video_renderer_json = content_item_json["compactVideoRenderer"]; - if(!compact_video_renderer_json.isObject()) - continue; - auto body_item = parse_compact_video_renderer_json(content_item_json, added_videos); if(body_item) result_items.push_back(std::move(body_item)); |