mirror of
https://github.com/iv-org/invidious.git
synced 2026-01-28 07:48:31 -06:00
refactor: Move top level constants to it's own modules
This commit is contained in:
parent
344bc2d8e9
commit
146198c8c1
@ -67,20 +67,9 @@ rescue ex
|
|||||||
puts "Check your 'config.yml' database settings or PostgreSQL settings."
|
puts "Check your 'config.yml' database settings or PostgreSQL settings."
|
||||||
exit(1)
|
exit(1)
|
||||||
end
|
end
|
||||||
ARCHIVE_URL = URI.parse("https://archive.org")
|
HOST_URL = make_host_url(Kemal.config)
|
||||||
PUBSUB_URL = URI.parse("https://pubsubhubbub.appspot.com")
|
|
||||||
REDDIT_URL = URI.parse("https://www.reddit.com")
|
|
||||||
YT_URL = URI.parse("https://www.youtube.com")
|
|
||||||
HOST_URL = make_host_url(Kemal.config)
|
|
||||||
|
|
||||||
CHARS_SAFE = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"
|
|
||||||
TEST_IDS = {"AgbeGFYluEA", "BaW_jenozKc", "a9LDPn-MO4I", "ddFvjfvPnqk", "iqKdEhx-dD4"}
|
|
||||||
MAX_ITEMS_PER_PAGE = 1500
|
MAX_ITEMS_PER_PAGE = 1500
|
||||||
|
|
||||||
REQUEST_HEADERS_WHITELIST = {"accept", "accept-encoding", "cache-control", "content-length", "if-none-match", "range"}
|
|
||||||
RESPONSE_HEADERS_BLACKLIST = {"access-control-allow-origin", "alt-svc", "server", "cross-origin-opener-policy-report-only", "report-to", "cross-origin", "timing-allow-origin", "cross-origin-resource-policy"}
|
|
||||||
HTTP_CHUNK_SIZE = 10485760 # ~10MB
|
|
||||||
|
|
||||||
CURRENT_BRANCH = {{ "#{`git branch | sed -n '/* /s///p'`.strip}" }}
|
CURRENT_BRANCH = {{ "#{`git branch | sed -n '/* /s///p'`.strip}" }}
|
||||||
CURRENT_COMMIT = {{ "#{`git rev-list HEAD --max-count=1 --abbrev-commit`.strip}" }}
|
CURRENT_COMMIT = {{ "#{`git rev-list HEAD --max-count=1 --abbrev-commit`.strip}" }}
|
||||||
CURRENT_VERSION = {{ "#{`git log -1 --format=%ci | awk '{print $1}' | sed s/-/./g`.strip}" }}
|
CURRENT_VERSION = {{ "#{`git log -1 --format=%ci | awk '{print $1}' | sed s/-/./g`.strip}" }}
|
||||||
@ -97,7 +86,7 @@ SOFTWARE = {
|
|||||||
"branch" => "#{CURRENT_BRANCH}",
|
"branch" => "#{CURRENT_BRANCH}",
|
||||||
}
|
}
|
||||||
|
|
||||||
YT_POOL = YoutubeConnectionPool.new(YT_URL, capacity: CONFIG.pool_size)
|
YT_POOL = YoutubeConnectionPool.new(URI.parse("https://www.youtube.com"), capacity: CONFIG.pool_size)
|
||||||
|
|
||||||
# Image request pool
|
# Image request pool
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
module Invidious::Comments
|
module Invidious::Comments
|
||||||
extend self
|
extend self
|
||||||
|
private REDDIT_URL = URI.parse("https://www.reddit.com")
|
||||||
|
|
||||||
def fetch_reddit(id, sort_by = "confidence")
|
def fetch_reddit(id, sort_by = "confidence")
|
||||||
client = make_client(REDDIT_URL)
|
client = make_client(REDDIT_URL)
|
||||||
|
|||||||
@ -1,5 +1,7 @@
|
|||||||
require "./macros"
|
require "./macros"
|
||||||
|
|
||||||
|
TEST_IDS = {"AgbeGFYluEA", "BaW_jenozKc", "a9LDPn-MO4I", "ddFvjfvPnqk", "iqKdEhx-dD4"}
|
||||||
|
|
||||||
struct Nonce
|
struct Nonce
|
||||||
include DB::Serializable
|
include DB::Serializable
|
||||||
|
|
||||||
|
|||||||
@ -1,3 +1,5 @@
|
|||||||
|
PUBSUB_URL = URI.parse("https://pubsubhubbub.appspot.com")
|
||||||
|
|
||||||
# See http://www.evanmiller.org/how-not-to-sort-by-average-rating.html
|
# See http://www.evanmiller.org/how-not-to-sort-by-average-rating.html
|
||||||
def ci_lower_bound(pos, n)
|
def ci_lower_bound(pos, n)
|
||||||
if n == 0
|
if n == 0
|
||||||
|
|||||||
@ -1,6 +1,9 @@
|
|||||||
require "html"
|
require "html"
|
||||||
|
|
||||||
module Invidious::Routes::API::V1::Videos
|
module Invidious::Routes::API::V1::Videos
|
||||||
|
private INTERNET_ARCHIVE_URL = URI.parse("https://archive.org")
|
||||||
|
private CHARS_SAFE = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"
|
||||||
|
|
||||||
def self.videos(env)
|
def self.videos(env)
|
||||||
locale = env.get("preferences").as(Preferences).locale
|
locale = env.get("preferences").as(Preferences).locale
|
||||||
|
|
||||||
@ -279,7 +282,7 @@ module Invidious::Routes::API::V1::Videos
|
|||||||
|
|
||||||
file = URI.encode_www_form("#{id[0, 3]}/#{id}.xml")
|
file = URI.encode_www_form("#{id[0, 3]}/#{id}.xml")
|
||||||
|
|
||||||
location = make_client(ARCHIVE_URL, &.get("/download/youtubeannotations_#{index}/#{id[0, 2]}.tar/#{file}"))
|
location = make_client(INTERNET_ARCHIVE_URL, &.get("/download/youtubeannotations_#{index}/#{id[0, 2]}.tar/#{file}"))
|
||||||
|
|
||||||
if !location.headers["Location"]?
|
if !location.headers["Location"]?
|
||||||
env.response.status_code = location.status_code
|
env.response.status_code = location.status_code
|
||||||
|
|||||||
21
src/invidious/routes/routes.cr
Normal file
21
src/invidious/routes/routes.cr
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
module Invidious::Routes
|
||||||
|
private REQUEST_HEADERS_WHITELIST = {
|
||||||
|
"accept",
|
||||||
|
"accept-encoding",
|
||||||
|
"cache-control",
|
||||||
|
"content-length",
|
||||||
|
"if-none-match",
|
||||||
|
"range",
|
||||||
|
}
|
||||||
|
private RESPONSE_HEADERS_BLACKLIST = {
|
||||||
|
"access-control-allow-origin",
|
||||||
|
"alt-svc",
|
||||||
|
"server",
|
||||||
|
"cross-origin-opener-policy-report-only",
|
||||||
|
"report-to",
|
||||||
|
"cross-origin",
|
||||||
|
"timing-allow-origin",
|
||||||
|
"cross-origin-resource-policy
|
||||||
|
",
|
||||||
|
}
|
||||||
|
end
|
||||||
@ -1,4 +1,6 @@
|
|||||||
module Invidious::Routes::VideoPlayback
|
module Invidious::Routes::VideoPlayback
|
||||||
|
private HTTP_CHUNK_SIZE = 10485760 # ~10MB
|
||||||
|
|
||||||
# /videoplayback
|
# /videoplayback
|
||||||
def self.get_video_playback(env)
|
def self.get_video_playback(env)
|
||||||
locale = env.get("preferences").as(Preferences).locale
|
locale = env.get("preferences").as(Preferences).locale
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user