mirror of
https://github.com/iv-org/invidious.git
synced 2024-12-25 17:49:49 +05:30
Clean useless database arguments (4/5)
This commit is contained in:
parent
40ed4a0506
commit
d74873fed1
@ -793,7 +793,7 @@ post "/data_control" do |env|
|
||||
next if !video_id
|
||||
|
||||
begin
|
||||
video = get_video(video_id, PG_DB)
|
||||
video = get_video(video_id)
|
||||
rescue ex
|
||||
next
|
||||
end
|
||||
|
@ -60,7 +60,7 @@ def html_to_content(description_html : String)
|
||||
return description
|
||||
end
|
||||
|
||||
def cache_annotation(db, id, annotations)
|
||||
def cache_annotation(id, annotations)
|
||||
if !CONFIG.cache_annotations
|
||||
return
|
||||
end
|
||||
@ -99,7 +99,7 @@ def create_notification_stream(env, topics, connection_channel)
|
||||
published = Time.utc - Time::Span.new(days: time_span[0], hours: time_span[1], minutes: time_span[2], seconds: time_span[3])
|
||||
video_id = TEST_IDS[rand(TEST_IDS.size)]
|
||||
|
||||
video = get_video(video_id, PG_DB)
|
||||
video = get_video(video_id)
|
||||
video.published = published
|
||||
response = JSON.parse(video.to_json(locale, nil))
|
||||
|
||||
@ -176,7 +176,7 @@ def create_notification_stream(env, topics, connection_channel)
|
||||
next
|
||||
end
|
||||
|
||||
video = get_video(video_id, PG_DB)
|
||||
video = get_video(video_id)
|
||||
video.published = Time.unix(published)
|
||||
response = JSON.parse(video.to_json(locale, nil))
|
||||
|
||||
|
@ -13,7 +13,7 @@ module Invidious::Routes::API::Manifest
|
||||
unique_res = env.params.query["unique_res"]?.try { |q| (q == "true" || q == "1").to_unsafe }
|
||||
|
||||
begin
|
||||
video = get_video(id, PG_DB, region: region)
|
||||
video = get_video(id, region: region)
|
||||
rescue ex : VideoRedirect
|
||||
return env.redirect env.request.resource.gsub(id, ex.video_id)
|
||||
rescue ex
|
||||
|
@ -245,7 +245,7 @@ module Invidious::Routes::API::V1::Authenticated
|
||||
end
|
||||
|
||||
begin
|
||||
video = get_video(video_id, PG_DB)
|
||||
video = get_video(video_id)
|
||||
rescue ex
|
||||
return error_json(500, ex)
|
||||
end
|
||||
|
@ -8,7 +8,7 @@ module Invidious::Routes::API::V1::Videos
|
||||
region = env.params.query["region"]?
|
||||
|
||||
begin
|
||||
video = get_video(id, PG_DB, 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})
|
||||
@ -36,7 +36,7 @@ module Invidious::Routes::API::V1::Videos
|
||||
# getting video info.
|
||||
|
||||
begin
|
||||
video = get_video(id, PG_DB, 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})
|
||||
@ -157,7 +157,7 @@ module Invidious::Routes::API::V1::Videos
|
||||
region = env.params.query["region"]?
|
||||
|
||||
begin
|
||||
video = get_video(id, PG_DB, 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})
|
||||
@ -271,7 +271,7 @@ module Invidious::Routes::API::V1::Videos
|
||||
|
||||
annotations = response.body
|
||||
|
||||
cache_annotation(PG_DB, id, annotations)
|
||||
cache_annotation(id, annotations)
|
||||
end
|
||||
else # "youtube"
|
||||
response = YT_POOL.client &.get("/annotations_invideo?video_id=#{id}")
|
||||
|
@ -30,7 +30,7 @@ module Invidious::Routes::Embed
|
||||
id = env.params.url["id"]
|
||||
|
||||
plid = env.params.query["list"]?.try &.gsub(/[^a-zA-Z0-9_-]/, "")
|
||||
continuation = process_continuation(PG_DB, env.params.query, plid, id)
|
||||
continuation = process_continuation(env.params.query, plid, id)
|
||||
|
||||
if md = env.params.query["playlist"]?
|
||||
.try &.match(/[a-zA-Z0-9_-]{11}(,[a-zA-Z0-9_-]{11})*/)
|
||||
@ -119,7 +119,7 @@ module Invidious::Routes::Embed
|
||||
subscriptions ||= [] of String
|
||||
|
||||
begin
|
||||
video = get_video(id, PG_DB, 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
|
||||
|
@ -393,7 +393,7 @@ module Invidious::Routes::Feeds
|
||||
published = Time.parse_rfc3339(entry.xpath_node("published").not_nil!.content)
|
||||
updated = Time.parse_rfc3339(entry.xpath_node("updated").not_nil!.content)
|
||||
|
||||
video = get_video(id, PG_DB, force_refresh: true)
|
||||
video = get_video(id, force_refresh: true)
|
||||
|
||||
# Deliver notifications to `/api/v1/auth/notifications`
|
||||
payload = {
|
||||
|
@ -345,7 +345,7 @@ module Invidious::Routes::Playlists
|
||||
video_id = env.params.query["video_id"]
|
||||
|
||||
begin
|
||||
video = get_video(video_id, PG_DB)
|
||||
video = get_video(video_id)
|
||||
rescue ex
|
||||
if redirect
|
||||
return error_template(500, ex)
|
||||
|
@ -263,7 +263,7 @@ module Invidious::Routes::VideoPlayback
|
||||
haltf env, status_code: 400, response: "TESTING"
|
||||
end
|
||||
|
||||
video = get_video(id, PG_DB, region: region)
|
||||
video = get_video(id, region: region)
|
||||
|
||||
fmt = video.fmt_stream.find(nil) { |f| f["itag"].as_i == itag } || video.adaptive_fmts.find(nil) { |f| f["itag"].as_i == itag }
|
||||
url = fmt.try &.["url"]?.try &.as_s
|
||||
|
@ -39,7 +39,7 @@ module Invidious::Routes::Watch
|
||||
end
|
||||
|
||||
plid = env.params.query["list"]?.try &.gsub(/[^a-zA-Z0-9_-]/, "")
|
||||
continuation = process_continuation(PG_DB, env.params.query, plid, id)
|
||||
continuation = process_continuation(env.params.query, plid, id)
|
||||
|
||||
nojs = env.params.query["nojs"]?
|
||||
|
||||
@ -60,7 +60,7 @@ module Invidious::Routes::Watch
|
||||
env.params.query.delete_all("listen")
|
||||
|
||||
begin
|
||||
video = get_video(id, PG_DB, 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
|
||||
|
@ -993,7 +993,7 @@ def extract_video_info(video_id : String, proxy_region : String? = nil, context_
|
||||
return params
|
||||
end
|
||||
|
||||
def get_video(id, db, 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 record was last updated over 10 minutes ago, or video has since premiered,
|
||||
# refresh (expire param in response lasts for 6 hours)
|
||||
@ -1056,7 +1056,7 @@ def itag_to_metadata?(itag : JSON::Any)
|
||||
return VIDEO_FORMATS[itag.to_s]?
|
||||
end
|
||||
|
||||
def process_continuation(db, query, plid, id)
|
||||
def process_continuation(query, plid, id)
|
||||
continuation = nil
|
||||
if plid
|
||||
if index = query["index"]?.try &.to_i?
|
||||
|
Loading…
Reference in New Issue
Block a user