mirror of
https://github.com/iv-org/invidious.git
synced 2024-10-01 01:25:56 -04:00
Use config.domain in place of hardcoded value
This commit is contained in:
parent
9580a21786
commit
20c4d213d9
@ -364,7 +364,7 @@ get "/watch" do |env|
|
|||||||
video.description = replace_links(video.description)
|
video.description = replace_links(video.description)
|
||||||
description = video.short_description
|
description = video.short_description
|
||||||
|
|
||||||
host_url = make_host_url(Kemal.config.ssl || CONFIG.https_only, env.request.headers["Host"]?)
|
host_url = make_host_url(Kemal.config.ssl || CONFIG.https_only, CONFIG.domain)
|
||||||
host_params = env.request.query_params
|
host_params = env.request.query_params
|
||||||
host_params.delete_all("v")
|
host_params.delete_all("v")
|
||||||
|
|
||||||
@ -466,7 +466,7 @@ get "/embed/:id" do |env|
|
|||||||
video.description = replace_links(video.description)
|
video.description = replace_links(video.description)
|
||||||
description = video.short_description
|
description = video.short_description
|
||||||
|
|
||||||
host_url = make_host_url(Kemal.config.ssl || CONFIG.https_only, env.request.headers["Host"]?)
|
host_url = make_host_url(Kemal.config.ssl || CONFIG.https_only, CONFIG.domain)
|
||||||
host_params = env.request.query_params
|
host_params = env.request.query_params
|
||||||
host_params.delete_all("v")
|
host_params.delete_all("v")
|
||||||
|
|
||||||
@ -552,14 +552,16 @@ get "/opensearch.xml" do |env|
|
|||||||
locale = LOCALES[env.get("locale").as(String)]?
|
locale = LOCALES[env.get("locale").as(String)]?
|
||||||
env.response.content_type = "application/opensearchdescription+xml"
|
env.response.content_type = "application/opensearchdescription+xml"
|
||||||
|
|
||||||
|
host = make_host_url(Kemal.config.ssl || CONFIG.https_only, CONFIG.domain)
|
||||||
|
|
||||||
XML.build(indent: " ", encoding: "UTF-8") do |xml|
|
XML.build(indent: " ", encoding: "UTF-8") do |xml|
|
||||||
xml.element("OpenSearchDescription", xmlns: "http://a9.com/-/spec/opensearch/1.1/") do
|
xml.element("OpenSearchDescription", xmlns: "http://a9.com/-/spec/opensearch/1.1/") do
|
||||||
xml.element("ShortName") { xml.text "Invidious" }
|
xml.element("ShortName") { xml.text "Invidious" }
|
||||||
xml.element("LongName") { xml.text "Invidious Search" }
|
xml.element("LongName") { xml.text "Invidious Search" }
|
||||||
xml.element("Description") { xml.text "Search for videos, channels, and playlists on Invidious" }
|
xml.element("Description") { xml.text "Search for videos, channels, and playlists on Invidious" }
|
||||||
xml.element("InputEncoding") { xml.text "UTF-8" }
|
xml.element("InputEncoding") { xml.text "UTF-8" }
|
||||||
xml.element("Image", width: 48, height: 48, type: "image/x-icon") { xml.text "https://invidio.us/favicon.ico" }
|
xml.element("Image", width: 48, height: 48, type: "image/x-icon") { xml.text "#{host}/favicon.ico" }
|
||||||
xml.element("Url", type: "text/html", method: "get", template: "https://invidio.us/search?q={searchTerms}")
|
xml.element("Url", type: "text/html", method: "get", template: "#{host}/search?q={searchTerms}")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -1367,7 +1369,7 @@ get "/subscription_manager" do |env|
|
|||||||
subscriptions.sort_by! { |channel| channel.author.downcase }
|
subscriptions.sort_by! { |channel| channel.author.downcase }
|
||||||
|
|
||||||
if action_takeout
|
if action_takeout
|
||||||
host_url = make_host_url(Kemal.config.ssl || CONFIG.https_only, env.request.headers["Host"]?)
|
host_url = make_host_url(Kemal.config.ssl || CONFIG.https_only, CONFIG.domain)
|
||||||
|
|
||||||
if format == "json"
|
if format == "json"
|
||||||
env.response.content_type = "application/json"
|
env.response.content_type = "application/json"
|
||||||
@ -1915,7 +1917,7 @@ get "/feed/channel/:ucid" do |env|
|
|||||||
videos, count = get_60_videos(ucid, page, auto_generated)
|
videos, count = get_60_videos(ucid, page, auto_generated)
|
||||||
videos.select! { |video| !video.paid }
|
videos.select! { |video| !video.paid }
|
||||||
|
|
||||||
host_url = make_host_url(Kemal.config.ssl || CONFIG.https_only, env.request.headers["Host"]?)
|
host_url = make_host_url(Kemal.config.ssl || CONFIG.https_only, CONFIG.domain)
|
||||||
path = env.request.path
|
path = env.request.path
|
||||||
|
|
||||||
feed = XML.build(indent: " ", encoding: "UTF-8") do |xml|
|
feed = XML.build(indent: " ", encoding: "UTF-8") do |xml|
|
||||||
@ -2037,7 +2039,7 @@ get "/feed/private" do |env|
|
|||||||
videos = videos[0..max_results]
|
videos = videos[0..max_results]
|
||||||
end
|
end
|
||||||
|
|
||||||
host_url = make_host_url(Kemal.config.ssl || CONFIG.https_only, env.request.headers["Host"]?)
|
host_url = make_host_url(Kemal.config.ssl || CONFIG.https_only, CONFIG.domain)
|
||||||
path = env.request.path
|
path = env.request.path
|
||||||
query = env.request.query.not_nil!
|
query = env.request.query.not_nil!
|
||||||
|
|
||||||
@ -2084,7 +2086,7 @@ get "/feed/playlist/:plid" do |env|
|
|||||||
|
|
||||||
plid = env.params.url["plid"]
|
plid = env.params.url["plid"]
|
||||||
|
|
||||||
host_url = make_host_url(Kemal.config.ssl || CONFIG.https_only, env.request.headers["Host"]?)
|
host_url = make_host_url(Kemal.config.ssl || CONFIG.https_only, CONFIG.domain)
|
||||||
path = env.request.path
|
path = env.request.path
|
||||||
|
|
||||||
client = make_client(YT_URL)
|
client = make_client(YT_URL)
|
||||||
@ -2521,7 +2523,8 @@ get "/api/v1/videos/:id" do |env|
|
|||||||
end
|
end
|
||||||
|
|
||||||
if video.player_response["streamingData"]?.try &.["hlsManifestUrl"]?
|
if video.player_response["streamingData"]?.try &.["hlsManifestUrl"]?
|
||||||
host_url = make_host_url(Kemal.config.ssl || CONFIG.https_only, env.request.headers["Host"]?)
|
host_url = make_host_url(Kemal.config.ssl || CONFIG.https_only, CONFIG.domain)
|
||||||
|
|
||||||
host_params = env.request.query_params
|
host_params = env.request.query_params
|
||||||
host_params.delete_all("v")
|
host_params.delete_all("v")
|
||||||
|
|
||||||
@ -3536,7 +3539,8 @@ get "/api/manifest/hls_variant/*" do |env|
|
|||||||
env.response.content_type = "application/x-mpegURL"
|
env.response.content_type = "application/x-mpegURL"
|
||||||
env.response.headers.add("Access-Control-Allow-Origin", "*")
|
env.response.headers.add("Access-Control-Allow-Origin", "*")
|
||||||
|
|
||||||
host_url = make_host_url(Kemal.config.ssl || CONFIG.https_only, env.request.headers["Host"])
|
host_url = make_host_url(Kemal.config.ssl || CONFIG.https_only, CONFIG.domain)
|
||||||
|
|
||||||
manifest = manifest.body
|
manifest = manifest.body
|
||||||
manifest.gsub("https://www.youtube.com", host_url)
|
manifest.gsub("https://www.youtube.com", host_url)
|
||||||
end
|
end
|
||||||
@ -3549,7 +3553,7 @@ get "/api/manifest/hls_playlist/*" do |env|
|
|||||||
halt env, status_code: manifest.status_code
|
halt env, status_code: manifest.status_code
|
||||||
end
|
end
|
||||||
|
|
||||||
host_url = make_host_url(Kemal.config.ssl || CONFIG.https_only, env.request.headers["Host"])
|
host_url = make_host_url(Kemal.config.ssl || CONFIG.https_only, CONFIG.domain)
|
||||||
|
|
||||||
manifest = manifest.body.gsub("https://www.youtube.com", host_url)
|
manifest = manifest.body.gsub("https://www.youtube.com", host_url)
|
||||||
manifest = manifest.gsub(/https:\/\/r\d---.{11}\.c\.youtube\.com/, host_url)
|
manifest = manifest.gsub(/https:\/\/r\d---.{11}\.c\.youtube\.com/, host_url)
|
||||||
|
@ -15,7 +15,10 @@ class Config
|
|||||||
https_only: Bool?,
|
https_only: Bool?,
|
||||||
hmac_key: String?,
|
hmac_key: String?,
|
||||||
full_refresh: Bool,
|
full_refresh: Bool,
|
||||||
domain: String?,
|
domain: {
|
||||||
|
type: String?,
|
||||||
|
default: "invidio.us",
|
||||||
|
},
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -205,8 +205,6 @@ def make_host_url(ssl, host)
|
|||||||
scheme = "http://"
|
scheme = "http://"
|
||||||
end
|
end
|
||||||
|
|
||||||
host ||= "invidio.us"
|
|
||||||
|
|
||||||
return "#{scheme}#{host}"
|
return "#{scheme}#{host}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -137,7 +137,7 @@ BYPASS_REGIONS = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
VIDEO_THUMBNAILS = {
|
VIDEO_THUMBNAILS = {
|
||||||
{name: "maxres", host: "invidio.us", url: "maxres", height: 720, width: 1280},
|
{name: "maxres", host: "#{CONFIG.domain}", url: "maxres", height: 720, width: 1280},
|
||||||
{name: "maxresdefault", host: "i.ytimg.com", url: "maxresdefault", height: 720, width: 1280},
|
{name: "maxresdefault", host: "i.ytimg.com", url: "maxresdefault", height: 720, width: 1280},
|
||||||
{name: "sddefault", host: "i.ytimg.com", url: "sddefault", height: 480, width: 640},
|
{name: "sddefault", host: "i.ytimg.com", url: "sddefault", height: 480, width: 640},
|
||||||
{name: "high", host: "i.ytimg.com", url: "hqdefault", height: 360, width: 480},
|
{name: "high", host: "i.ytimg.com", url: "hqdefault", height: 360, width: 480},
|
||||||
|
Loading…
Reference in New Issue
Block a user