|
|
@ -8,7 +8,7 @@ module Invidious::Routes::API::V1::Videos
|
|
|
|
region = env.params.query["region"]?
|
|
|
|
region = env.params.query["region"]?
|
|
|
|
|
|
|
|
|
|
|
|
begin
|
|
|
|
begin
|
|
|
|
video = get_video(id, PG_DB, region: region)
|
|
|
|
video = get_video(id, region: region)
|
|
|
|
rescue ex : VideoRedirect
|
|
|
|
rescue ex : VideoRedirect
|
|
|
|
env.response.headers["Location"] = env.request.resource.gsub(id, ex.video_id)
|
|
|
|
env.response.headers["Location"] = env.request.resource.gsub(id, ex.video_id)
|
|
|
|
return error_json(302, "Video is unavailable", {"videoId" => ex.video_id})
|
|
|
|
return error_json(302, "Video is unavailable", {"videoId" => ex.video_id})
|
|
|
@ -36,7 +36,7 @@ module Invidious::Routes::API::V1::Videos
|
|
|
|
# getting video info.
|
|
|
|
# getting video info.
|
|
|
|
|
|
|
|
|
|
|
|
begin
|
|
|
|
begin
|
|
|
|
video = get_video(id, PG_DB, region: region)
|
|
|
|
video = get_video(id, region: region)
|
|
|
|
rescue ex : VideoRedirect
|
|
|
|
rescue ex : VideoRedirect
|
|
|
|
env.response.headers["Location"] = env.request.resource.gsub(id, ex.video_id)
|
|
|
|
env.response.headers["Location"] = env.request.resource.gsub(id, ex.video_id)
|
|
|
|
return error_json(302, "Video is unavailable", {"videoId" => ex.video_id})
|
|
|
|
return error_json(302, "Video is unavailable", {"videoId" => ex.video_id})
|
|
|
@ -157,7 +157,7 @@ module Invidious::Routes::API::V1::Videos
|
|
|
|
region = env.params.query["region"]?
|
|
|
|
region = env.params.query["region"]?
|
|
|
|
|
|
|
|
|
|
|
|
begin
|
|
|
|
begin
|
|
|
|
video = get_video(id, PG_DB, region: region)
|
|
|
|
video = get_video(id, region: region)
|
|
|
|
rescue ex : VideoRedirect
|
|
|
|
rescue ex : VideoRedirect
|
|
|
|
env.response.headers["Location"] = env.request.resource.gsub(id, ex.video_id)
|
|
|
|
env.response.headers["Location"] = env.request.resource.gsub(id, ex.video_id)
|
|
|
|
return error_json(302, "Video is unavailable", {"videoId" => ex.video_id})
|
|
|
|
return error_json(302, "Video is unavailable", {"videoId" => ex.video_id})
|
|
|
@ -271,7 +271,7 @@ module Invidious::Routes::API::V1::Videos
|
|
|
|
|
|
|
|
|
|
|
|
annotations = response.body
|
|
|
|
annotations = response.body
|
|
|
|
|
|
|
|
|
|
|
|
cache_annotation(PG_DB, id, annotations)
|
|
|
|
cache_annotation(id, annotations)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
else # "youtube"
|
|
|
|
else # "youtube"
|
|
|
|
response = YT_POOL.client &.get("/annotations_invideo?video_id=#{id}")
|
|
|
|
response = YT_POOL.client &.get("/annotations_invideo?video_id=#{id}")
|
|
|
|