From 1aaf290814e4737142c382c148ede816ca1a5df2 Mon Sep 17 00:00:00 2001 From: shironeko Date: Thu, 29 Dec 2022 14:41:17 -0500 Subject: [PATCH 1/7] handle auto theme correctly with the manual toggle If the user used the manual toggle, they will not be able to get back to auto since it will force set to light theme. This should fix that. --- assets/js/themes.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/assets/js/themes.js b/assets/js/themes.js index 76767d5f..84a9f6d9 100644 --- a/assets/js/themes.js +++ b/assets/js/themes.js @@ -22,9 +22,11 @@ function setTheme(theme) { if (theme === THEME_DARK) { toggle_theme.children[0].className = 'icon ion-ios-sunny'; document.body.className = 'dark-theme'; - } else { + } else if (theme === THEME_LIGHT) { toggle_theme.children[0].className = 'icon ion-ios-moon'; document.body.className = 'light-theme'; + } else { + document.body.className = 'no-theme'; } } From 3492485789ae3758f551916b406ed75b3c028021 Mon Sep 17 00:00:00 2001 From: ChunkyProgrammer <78101139+ChunkyProgrammer@users.noreply.github.com> Date: Tue, 21 Mar 2023 21:24:37 -0400 Subject: [PATCH 2/7] Fix channel search --- src/invidious/yt_backend/extractors.cr | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/invidious/yt_backend/extractors.cr b/src/invidious/yt_backend/extractors.cr index b14ad7b9..090944fc 100644 --- a/src/invidious/yt_backend/extractors.cr +++ b/src/invidious/yt_backend/extractors.cr @@ -18,6 +18,7 @@ private ITEM_PARSERS = { Parsers::CategoryRendererParser, Parsers::RichItemRendererParser, Parsers::ReelItemRendererParser, + Parsers::ItemSectionRendererParser, Parsers::ContinuationItemRendererParser, } @@ -377,6 +378,30 @@ private module Parsers end end + # Parses an InnerTube itemSectionRenderer into a SearchVideo. + # Returns nil when the given object isn't a ItemSectionRenderer + # + # A itemSectionRenderer seems to be a simple wrapper for a videoRenderer, used + # by the result page for channel searches. It is located inside a continuationItems + # container.It is very similar to RichItemRendererParser + # + module ItemSectionRendererParser + def self.process(item : JSON::Any, author_fallback : AuthorFallback) + if item_contents = item.dig?("itemSectionRenderer", "contents", 0) + return self.parse(item_contents, author_fallback) + end + end + + private def self.parse(item_contents, author_fallback) + child = VideoRendererParser.process(item_contents, author_fallback) + return child + end + + def self.parser_name + return {{@type.name}} + end + end + # Parses an InnerTube richItemRenderer into a SearchVideo. # Returns nil when the given object isn't a RichItemRenderer # From f840addd930945141a6d4fdf7e7eb8376411d82d Mon Sep 17 00:00:00 2001 From: ChunkyProgrammer <78101139+ChunkyProgrammer@users.noreply.github.com> Date: Mon, 27 Mar 2023 22:10:28 -0400 Subject: [PATCH 3/7] Fix error when song title is missing from the track --- src/invidious/videos/parser.cr | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/invidious/videos/parser.cr b/src/invidious/videos/parser.cr index 608ae99d..13ee5f65 100644 --- a/src/invidious/videos/parser.cr +++ b/src/invidious/videos/parser.cr @@ -330,7 +330,10 @@ def parse_video_info(video_id : String, player_response : Hash(String, JSON::Any # Used when the video has multiple songs if song_title = music_desc.dig?("carouselLockupRenderer", "videoLockup", "compactVideoRenderer", "title") # "simpleText" for plain text / "runs" when song has a link - song = song_title["simpleText"]? || song_title.dig("runs", 0, "text") + song = song_title["simpleText"]? || song_title.dig?("runs", 0, "text") + + # some videos can have empty tracks. See: https://www.youtube.com/watch?v=eBGIQ7ZuuiU + next if !song end music_desc.dig?("carouselLockupRenderer", "infoRows").try &.as_a.each do |desc| From 1d187bcf176481c5619e275e60ac70a1bee80269 Mon Sep 17 00:00:00 2001 From: Lennart Bernhardt Date: Tue, 28 Mar 2023 10:30:52 +0200 Subject: [PATCH 4/7] fix long description overflow --- assets/css/default.css | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/assets/css/default.css b/assets/css/default.css index f8b1c9f7..fcc826d1 100644 --- a/assets/css/default.css +++ b/assets/css/default.css @@ -515,6 +515,10 @@ hr { #descexpansionbutton ~ div { overflow: hidden; + height: 8.3em; +} + +#descexpansionbutton:not(:checked) ~ div { max-height: 8.3em; } From f83f0d2561494eff915f32b4c9364e87000f60d5 Mon Sep 17 00:00:00 2001 From: Lennart Bernhardt Date: Tue, 28 Mar 2023 10:33:03 +0200 Subject: [PATCH 5/7] remove fixed height from description --- assets/css/default.css | 1 - 1 file changed, 1 deletion(-) diff --git a/assets/css/default.css b/assets/css/default.css index fcc826d1..88ec6ef1 100644 --- a/assets/css/default.css +++ b/assets/css/default.css @@ -515,7 +515,6 @@ hr { #descexpansionbutton ~ div { overflow: hidden; - height: 8.3em; } #descexpansionbutton:not(:checked) ~ div { From 0fe1b1ec19d8bf108765842dc84252fc3b394a9b Mon Sep 17 00:00:00 2001 From: Jarek Baran Date: Thu, 30 Mar 2023 12:52:03 +0200 Subject: [PATCH 6/7] download_widget: Add missing translation key --- locales/en-US.json | 1 + locales/pl.json | 1 + src/invidious/frontend/watch_page.cr | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/locales/en-US.json b/locales/en-US.json index a3c195ff..05811f27 100644 --- a/locales/en-US.json +++ b/locales/en-US.json @@ -402,6 +402,7 @@ "Movies": "Movies", "Download": "Download", "Download as: ": "Download as: ", + "Download is disabled": "Download is disabled", "%A %B %-d, %Y": "%A %B %-d, %Y", "(edited)": "(edited)", "YouTube comment permalink": "YouTube comment permalink", diff --git a/locales/pl.json b/locales/pl.json index 3ca78e43..3c713e70 100644 --- a/locales/pl.json +++ b/locales/pl.json @@ -317,6 +317,7 @@ "Movies": "Filmy", "Download": "Pobierz", "Download as: ": "Pobierz jako: ", + "Download is disabled": "Pobieranie jest wyłączone", "%A %B %-d, %Y": "%A, %-d %B %Y", "(edited)": "(edytowany)", "YouTube comment permalink": "Odnośnik bezpośredni do komentarza na YouTube", diff --git a/src/invidious/frontend/watch_page.cr b/src/invidious/frontend/watch_page.cr index a9b00860..e3214469 100644 --- a/src/invidious/frontend/watch_page.cr +++ b/src/invidious/frontend/watch_page.cr @@ -20,7 +20,7 @@ module Invidious::Frontend::WatchPage def download_widget(locale : String, video : Video, video_assets : VideoAssets) : String if CONFIG.disabled?("downloads") - return "

#{translate(locale, "Download is disabled.")}

" + return "

#{translate(locale, "Download is disabled")}

" end return String.build(4000) do |str| From e0600f455393ffcf0edd2f0c4b644fac7dba209f Mon Sep 17 00:00:00 2001 From: Emilien Devos Date: Fri, 31 Mar 2023 22:08:09 +0200 Subject: [PATCH 7/7] quick fix for channel videos page --- src/invidious/channels/videos.cr | 4 +++- src/invidious/yt_backend/extractors.cr | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/invidious/channels/videos.cr b/src/invidious/channels/videos.cr index befec03d..3d53f2ab 100644 --- a/src/invidious/channels/videos.cr +++ b/src/invidious/channels/videos.cr @@ -30,7 +30,9 @@ def produce_channel_videos_continuation(ucid, page = 1, auto_generated = nil, so "15:embedded" => { "1:embedded" => { "1:string" => object_inner_2_encoded, - "2:string" => "00000000-0000-0000-0000-000000000000", + }, + "2:embedded" => { + "1:string" => "00000000-0000-0000-0000-000000000000", }, "3:varint" => sort_by_numerical, }, diff --git a/src/invidious/yt_backend/extractors.cr b/src/invidious/yt_backend/extractors.cr index b14ad7b9..978e380d 100644 --- a/src/invidious/yt_backend/extractors.cr +++ b/src/invidious/yt_backend/extractors.cr @@ -773,6 +773,7 @@ end def extract_items(initial_data : InitialData, &block) if unpackaged_data = initial_data["contents"]?.try &.as_h elsif unpackaged_data = initial_data["response"]?.try &.as_h + elsif unpackaged_data = initial_data.dig?("onResponseReceivedActions", 1).try &.as_h elsif unpackaged_data = initial_data.dig?("onResponseReceivedActions", 0).try &.as_h else unpackaged_data = initial_data