mirror of
https://git.nerdvpn.de/NerdVPN.de/invidious
synced 2026-02-14 22:51:42 +01:00
apply patch PR 4789 instead
This commit is contained in:
@@ -0,0 +1,185 @@
|
||||
From 9e11d59af407c9666d53a78706e2a5f031c4315e Mon Sep 17 00:00:00 2001
|
||||
From: Emilien Devos <4016501+unixfox@users.noreply.github.com>
|
||||
Date: Thu, 11 Jul 2024 23:19:20 +0200
|
||||
Subject: [PATCH 1/3] Add ability to set po_token and visitordata ID
|
||||
|
||||
---
|
||||
config/config.example.yml | 10 ++++++++++
|
||||
src/invidious/config.cr | 5 +++++
|
||||
src/invidious/yt_backend/youtube_api.cr | 11 +++++++++++
|
||||
3 files changed, 26 insertions(+)
|
||||
|
||||
diff --git a/config/config.example.yml b/config/config.example.yml
|
||||
index 38085a20b..41a57e00b 100644
|
||||
--- a/config/config.example.yml
|
||||
+++ b/config/config.example.yml
|
||||
@@ -173,6 +173,16 @@ https_only: false
|
||||
##
|
||||
# use_innertube_for_captions: false
|
||||
|
||||
+##
|
||||
+## Send Google session informations. This gives more identifiable information to Google.
|
||||
+##
|
||||
+## Useful when Invidious is blocked by the message "This helps protect our community." See https://github.com/iv-org/invidious/issues/4734
|
||||
+##
|
||||
+## Accepted values: true, false
|
||||
+## Default: false
|
||||
+##
|
||||
+# po_token: XXX
|
||||
+# visitor_data: XXX
|
||||
|
||||
# -----------------------------
|
||||
# Logging
|
||||
diff --git a/src/invidious/config.cr b/src/invidious/config.cr
|
||||
index 09c2168b8..5340d4f5a 100644
|
||||
--- a/src/invidious/config.cr
|
||||
+++ b/src/invidious/config.cr
|
||||
@@ -130,6 +130,11 @@ class Config
|
||||
# Use Innertube's transcripts API instead of timedtext for closed captions
|
||||
property use_innertube_for_captions : Bool = false
|
||||
|
||||
+ # visitor data ID for Google session
|
||||
+ property visitor_data : String? = nil
|
||||
+ # poToken for passing bot attestation
|
||||
+ property po_token : String? = nil
|
||||
+
|
||||
# Saved cookies in "name1=value1; name2=value2..." format
|
||||
@[YAML::Field(converter: Preferences::StringToCookies)]
|
||||
property cookies : HTTP::Cookies = HTTP::Cookies.new
|
||||
diff --git a/src/invidious/yt_backend/youtube_api.cr b/src/invidious/yt_backend/youtube_api.cr
|
||||
index 727ce9a37..f8470e8ae 100644
|
||||
--- a/src/invidious/yt_backend/youtube_api.cr
|
||||
+++ b/src/invidious/yt_backend/youtube_api.cr
|
||||
@@ -341,6 +341,10 @@ module YoutubeAPI
|
||||
client_context["client"]["platform"] = platform
|
||||
end
|
||||
|
||||
+ if CONFIG.visitor_data.is_a?(String)
|
||||
+ client_context["client"]["visitorData"] = CONFIG.visitor_data.as(String)
|
||||
+ end
|
||||
+
|
||||
return client_context
|
||||
end
|
||||
|
||||
@@ -488,6 +492,9 @@ module YoutubeAPI
|
||||
"html5Preference": "HTML5_PREF_WANTS",
|
||||
},
|
||||
},
|
||||
+ "serviceIntegrityDimensions" => {
|
||||
+ "poToken" => CONFIG.po_token ? CONFIG.po_token.as(String) : nil,
|
||||
+ },
|
||||
}
|
||||
|
||||
# Append the additional parameters if those were provided
|
||||
@@ -620,6 +627,10 @@ module YoutubeAPI
|
||||
headers["User-Agent"] = user_agent
|
||||
end
|
||||
|
||||
+ if CONFIG.visitor_data.is_a?(String)
|
||||
+ headers["X-Goog-Visitor-Id"] = CONFIG.visitor_data.as(String)
|
||||
+ end
|
||||
+
|
||||
# Logging
|
||||
LOGGER.debug("YoutubeAPI: Using endpoint: \"#{endpoint}\"")
|
||||
LOGGER.trace("YoutubeAPI: ClientConfig: #{client_config}")
|
||||
|
||||
From a24a3a608ecaf0b55a58afdea0d8c6437f4d5da7 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?=C3=89milien=20=28perso=29?=
|
||||
<4016501+unixfox@users.noreply.github.com>
|
||||
Date: Fri, 19 Jul 2024 22:47:30 +0200
|
||||
Subject: [PATCH 2/3] Better wording for the comments in config.yaml
|
||||
|
||||
Co-authored-by: Samantaz Fox <coding@samantaz.fr>
|
||||
---
|
||||
config/config.example.yml | 14 ++++++++------
|
||||
1 file changed, 8 insertions(+), 6 deletions(-)
|
||||
|
||||
diff --git a/config/config.example.yml b/config/config.example.yml
|
||||
index 41a57e00b..f666405e3 100644
|
||||
--- a/config/config.example.yml
|
||||
+++ b/config/config.example.yml
|
||||
@@ -174,15 +174,17 @@ https_only: false
|
||||
# use_innertube_for_captions: false
|
||||
|
||||
##
|
||||
-## Send Google session informations. This gives more identifiable information to Google.
|
||||
+## Send Google session informations. This is useful when Invidious is blocked
|
||||
+## by the message "This helps protect our community."
|
||||
+## See https://github.com/iv-org/invidious/issues/4734.
|
||||
##
|
||||
-## Useful when Invidious is blocked by the message "This helps protect our community." See https://github.com/iv-org/invidious/issues/4734
|
||||
+## Warning: These strings gives much more identifiable information to Google!
|
||||
##
|
||||
-## Accepted values: true, false
|
||||
-## Default: false
|
||||
+## Accepted values: String
|
||||
+## Default: <none>
|
||||
##
|
||||
-# po_token: XXX
|
||||
-# visitor_data: XXX
|
||||
+# po_token: ""
|
||||
+# visitor_data: ""
|
||||
|
||||
# -----------------------------
|
||||
# Logging
|
||||
|
||||
From 991c8ddfdbd2899ec79c140e0596d7cad9c0a583 Mon Sep 17 00:00:00 2001
|
||||
From: Emilien Devos <4016501+unixfox@users.noreply.github.com>
|
||||
Date: Sat, 20 Jul 2024 13:24:01 +0200
|
||||
Subject: [PATCH 3/3] remove ternary + use web client if po_token if not let
|
||||
android client
|
||||
|
||||
---
|
||||
src/invidious/videos/parser.cr | 11 ++++++++---
|
||||
src/invidious/yt_backend/youtube_api.cr | 2 +-
|
||||
2 files changed, 9 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/src/invidious/videos/parser.cr b/src/invidious/videos/parser.cr
|
||||
index 0e1a947cc..506e9e1e9 100644
|
||||
--- a/src/invidious/videos/parser.cr
|
||||
+++ b/src/invidious/videos/parser.cr
|
||||
@@ -55,7 +55,7 @@ def extract_video_info(video_id : String)
|
||||
client_config = YoutubeAPI::ClientConfig.new
|
||||
|
||||
# Fetch data from the player endpoint
|
||||
- player_response = YoutubeAPI.player(video_id: video_id, params: "", client_config: client_config)
|
||||
+ player_response = YoutubeAPI.player(video_id: video_id, params: "2AMB", client_config: client_config)
|
||||
|
||||
playability_status = player_response.dig?("playabilityStatus", "status").try &.as_s
|
||||
|
||||
@@ -102,7 +102,9 @@ def extract_video_info(video_id : String)
|
||||
|
||||
new_player_response = nil
|
||||
|
||||
- if reason.nil?
|
||||
+ # Don't use Android client if po_token is passed because po_token doesn't
|
||||
+ # work for Android client.
|
||||
+ if reason.nil? && CONFIG.po_token.nil?
|
||||
# Fetch the video streams using an Android client in order to get the
|
||||
# decrypted URLs and maybe fix throttling issues (#2194). See the
|
||||
# following issue for an explanation about decrypted URLs:
|
||||
@@ -112,7 +114,10 @@ def extract_video_info(video_id : String)
|
||||
end
|
||||
|
||||
# Last hope
|
||||
- if new_player_response.nil?
|
||||
+ # Only trigger if reason found and po_token or didn't work wth Android client.
|
||||
+ # TvHtml5ScreenEmbed now requires sig helper for it to work but po_token is not required
|
||||
+ # if the IP address is not blocked.
|
||||
+ if CONFIG.po_token && reason || CONFIG.po_token.nil? && new_player_response.nil?
|
||||
client_config.client_type = YoutubeAPI::ClientType::TvHtml5ScreenEmbed
|
||||
new_player_response = try_fetch_streaming_data(video_id, client_config)
|
||||
end
|
||||
diff --git a/src/invidious/yt_backend/youtube_api.cr b/src/invidious/yt_backend/youtube_api.cr
|
||||
index f8470e8ae..2d3b77d2e 100644
|
||||
--- a/src/invidious/yt_backend/youtube_api.cr
|
||||
+++ b/src/invidious/yt_backend/youtube_api.cr
|
||||
@@ -493,7 +493,7 @@ module YoutubeAPI
|
||||
},
|
||||
},
|
||||
"serviceIntegrityDimensions" => {
|
||||
- "poToken" => CONFIG.po_token ? CONFIG.po_token.as(String) : nil,
|
||||
+ "poToken" => CONFIG.po_token,
|
||||
},
|
||||
}
|
||||
|
||||
@@ -1,39 +0,0 @@
|
||||
From 48a625b4a43930e98b07134c39899ea9d84e8a44 Mon Sep 17 00:00:00 2001
|
||||
From: Emilien Devos <4016501+unixfox@users.noreply.github.com>
|
||||
Date: Fri, 21 Jun 2024 23:17:22 +0200
|
||||
Subject: [PATCH 1/1] retreive potoken for bypass restrictions
|
||||
|
||||
---
|
||||
src/invidious/yt_backend/youtube_api.cr | 9 +++++++++
|
||||
1 file changed, 9 insertions(+)
|
||||
|
||||
diff --git a/src/invidious/yt_backend/youtube_api.cr b/src/invidious/yt_backend/youtube_api.cr
|
||||
index 727ce9a3..b1c2c288 100644
|
||||
--- a/src/invidious/yt_backend/youtube_api.cr
|
||||
+++ b/src/invidious/yt_backend/youtube_api.cr
|
||||
@@ -306,6 +306,12 @@ module YoutubeAPI
|
||||
} of String => String | Int64,
|
||||
}
|
||||
|
||||
+ visitor_data = REDIS_DB.get("VISITORDATA")
|
||||
+
|
||||
+ if visitor_data
|
||||
+ client_context["client"]["visitorData"] = visitor_data
|
||||
+ end
|
||||
+
|
||||
# Add some more context if it exists in the client definitions
|
||||
if !client_config.screen.empty?
|
||||
client_context["client"]["clientScreen"] = client_config.screen
|
||||
@@ -488,6 +494,9 @@ module YoutubeAPI
|
||||
"html5Preference": "HTML5_PREF_WANTS",
|
||||
},
|
||||
},
|
||||
+ "serviceIntegrityDimensions" => {
|
||||
+ "poToken": REDIS_DB.get("POTOKEN"),
|
||||
+ },
|
||||
}
|
||||
|
||||
# Append the additional parameters if those were provided
|
||||
--
|
||||
2.45.2
|
||||
|
||||
Reference in New Issue
Block a user