mirror of
https://github.com/iv-org/invidious.git
synced 2025-04-06 21:13:45 -04:00
Use ProblematicTimelineItem as needed in playlists
This commit is contained in:
parent
c288005bfd
commit
f7810ba007
@ -309,6 +309,32 @@ struct ProblematicTimelineItem
|
||||
json.field "errorBacktrace", @parse_exception.inspect_with_backtrace
|
||||
end
|
||||
end
|
||||
|
||||
# Provides compatibility with PlaylistVideo
|
||||
def to_json(json : JSON::Builder, *args, **kwargs)
|
||||
return to_json("", json)
|
||||
end
|
||||
|
||||
def to_xml(env, locale, xml : XML::Builder)
|
||||
xml.element("entry") do
|
||||
xml.element("id") { xml.text "iv-err-#{Random.new.base64(8)}" }
|
||||
xml.element("title") { xml.text "Parse Error: This item has failed to parse" }
|
||||
xml.element("updated") { xml.text Time.utc.to_rfc3339 }
|
||||
|
||||
xml.element("content", type: "xhtml") do
|
||||
xml.element("div", xmlns: "http://www.w3.org/1999/xhtml") do
|
||||
xml.element("div") do
|
||||
xml.element("h4") { translate(locale, "timeline_parse_error_placeholder_heading") }
|
||||
xml.element("p") { translate(locale, "timeline_parse_error_placeholder_message") }
|
||||
end
|
||||
|
||||
xml.element("pre") do
|
||||
get_issue_template(env, @parse_exception)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
class Category
|
||||
|
@ -432,7 +432,7 @@ def get_playlist_videos(playlist : InvidiousPlaylist | Playlist, offset : Int32,
|
||||
offset = initial_data.dig?("contents", "twoColumnWatchNextResults", "playlist", "playlist", "currentIndex").try &.as_i || offset
|
||||
end
|
||||
|
||||
videos = [] of PlaylistVideo
|
||||
videos = [] of PlaylistVideo | ProblematicTimelineItem
|
||||
|
||||
until videos.size >= 200 || videos.size == playlist.video_count || offset >= playlist.video_count
|
||||
# 100 videos per request
|
||||
@ -448,7 +448,7 @@ def get_playlist_videos(playlist : InvidiousPlaylist | Playlist, offset : Int32,
|
||||
end
|
||||
|
||||
def extract_playlist_videos(initial_data : Hash(String, JSON::Any))
|
||||
videos = [] of PlaylistVideo
|
||||
videos = [] of PlaylistVideo | ProblematicTimelineItem
|
||||
|
||||
if initial_data["contents"]?
|
||||
tabs = initial_data["contents"]["twoColumnBrowseResultsRenderer"]["tabs"]
|
||||
@ -500,6 +500,10 @@ def extract_playlist_videos(initial_data : Hash(String, JSON::Any))
|
||||
index: index,
|
||||
})
|
||||
end
|
||||
rescue ex
|
||||
videos << ProblematicTimelineItem.new(
|
||||
parse_exception: ex
|
||||
)
|
||||
end
|
||||
|
||||
return videos
|
||||
|
@ -12,13 +12,15 @@ module Invidious::Routes::Embed
|
||||
url = "/playlist?list=#{plid}"
|
||||
raise NotFoundException.new(translate(locale, "error_video_not_in_playlist", url))
|
||||
end
|
||||
|
||||
get_first_video = videos[0].as(PlaylistVideo)
|
||||
rescue ex : NotFoundException
|
||||
return error_template(404, ex)
|
||||
rescue ex
|
||||
return error_template(500, ex)
|
||||
end
|
||||
|
||||
url = "/embed/#{videos[0].id}?#{env.params.query}"
|
||||
url = "/embed/#{get_first_video}?#{env.params.query}"
|
||||
|
||||
if env.params.query.size > 0
|
||||
url += "?#{env.params.query}"
|
||||
@ -72,13 +74,15 @@ module Invidious::Routes::Embed
|
||||
url = "/playlist?list=#{plid}"
|
||||
raise NotFoundException.new(translate(locale, "error_video_not_in_playlist", url))
|
||||
end
|
||||
|
||||
get_first_video = videos[0].as(PlaylistVideo)
|
||||
rescue ex : NotFoundException
|
||||
return error_template(404, ex)
|
||||
rescue ex
|
||||
return error_template(500, ex)
|
||||
end
|
||||
|
||||
url = "/embed/#{videos[0].id}"
|
||||
url = "/embed/#{get_first_video.id}"
|
||||
elsif video_series
|
||||
url = "/embed/#{video_series.shift}"
|
||||
env.params.query["playlist"] = video_series.join(",")
|
||||
|
@ -296,7 +296,13 @@ module Invidious::Routes::Feeds
|
||||
xml.element("name") { xml.text playlist.author }
|
||||
end
|
||||
|
||||
videos.each &.to_xml(xml)
|
||||
videos.each do |video|
|
||||
if video.is_a? PlaylistVideo
|
||||
video.to_xml(xml)
|
||||
else
|
||||
video.to_xml(env, locale, xml)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
else
|
||||
|
Loading…
x
Reference in New Issue
Block a user