summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorChunkyProgrammer <78101139+ChunkyProgrammer@users.noreply.github.com>2023-04-02 16:42:46 -0400
committerChunkyProgrammer <78101139+ChunkyProgrammer@users.noreply.github.com>2023-04-02 16:42:46 -0400
commitdc929be1983708c917b052ab66e55f901f196266 (patch)
tree4427e106dcd218704f29640ce44b1883dc60be1f /src
parent5767344746fb9806e57cacb36ddc66ee2eaffd9e (diff)
parent8db2a93827a4e27a55a9095be15083ea68cdd571 (diff)
downloadinvidious-dc929be1983708c917b052ab66e55f901f196266.tar.gz
invidious-dc929be1983708c917b052ab66e55f901f196266.tar.bz2
invidious-dc929be1983708c917b052ab66e55f901f196266.zip
Merge branch 'master' into fix-shorts
Diffstat (limited to 'src')
-rw-r--r--src/invidious/channels/videos.cr4
-rw-r--r--src/invidious/frontend/watch_page.cr2
-rw-r--r--src/invidious/videos/parser.cr5
-rw-r--r--src/invidious/yt_backend/extractors.cr26
4 files changed, 34 insertions, 3 deletions
diff --git a/src/invidious/channels/videos.cr b/src/invidious/channels/videos.cr
index fc2d1044..12ed4a7d 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/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 "<p id=\"download\">#{translate(locale, "Download is disabled.")}</p>"
+ return "<p id=\"download\">#{translate(locale, "Download is disabled")}</p>"
end
return String.build(4000) do |str|
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|
diff --git a/src/invidious/yt_backend/extractors.cr b/src/invidious/yt_backend/extractors.cr
index f952e767..347d2482 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
#
@@ -772,6 +797,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