Fix patches after upstream changes

This commit is contained in:
Sommerwiesel
2025-07-22 12:14:22 +02:00
parent 0b0b46bdc2
commit 960090a757
5 changed files with 70 additions and 45 deletions
@@ -1,15 +1,3 @@
From 04eb4c82d81a4ff183d2e94eff474136841ff1a1 Mon Sep 17 00:00:00 2001
From: Fijxu <fijxu@nadeko.net>
Date: Mon, 24 Mar 2025 19:02:01 -0300
Subject: [PATCH 01/12] feat: add resolution limit on DASH streams to save
bandwidth
---
config/config.example.toml | 1 +
src/lib/helpers/config.ts | 3 +++
src/routes/invidious_routes/dashManifest.ts | 3 ++-
3 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/config/config.example.toml b/config/config.example.toml
index 2a49d0f..d711ca0 100644
--- a/config/config.example.toml
@@ -23,32 +11,32 @@ index 2a49d0f..d711ca0 100644
# [cache]
# enabled = true # env variable: CACHE_ENABLED
diff --git a/src/lib/helpers/config.ts b/src/lib/helpers/config.ts
index 6ec7112..793265e 100644
index 6ec7112..8dcbe10 100644
--- a/src/lib/helpers/config.ts
+++ b/src/lib/helpers/config.ts
@@ -17,6 +17,9 @@ export const ConfigSchema = z.object({
@@ -17,6 +17,10 @@ export const ConfigSchema = z.object({
enable_metrics: z.boolean().default(
Deno.env.get("SERVER_ENABLE_METRICS") === "true" || false,
),
+ max_dash_resolution: z.number().default(
+ Number(Deno.env.get("SERVER_MAX_DASH_RESOLUTION")),
+ ),
+
}).strict().default({}),
cache: z.object({
enabled: z.boolean().default(
diff --git a/src/routes/invidious_routes/dashManifest.ts b/src/routes/invidious_routes/dashManifest.ts
index 059b4ed..2ebb783 100644
index 059b4ed..4e10eb8 100644
--- a/src/routes/invidious_routes/dashManifest.ts
+++ b/src/routes/invidious_routes/dashManifest.ts
@@ -55,7 +55,8 @@ dashManifest.get("/:videoId", async (c) => {
@@ -55,7 +55,9 @@ dashManifest.get("/:videoId", async (c) => {
videoInfo.streaming_data.adaptive_formats = videoInfo
.streaming_data.adaptive_formats
.filter((i) =>
- i.has_video === false || i.mime_type.includes("mp4")
+ //@ts-ignore: 'i.height' is possibly 'undefined'.
+ i.has_video === false || (i.mime_type.includes("mp4") && (i.height <= config.server.max_dash_resolution))
+
);
const player_response = videoInfo.page[0];
--
2.49.0
@@ -17,7 +17,7 @@ index 84c4f02..2112564 100644
# ump = false # env variable: NETWORKING_VIDEOPLAYBACK_UMP
# # size of chunks to request from google servers for rate limiting reductions
# video_fetch_chunk_size_mb = 5 # env variable: NETWORKING_VIDEOPLAYBACK_VIDEO_FETCH_CHUNK_SIZE_MB
+# max_proxy_retries = 2 # env variable: NETWORKING_MAX_PROXY_RETRIES
+# max_proxy_retries = 3 # env variable: NETWORKING_MAX_PROXY_RETRIES
###
# Network call timeouts when talking to YouTube.
@@ -30,7 +30,7 @@ index 3990214..01dda24 100644
),
}).strict().default({}),
+ max_proxy_retries: z.number().default(
+ Number(Deno.env.get("NETWORKING_MAX_PROXY_RETIRES") || 2),
+ Number(Deno.env.get("NETWORKING_MAX_PROXY_RETIRES") || 3),
+ ),
}).strict().default({}),
jobs: z.object({
@@ -15,3 +15,22 @@ index a24423df..d91d345e 100644
</div>
<% end %>
</div>
diff --git a/src/invidious/views/watch.ecr b/src/invidious/views/watch.ecr
index 6f9ced6f..83d01c89 100644
--- a/src/invidious/views/watch.ecr
+++ b/src/invidious/views/watch.ecr
@@ -351,14 +351,6 @@ we're going to need to do it here in order to allow for translations.
<b style="width:100%"><%= rv["author"]? %><% if rv["author_verified"]? == "true" %>&nbsp;<i class="icon ion ion-md-checkmark-circle"></i><% end %></b>
<% end %>
</div>
-
- <div class="pure-u-10-24" style="text-align:right">
- <b class="width:100%"><%=
- views = rv["view_count"]?.try &.to_i?
- views ||= rv["view_count_short"]?.try { |x| short_text_to_number(x) }
- translate_count(locale, "generic_views_count", views || 0, NumberFormatting::Short)
- %></b>
- </div>
</h5>
</div>
@@ -22,7 +22,7 @@ index 94103c29..f9488972 100644
"next_steps_error_message_go_to_youtube": "انتقل إلى يوتيوب",
"search_filters_duration_option_short": "قصير (< 4 دقائق)",
diff --git a/locales/bg.json b/locales/bg.json
index 5c99d98f..b6e5f55d 100644
index 5c99d98f..de3a5d89 100644
--- a/locales/bg.json
+++ b/locales/bg.json
@@ -454,7 +454,17 @@
@@ -45,7 +45,7 @@ index 5c99d98f..b6e5f55d 100644
"Standard YouTube license": "Стандартен YouTube лиценз",
"Text CAPTCHA": "Текст CAPTCHA",
diff --git a/locales/ca.json b/locales/ca.json
index 474d6a3c..bfa8ce96 100644
index 474d6a3c..8a7bc150 100644
--- a/locales/ca.json
+++ b/locales/ca.json
@@ -156,7 +156,17 @@
@@ -91,7 +91,7 @@ index 41f3db5c..4508b40c 100644
"download_subtitles": "Titulky - `x` (.vtt)",
"%A %B %-d, %Y": "%A %B %-d, %Y",
diff --git a/locales/da.json b/locales/da.json
index 9cbb446a..c6e042a5 100644
index 9cbb446a..5565fcb5 100644
--- a/locales/da.json
+++ b/locales/da.json
@@ -337,7 +337,17 @@
@@ -114,7 +114,7 @@ index 9cbb446a..c6e042a5 100644
"Thai": "Thai",
"No such user": "Brugeren findes ikke",
diff --git a/locales/de.json b/locales/de.json
index e51d40b9..5df3a026 100644
index e51d40b9..65c11e87 100644
--- a/locales/de.json
+++ b/locales/de.json
@@ -349,7 +349,17 @@
@@ -160,7 +160,7 @@ index e5a89a44..8c9232a6 100644
"footer_donate_page": "Δωρεά",
"footer_original_source_code": "Πρωτότυπος πηγαίος κώδικας",
diff --git a/locales/en-US.json b/locales/en-US.json
index 3f42a509..313b0f99 100644
index 0b752d93..a388dab6 100644
--- a/locales/en-US.json
+++ b/locales/en-US.json
@@ -459,7 +459,17 @@
@@ -183,7 +183,7 @@ index 3f42a509..313b0f99 100644
"next_steps_error_message_go_to_youtube": "Go to YouTube",
"footer_donate_page": "Donate",
diff --git a/locales/eo.json b/locales/eo.json
index 7276c890..dafd8a25 100644
index 7276c890..d2b77e86 100644
--- a/locales/eo.json
+++ b/locales/eo.json
@@ -347,7 +347,17 @@
@@ -206,7 +206,7 @@ index 7276c890..dafd8a25 100644
"next_steps_error_message_go_to_youtube": "Iri al JuTubo",
"search_filters_duration_option_long": "Longa (> 20 minutos)",
diff --git a/locales/es.json b/locales/es.json
index 46217943..6bbb2f99 100644
index 46217943..da56b6a2 100644
--- a/locales/es.json
+++ b/locales/es.json
@@ -347,7 +347,17 @@
@@ -298,7 +298,7 @@ index 13fef6de..0ab6f4e0 100644
"next_steps_error_message_go_to_youtube": "Siirry YouTubeen",
"generic_count_hours": "{{count}} tunti",
diff --git a/locales/fr.json b/locales/fr.json
index 49aa09df..3d83e42b 100644
index 49aa09df..c729462b 100644
--- a/locales/fr.json
+++ b/locales/fr.json
@@ -405,7 +405,17 @@
@@ -436,7 +436,7 @@ index 28cacf31..7024bafe 100644
"download_subtitles": "Skjátextar - `x` (.vtt)",
"user_created_playlists": "`x` útbjó spilunarlista",
diff --git a/locales/it.json b/locales/it.json
index c7143ef6..18720ede 100644
index c7143ef6..d0304b41 100644
--- a/locales/it.json
+++ b/locales/it.json
@@ -420,7 +420,17 @@
@@ -528,7 +528,7 @@ index 740be7b6..6cc5049d 100644
"next_steps_error_message_go_to_youtube": "Eiti į YouTube",
"search_filters_duration_option_short": "Trumpas (< 4 minučių)",
diff --git a/locales/nb-NO.json b/locales/nb-NO.json
index 38402fed..0bb4955d 100644
index 38402fed..e5cc001b 100644
--- a/locales/nb-NO.json
+++ b/locales/nb-NO.json
@@ -347,7 +347,17 @@
@@ -551,7 +551,7 @@ index 38402fed..0bb4955d 100644
"next_steps_error_message_go_to_youtube": "Gå til YouTube",
"search_filters_duration_option_long": "Lang (> 20 minutter)",
diff --git a/locales/nl.json b/locales/nl.json
index e9ce7674..61cb8376 100644
index e9ce7674..9be8382c 100644
--- a/locales/nl.json
+++ b/locales/nl.json
@@ -357,7 +357,17 @@
@@ -597,7 +597,7 @@ index d78b7a95..e8f0850a 100644
"next_steps_error_message_go_to_youtube": "Przejdź do YouTube",
"invidious": "Invidious",
diff --git a/locales/pt-BR.json b/locales/pt-BR.json
index 1eb3c989..0c70f534 100644
index 1eb3c989..560595e4 100644
--- a/locales/pt-BR.json
+++ b/locales/pt-BR.json
@@ -371,7 +371,17 @@
@@ -620,7 +620,7 @@ index 1eb3c989..0c70f534 100644
"next_steps_error_message_go_to_youtube": "Ir para o YouTube",
"footer_donate_page": "Doar",
diff --git a/locales/pt-PT.json b/locales/pt-PT.json
index 449bde77..458f661f 100644
index 449bde77..c2ceed40 100644
--- a/locales/pt-PT.json
+++ b/locales/pt-PT.json
@@ -371,7 +371,17 @@
@@ -643,7 +643,7 @@ index 449bde77..458f661f 100644
"next_steps_error_message_go_to_youtube": "Ir para o YouTube",
"search_filters_title": "Filtro",
diff --git a/locales/pt.json b/locales/pt.json
index 6438e15.f9fd79a4 100644
index 6438e15b..e9ff5533 100644
--- a/locales/pt.json
+++ b/locales/pt.json
@@ -14,7 +14,17 @@
@@ -689,7 +689,7 @@ index ccbeef63..022206f0 100644
"search_filters_features_option_location": "locație",
"search_filters_sort_label": "Sortați după",
diff --git a/locales/ru.json b/locales/ru.json
index 906f00fc..f01e0398 100644
index 906f00fc..5f64c0a6 100644
--- a/locales/ru.json
+++ b/locales/ru.json
@@ -348,7 +348,17 @@
@@ -804,7 +804,7 @@ index e6ab0f35..7d380141 100644
"footer_documentation": "Документација",
"footer_modfied_source_code": "Измењени изворни кôд",
diff --git a/locales/sv-SE.json b/locales/sv-SE.json
index 8f050d98..6481e160 100644
index 8f050d98..db724bf7 100644
--- a/locales/sv-SE.json
+++ b/locales/sv-SE.json
@@ -478,7 +478,17 @@
@@ -873,7 +873,7 @@ index cf3f8987..28a8e4ee 100644
"next_steps_error_message_go_to_youtube": "YouTube'a Git",
"search_filters_duration_option_short": "Kısa (4 Dakikadan Az)",
diff --git a/locales/uk.json b/locales/uk.json
index b99923e2..5cea14d1 100644
index b99923e2..2794da93 100644
--- a/locales/uk.json
+++ b/locales/uk.json
@@ -397,7 +397,17 @@
@@ -919,7 +919,7 @@ index 9c4a5a15..241dd123 100644
"search_filters_duration_option_medium": "Trung bình (4 - 20 phút)",
"generic_count_seconds_0": "{{count}} giây",
diff --git a/locales/zh-CN.json b/locales/zh-CN.json
index f3bc660.5909d150 100644
index f3bc660b..5909d150 100644
--- a/locales/zh-CN.json
+++ b/locales/zh-CN.json
@@ -363,7 +363,17 @@
@@ -965,17 +965,35 @@ index 77805349..7d278762 100644
"next_steps_error_message_go_to_youtube": "到 YouTube",
"search_filters_duration_option_short": "短(小於4分鐘)",
diff --git a/src/invidious/helpers/errors.cr b/src/invidious/helpers/errors.cr
index e2c4b650..4ca7bbeb 100644
index e2c4b650..f0e93de2 100644
--- a/src/invidious/helpers/errors.cr
+++ b/src/invidious/helpers/errors.cr
@@ -89,15 +89,37 @@ def error_template_helper(env : HTTP::Server::Context, status_code : Int32, exce
@@ -89,15 +89,55 @@ def error_template_helper(env : HTTP::Server::Context, status_code : Int32, exce
return templated "error"
end
+def remove_duplicate_phrases(text : String) : String
+ phrases = text.split(/ *[:.] */)
+ unique_phrases = phrases.uniq
+ return unique_phrases.join(" ")
+ html_tag_regex = /<[^>]+>/
+
+ # Scan text und erhalte alle HTML-Tags und Nicht-Tags als Array von MatchData
+ matches = text.scan(/#{html_tag_regex}|[^<]+/)
+
+ # Konvertiere MatchData zu Strings
+ parts = matches.map(&.to_s)
+
+ processed_parts = parts.map do |part|
+ if part.match(html_tag_regex)
+ # HTML-Tag, unverändert lassen
+ part
+ else
+ # Normaler Text: nach Satztrennern splitten und Duplikate entfernen
+ phrases = part.split(/ *[:.] */)
+ unique_phrases = phrases.uniq
+ unique_phrases.join(" ")
+ end
+ end
+
+ return processed_parts.join
+end
+
def error_template_helper(env : HTTP::Server::Context, status_code : Int32, message : String)
@@ -1008,7 +1026,7 @@ index e2c4b650..4ca7bbeb 100644
return templated "error"
end
@@ -187,24 +209,60 @@ def error_redirect_helper(env : HTTP::Server::Context)
@@ -187,24 +227,60 @@ def error_redirect_helper(env : HTTP::Server::Context)
if request_path.starts_with?("/search") || request_path.starts_with?("/watch") ||
request_path.starts_with?("/channel") || request_path.starts_with?("/playlist?list=PL")
next_steps_text = translate(locale, "next_steps_error_message")
+1 -1
View File
@@ -9,7 +9,7 @@ index 8f5aa61d..f97a8732 100644
- raise InfoException.new("Error: non 200 status code. Youtube API returned \
- status code #{response.status_code}. See <a href=\"https://docs.invidious.io/youtube-errors-explained/\"> \
- https://docs.invidious.io/youtube-errors-explained/</a> for troubleshooting.")
+ raise InfoException.new("<h2>Error loading video</h2><p style='font-size: 0.8em; margin: -20px 0 20px 0;'>Received error from YouTube: #{response.status_code}</p>")
+ raise InfoException.new("<h2>YouTube API error</h2><p style='font-size: 0.8em; margin: -20px 0 20px 0;'>YouTube error code: #{response.status_code}</p>")
end
self._decompress(response.body_io, response.headers["Content-Encoding"]?)
end