Message when the video doesn't exist in playlist
This commit is contained in:
parent
4ab54f284c
commit
ca4c2115ee
|
@ -471,5 +471,6 @@
|
||||||
"crash_page_switch_instance": "tried to <a href=\"`x`\">use another instance</a>",
|
"crash_page_switch_instance": "tried to <a href=\"`x`\">use another instance</a>",
|
||||||
"crash_page_read_the_faq": "read the <a href=\"`x`\">Frequently Asked Questions (FAQ)</a>",
|
"crash_page_read_the_faq": "read the <a href=\"`x`\">Frequently Asked Questions (FAQ)</a>",
|
||||||
"crash_page_search_issue": "searched for <a href=\"`x`\">existing issues on GitHub</a>",
|
"crash_page_search_issue": "searched for <a href=\"`x`\">existing issues on GitHub</a>",
|
||||||
"crash_page_report_issue": "If none of the above helped, please <a href=\"`x`\">open a new issue on GitHub</a> (preferably in English) and include the following text in your message (do NOT translate that text):"
|
"crash_page_report_issue": "If none of the above helped, please <a href=\"`x`\">open a new issue on GitHub</a> (preferably in English) and include the following text in your message (do NOT translate that text):",
|
||||||
|
"video_not_exist_in_playlist": "The video requested doesn't exist in the playlist. Click <a href=\"`x`\">here</a> for the playlist home page."
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,11 +2,16 @@
|
||||||
|
|
||||||
module Invidious::Routes::Embed
|
module Invidious::Routes::Embed
|
||||||
def self.redirect(env)
|
def self.redirect(env)
|
||||||
|
locale = env.get("preferences").as(Preferences).locale
|
||||||
if plid = env.params.query["list"]?.try &.gsub(/[^a-zA-Z0-9_-]/, "")
|
if plid = env.params.query["list"]?.try &.gsub(/[^a-zA-Z0-9_-]/, "")
|
||||||
begin
|
begin
|
||||||
playlist = get_playlist(plid)
|
playlist = get_playlist(plid)
|
||||||
offset = env.params.query["index"]?.try &.to_i? || 0
|
offset = env.params.query["index"]?.try &.to_i? || 0
|
||||||
videos = get_playlist_videos(playlist, offset: offset)
|
videos = get_playlist_videos(playlist, offset: offset)
|
||||||
|
if videos.empty?
|
||||||
|
url = "/playlist?list=#{plid}"
|
||||||
|
raise NotFoundException.new(translate(locale, "video_not_exist_in_playlist", url))
|
||||||
|
end
|
||||||
rescue ex : NotFoundException
|
rescue ex : NotFoundException
|
||||||
return error_template(404, ex)
|
return error_template(404, ex)
|
||||||
rescue ex
|
rescue ex
|
||||||
|
@ -26,6 +31,7 @@ module Invidious::Routes::Embed
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.show(env)
|
def self.show(env)
|
||||||
|
locale = env.get("preferences").as(Preferences).locale
|
||||||
id = env.params.url["id"]
|
id = env.params.url["id"]
|
||||||
|
|
||||||
plid = env.params.query["list"]?.try &.gsub(/[^a-zA-Z0-9_-]/, "")
|
plid = env.params.query["list"]?.try &.gsub(/[^a-zA-Z0-9_-]/, "")
|
||||||
|
@ -62,6 +68,10 @@ module Invidious::Routes::Embed
|
||||||
playlist = get_playlist(plid)
|
playlist = get_playlist(plid)
|
||||||
offset = env.params.query["index"]?.try &.to_i? || 0
|
offset = env.params.query["index"]?.try &.to_i? || 0
|
||||||
videos = get_playlist_videos(playlist, offset: offset)
|
videos = get_playlist_videos(playlist, offset: offset)
|
||||||
|
if videos.empty?
|
||||||
|
url = "/playlist?list=#{plid}"
|
||||||
|
raise NotFoundException.new(translate(locale, "video_not_exist_in_playlist", url))
|
||||||
|
end
|
||||||
rescue ex : NotFoundException
|
rescue ex : NotFoundException
|
||||||
return error_template(404, ex)
|
return error_template(404, ex)
|
||||||
rescue ex
|
rescue ex
|
||||||
|
|
Loading…
Reference in a new issue