aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--TODO5
-rw-r--r--include/Json.hpp2
-rw-r--r--src/Json.cpp1
-rw-r--r--src/plugins/Youtube.cpp23
-rw-r--r--src/plugins/youtube/Signature.cpp2
5 files changed, 16 insertions, 17 deletions
diff --git a/TODO b/TODO
index 6af2d71..e847fc1 100644
--- a/TODO
+++ b/TODO
@@ -167,6 +167,5 @@ Disable drop shadow on pinephone.
Load the next page in chapter list when reaching the bottom (when going to previous chapters in image view).
Loading image background should be rounded.
//Workaround mpv issue where video is frozen after seeking (with and without cache enabled, but more often with cache enabled). This happens because of audio. Reloading audio fixes this but audio will then be gone.
-Fix youtube comments not working because of youtube update. Missing xsrf_token.
-Fix youtube copyrighted videos not working. Youtube triggers recaptcha for request to watch?v, but signature code is also broken?
-Better deal with reading from file errors. This could happen when reading a file while its being modified. See read_file_as_json. \ No newline at end of file
+Better deal with reading from file errors. This could happen when reading a file while its being modified. See read_file_as_json.
+Fix youtube comments. \ No newline at end of file
diff --git a/include/Json.hpp b/include/Json.hpp
index 9e1e706..8cbd5d4 100644
--- a/include/Json.hpp
+++ b/include/Json.hpp
@@ -1,7 +1,7 @@
#pragma once
#include "DownloadUtils.hpp"
-#include <rapidjson/document.h>
+#include <rapidjson/fwd.h>
namespace QuickMedia {
const rapidjson::Value& GetMember(const rapidjson::Value &obj, const char *key);
diff --git a/src/Json.cpp b/src/Json.cpp
index 683c4da..0593c47 100644
--- a/src/Json.cpp
+++ b/src/Json.cpp
@@ -1,4 +1,5 @@
#include "../include/Json.hpp"
+#include <rapidjson/document.h>
namespace QuickMedia {
static rapidjson::Value nullValue(rapidjson::kNullType);
diff --git a/src/plugins/Youtube.cpp b/src/plugins/Youtube.cpp
index 924bf14..5799a98 100644
--- a/src/plugins/Youtube.cpp
+++ b/src/plugins/Youtube.cpp
@@ -441,7 +441,7 @@ R"END(
std::string website_result;
std::string::iterator api_key_start;
- if(download_to_string("https://www.youtube.com", website_result, {}, true) != DownloadResult::OK)
+ if(download_to_string("https://www.youtube.com/?gl=US&hl=en", website_result, {}, true) != DownloadResult::OK)
goto fallback;
api_key_index = website_result.find("INNERTUBE_API_KEY");
@@ -523,8 +523,9 @@ R"END(
Path cookies_filepath_tmp = cookies_filepath_p;
cookies_filepath_tmp.append(".tmp");
+ // TODO: This response also contains INNERTUBE_API_KEY which is the api key above. Maybe that should be parsed?
// TODO: Is there any way to bypass this? this is needed to set VISITOR_INFO1_LIVE which is required to read comments
- const char *args[] = { "curl", "-I", "-s", "-f", "-L", "-b", cookies_filepath_tmp.data.c_str(), "-c", cookies_filepath_tmp.data.c_str(), "https://www.youtube.com/subscription_manager?disable_polymer=1", nullptr };
+ const char *args[] = { "curl", "-I", "-s", "-f", "-L", "-b", cookies_filepath_tmp.data.c_str(), "-c", cookies_filepath_tmp.data.c_str(), "https://www.youtube.com/embed/watch?v=jNQXAC9IVRw&gl=US&hl=en", nullptr };
if(exec_program(args, nullptr, nullptr) == 0) {
rename_atomic(cookies_filepath_tmp.data.c_str(), cookies_filepath_p.data.c_str());
cookies_filepath = cookies_filepath_p.data;
@@ -974,7 +975,7 @@ R"END(
next_url += url_param_encode(continuation_token);
//next_url += "&continuation=";
//next_url += url_param_encode(comments_continuation_token);
- next_url += "&type=next";
+ next_url += "&type=next&gl=US&hl=en";
std::vector<CommandArg> additional_args = {
{ "-H", "x-youtube-client-name: 1" },
@@ -1056,7 +1057,7 @@ R"END(
next_url += url_param_encode(continuation_token);
//next_url += "&continuation=";
//next_url += url_param_encode(comments_continuation_token);
- next_url += "&type=next";
+ next_url += "&type=next&gl=US&hl=en";
std::vector<CommandArg> additional_args = {
{ "-H", "x-youtube-client-name: 1" },
@@ -1135,7 +1136,7 @@ R"END(
return plugin_result_to_search_result(lazy_fetch(result_items));
std::vector<CommandArg> cookies = get_cookies();
- std::string next_url = "https://www.youtube.com/youtubei/v1/browse?key=" + url_param_encode(api_key);
+ std::string next_url = "https://www.youtube.com/youtubei/v1/browse?key=" + url_param_encode(api_key) + "&gl=US&hl=en";
Json::Value request_json(Json::objectValue);
Json::Value context_json(Json::objectValue);
@@ -1221,7 +1222,7 @@ R"END(
PluginResult YoutubeChannelPage::search_get_continuation(const std::string &url, const std::string &current_continuation_token, BodyItems &result_items) {
std::vector<CommandArg> cookies = get_cookies();
- std::string next_url = "https://www.youtube.com/youtubei/v1/browse?key=" + url_param_encode(api_key);
+ std::string next_url = "https://www.youtube.com/youtubei/v1/browse?key=" + url_param_encode(api_key) + "&gl=US&hl=en";
Json::Value request_json(Json::objectValue);
Json::Value context_json(Json::objectValue);
@@ -1843,18 +1844,16 @@ R"END(
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/next?key=" + api_key, additional_args, true);
+ DownloadResult download_result = download_json(json_root, "https://www.youtube.com/youtubei/v1/next?key=" + api_key + "&gl=US&hl=en", additional_args, true);
if(download_result != DownloadResult::OK) return result_items;
if(!json_root.isObject())
return result_items;
std::unordered_set<std::string> added_videos;
- xsrf_token.clear();
+ xsrf_token.clear(); // TODO: Get xsrf token somehow
comments_continuation_token.clear();
- // TODO: Find xsrf_token somehow. Maybe use /embed/ endpoint to find it? xsrf_token is needed for comments
-
const Json::Value &contents_json = json_root["contents"];
if(!contents_json.isObject())
return result_items;
@@ -2039,7 +2038,7 @@ R"END(
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, additional_args, true);
+ 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(!json_root.isObject())
@@ -2128,7 +2127,7 @@ R"END(
additional_args.insert(additional_args.end(), cookies.begin(), cookies.end());
std::string response;
- DownloadResult download_result = download_to_string(playback_url + "&ver=2&cpn=" + cpn, response, std::move(additional_args), true);
+ DownloadResult download_result = download_to_string(playback_url + "&ver=2&cpn=" + cpn + "&gl=US&hl=en", response, std::move(additional_args), true);
if(download_result != DownloadResult::OK) {
fprintf(stderr, "Failed to mark video as watched because http request failed\n");
return;
diff --git a/src/plugins/youtube/Signature.cpp b/src/plugins/youtube/Signature.cpp
index 7631182..65d4e2e 100644
--- a/src/plugins/youtube/Signature.cpp
+++ b/src/plugins/youtube/Signature.cpp
@@ -260,7 +260,7 @@ namespace QuickMedia {
int YoutubeSignatureDecryptor::update_decrypt_function() {
std::string response;
- DownloadResult download_result = download_to_string("https://www.youtube.com/watch?v=jNQXAC9IVRw&gl=US&hl=en", response, {}, true);
+ DownloadResult download_result = download_to_string("https://www.youtube.com/?gl=US&hl=en", response, {}, true);
if(download_result != DownloadResult::OK) {
fprintf(stderr, "YoutubeSignatureDecryptor::update_decrypt_function failed. Failed to get youtube page\n");
return U_DEC_FUN_NET_ERR;