mirror of
https://github.com/iv-org/invidious.git
synced 2024-12-23 00:29:53 +05:30
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
|
||||||
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)
|
def storyboards(json, id, storyboards)
|
||||||
json.array do
|
json.array do
|
||||||
storyboards.each do |storyboard|
|
storyboards.each do |storyboard|
|
||||||
|
@ -14,8 +14,6 @@ module Invidious::Routes::API::Manifest
|
|||||||
|
|
||||||
begin
|
begin
|
||||||
video = get_video(id, region: region)
|
video = get_video(id, region: region)
|
||||||
rescue ex : VideoRedirect
|
|
||||||
return env.redirect env.request.resource.gsub(id, ex.video_id)
|
|
||||||
rescue ex : NotFoundException
|
rescue ex : NotFoundException
|
||||||
haltf env, status_code: 404
|
haltf env, status_code: 404
|
||||||
rescue ex
|
rescue ex
|
||||||
|
@ -9,9 +9,6 @@ module Invidious::Routes::API::V1::Videos
|
|||||||
|
|
||||||
begin
|
begin
|
||||||
video = get_video(id, region: region)
|
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
|
rescue ex : NotFoundException
|
||||||
return error_json(404, ex)
|
return error_json(404, ex)
|
||||||
rescue ex
|
rescue ex
|
||||||
@ -41,9 +38,6 @@ module Invidious::Routes::API::V1::Videos
|
|||||||
|
|
||||||
begin
|
begin
|
||||||
video = get_video(id, region: region)
|
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
|
rescue ex : NotFoundException
|
||||||
haltf env, 404
|
haltf env, 404
|
||||||
rescue ex
|
rescue ex
|
||||||
@ -168,9 +162,6 @@ module Invidious::Routes::API::V1::Videos
|
|||||||
|
|
||||||
begin
|
begin
|
||||||
video = get_video(id, region: region)
|
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
|
rescue ex : NotFoundException
|
||||||
haltf env, 404
|
haltf env, 404
|
||||||
rescue ex
|
rescue ex
|
||||||
|
@ -131,8 +131,6 @@ module Invidious::Routes::Embed
|
|||||||
|
|
||||||
begin
|
begin
|
||||||
video = get_video(id, region: params.region)
|
video = get_video(id, region: params.region)
|
||||||
rescue ex : VideoRedirect
|
|
||||||
return env.redirect env.request.resource.gsub(id, ex.video_id)
|
|
||||||
rescue ex : NotFoundException
|
rescue ex : NotFoundException
|
||||||
return error_template(404, ex)
|
return error_template(404, ex)
|
||||||
rescue ex
|
rescue ex
|
||||||
|
@ -61,8 +61,6 @@ module Invidious::Routes::Watch
|
|||||||
|
|
||||||
begin
|
begin
|
||||||
video = get_video(id, region: params.region)
|
video = get_video(id, region: params.region)
|
||||||
rescue ex : VideoRedirect
|
|
||||||
return env.redirect env.request.resource.gsub(id, ex.video_id)
|
|
||||||
rescue ex : NotFoundException
|
rescue ex : NotFoundException
|
||||||
LOGGER.error("get_video not found: #{id} : #{ex.message}")
|
LOGGER.error("get_video not found: #{id} : #{ex.message}")
|
||||||
return error_template(404, ex)
|
return error_template(404, ex)
|
||||||
|
@ -319,13 +319,6 @@ struct Video
|
|||||||
getset_bool isUpcoming
|
getset_bool isUpcoming
|
||||||
end
|
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)
|
def get_video(id, refresh = true, region = nil, force_refresh = false)
|
||||||
if (video = Invidious::Database::Videos.select(id)) && !region
|
if (video = Invidious::Database::Videos.select(id)) && !region
|
||||||
# If record was last updated over 10 minutes ago, or video has since premiered,
|
# If record was last updated over 10 minutes ago, or video has since premiered,
|
||||||
|
Loading…
Reference in New Issue
Block a user