mirror of
https://github.com/iv-org/invidious.git
synced 2025-05-20 05:21:12 +00: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
|
json.field "errorBacktrace", @parse_exception.inspect_with_backtrace
|
||||||
end
|
end
|
||||||
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
|
end
|
||||||
|
|
||||||
class Category
|
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
|
offset = initial_data.dig?("contents", "twoColumnWatchNextResults", "playlist", "playlist", "currentIndex").try &.as_i || offset
|
||||||
end
|
end
|
||||||
|
|
||||||
videos = [] of PlaylistVideo
|
videos = [] of PlaylistVideo | ProblematicTimelineItem
|
||||||
|
|
||||||
until videos.size >= 200 || videos.size == playlist.video_count || offset >= playlist.video_count
|
until videos.size >= 200 || videos.size == playlist.video_count || offset >= playlist.video_count
|
||||||
# 100 videos per request
|
# 100 videos per request
|
||||||
@ -448,7 +448,7 @@ def get_playlist_videos(playlist : InvidiousPlaylist | Playlist, offset : Int32,
|
|||||||
end
|
end
|
||||||
|
|
||||||
def extract_playlist_videos(initial_data : Hash(String, JSON::Any))
|
def extract_playlist_videos(initial_data : Hash(String, JSON::Any))
|
||||||
videos = [] of PlaylistVideo
|
videos = [] of PlaylistVideo | ProblematicTimelineItem
|
||||||
|
|
||||||
if initial_data["contents"]?
|
if initial_data["contents"]?
|
||||||
tabs = initial_data["contents"]["twoColumnBrowseResultsRenderer"]["tabs"]
|
tabs = initial_data["contents"]["twoColumnBrowseResultsRenderer"]["tabs"]
|
||||||
@ -500,6 +500,10 @@ def extract_playlist_videos(initial_data : Hash(String, JSON::Any))
|
|||||||
index: index,
|
index: index,
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
rescue ex
|
||||||
|
videos << ProblematicTimelineItem.new(
|
||||||
|
parse_exception: ex
|
||||||
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
return videos
|
return videos
|
||||||
|
@ -12,13 +12,15 @@ module Invidious::Routes::Embed
|
|||||||
url = "/playlist?list=#{plid}"
|
url = "/playlist?list=#{plid}"
|
||||||
raise NotFoundException.new(translate(locale, "error_video_not_in_playlist", url))
|
raise NotFoundException.new(translate(locale, "error_video_not_in_playlist", url))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
get_first_video = videos[0].as(PlaylistVideo)
|
||||||
rescue ex : NotFoundException
|
rescue ex : NotFoundException
|
||||||
return error_template(404, ex)
|
return error_template(404, ex)
|
||||||
rescue ex
|
rescue ex
|
||||||
return error_template(500, ex)
|
return error_template(500, ex)
|
||||||
end
|
end
|
||||||
|
|
||||||
url = "/embed/#{videos[0].id}?#{env.params.query}"
|
url = "/embed/#{get_first_video}?#{env.params.query}"
|
||||||
|
|
||||||
if env.params.query.size > 0
|
if env.params.query.size > 0
|
||||||
url += "?#{env.params.query}"
|
url += "?#{env.params.query}"
|
||||||
@ -72,13 +74,15 @@ module Invidious::Routes::Embed
|
|||||||
url = "/playlist?list=#{plid}"
|
url = "/playlist?list=#{plid}"
|
||||||
raise NotFoundException.new(translate(locale, "error_video_not_in_playlist", url))
|
raise NotFoundException.new(translate(locale, "error_video_not_in_playlist", url))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
get_first_video = videos[0].as(PlaylistVideo)
|
||||||
rescue ex : NotFoundException
|
rescue ex : NotFoundException
|
||||||
return error_template(404, ex)
|
return error_template(404, ex)
|
||||||
rescue ex
|
rescue ex
|
||||||
return error_template(500, ex)
|
return error_template(500, ex)
|
||||||
end
|
end
|
||||||
|
|
||||||
url = "/embed/#{videos[0].id}"
|
url = "/embed/#{get_first_video.id}"
|
||||||
elsif video_series
|
elsif video_series
|
||||||
url = "/embed/#{video_series.shift}"
|
url = "/embed/#{video_series.shift}"
|
||||||
env.params.query["playlist"] = video_series.join(",")
|
env.params.query["playlist"] = video_series.join(",")
|
||||||
|
@ -296,7 +296,13 @@ module Invidious::Routes::Feeds
|
|||||||
xml.element("name") { xml.text playlist.author }
|
xml.element("name") { xml.text playlist.author }
|
||||||
end
|
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
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
|
Loading…
x
Reference in New Issue
Block a user