mirror of
https://github.com/iv-org/invidious
synced 2024-11-24 03:53:27 +01:00
videos: remove unused 'VideoRedirect' exception
This commit is contained in:
parent
87a5d70062
commit
d659a451d6
18
src/invidious/jsonify/api_v1/common.cr
Normal file
18
src/invidious/jsonify/api_v1/common.cr
Normal file
@ -0,0 +1,18 @@
|
||||
require "json"
|
||||
|
||||
module Invidious::JSONify::APIv1
|
||||
extend self
|
||||
|
||||
def thumbnails(json : JSON::Builder, id : String)
|
||||
json.array do
|
||||
build_thumbnails(id).each do |thumbnail|
|
||||
json.object do
|
||||
json.field "quality", thumbnail[:name]
|
||||
json.field "url", "#{thumbnail[:host]}/vi/#{id}/#{thumbnail["url"]}.jpg"
|
||||
json.field "width", thumbnail[:width]
|
||||
json.field "height", thumbnail[:height]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -222,19 +222,6 @@ module Invidious::JSONify::APIv1
|
||||
end
|
||||
end
|
||||
|
||||
def thumbnails(json, id)
|
||||
json.array do
|
||||
build_thumbnails(id).each do |thumbnail|
|
||||
json.object do
|
||||
json.field "quality", thumbnail[:name]
|
||||
json.field "url", "#{thumbnail[:host]}/vi/#{id}/#{thumbnail["url"]}.jpg"
|
||||
json.field "width", thumbnail[:width]
|
||||
json.field "height", thumbnail[:height]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def storyboards(json, id, storyboards)
|
||||
json.array do
|
||||
storyboards.each do |storyboard|
|
||||
|
@ -14,8 +14,6 @@ module Invidious::Routes::API::Manifest
|
||||
|
||||
begin
|
||||
video = get_video(id, region: region)
|
||||
rescue ex : VideoRedirect
|
||||
return env.redirect env.request.resource.gsub(id, ex.video_id)
|
||||
rescue ex : NotFoundException
|
||||
haltf env, status_code: 404
|
||||
rescue ex
|
||||
|
@ -9,9 +9,6 @@ module Invidious::Routes::API::V1::Videos
|
||||
|
||||
begin
|
||||
video = get_video(id, region: region)
|
||||
rescue ex : VideoRedirect
|
||||
env.response.headers["Location"] = env.request.resource.gsub(id, ex.video_id)
|
||||
return error_json(302, "Video is unavailable", {"videoId" => ex.video_id})
|
||||
rescue ex : NotFoundException
|
||||
return error_json(404, ex)
|
||||
rescue ex
|
||||
@ -41,9 +38,6 @@ module Invidious::Routes::API::V1::Videos
|
||||
|
||||
begin
|
||||
video = get_video(id, region: region)
|
||||
rescue ex : VideoRedirect
|
||||
env.response.headers["Location"] = env.request.resource.gsub(id, ex.video_id)
|
||||
return error_json(302, "Video is unavailable", {"videoId" => ex.video_id})
|
||||
rescue ex : NotFoundException
|
||||
haltf env, 404
|
||||
rescue ex
|
||||
@ -168,9 +162,6 @@ module Invidious::Routes::API::V1::Videos
|
||||
|
||||
begin
|
||||
video = get_video(id, region: region)
|
||||
rescue ex : VideoRedirect
|
||||
env.response.headers["Location"] = env.request.resource.gsub(id, ex.video_id)
|
||||
return error_json(302, "Video is unavailable", {"videoId" => ex.video_id})
|
||||
rescue ex : NotFoundException
|
||||
haltf env, 404
|
||||
rescue ex
|
||||
|
@ -131,8 +131,6 @@ module Invidious::Routes::Embed
|
||||
|
||||
begin
|
||||
video = get_video(id, region: params.region)
|
||||
rescue ex : VideoRedirect
|
||||
return env.redirect env.request.resource.gsub(id, ex.video_id)
|
||||
rescue ex : NotFoundException
|
||||
return error_template(404, ex)
|
||||
rescue ex
|
||||
|
@ -61,8 +61,6 @@ module Invidious::Routes::Watch
|
||||
|
||||
begin
|
||||
video = get_video(id, region: params.region)
|
||||
rescue ex : VideoRedirect
|
||||
return env.redirect env.request.resource.gsub(id, ex.video_id)
|
||||
rescue ex : NotFoundException
|
||||
LOGGER.error("get_video not found: #{id} : #{ex.message}")
|
||||
return error_template(404, ex)
|
||||
|
@ -319,13 +319,6 @@ struct Video
|
||||
getset_bool isUpcoming
|
||||
end
|
||||
|
||||
class VideoRedirect < Exception
|
||||
property video_id : String
|
||||
|
||||
def initialize(@video_id)
|
||||
end
|
||||
end
|
||||
|
||||
def get_video(id, refresh = true, region = nil, force_refresh = false)
|
||||
if (video = Invidious::Database::Videos.select(id)) && !region
|
||||
# If record was last updated over 10 minutes ago, or video has since premiered,
|
||||
|
Loading…
Reference in New Issue
Block a user