summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--shard.yml2
-rw-r--r--src/invidious.cr28
-rw-r--r--src/invidious/comments.cr2
-rw-r--r--src/invidious/helpers/helpers.cr5
-rw-r--r--src/invidious/helpers/utils.cr2
-rw-r--r--src/invidious/videos.cr2
6 files changed, 22 insertions, 19 deletions
diff --git a/shard.yml b/shard.yml
index 6ed680f2..79997ad4 100644
--- a/shard.yml
+++ b/shard.yml
@@ -1,5 +1,5 @@
name: invidious
-version: 0.13.0
+version: 0.13.1
authors:
- Omar Roth <omarroth@hotmail.com>
diff --git a/src/invidious.cr b/src/invidious.cr
index 6f9097fc..f8a7d759 100644
--- a/src/invidious.cr
+++ b/src/invidious.cr
@@ -364,7 +364,7 @@ get "/watch" do |env|
video.description = replace_links(video.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.delete_all("v")
@@ -392,9 +392,7 @@ get "/watch" do |env|
rvs << HTTP::Params.parse(rv).to_h
end
- # rating = (video.likes.to_f/(video.likes.to_f + video.dislikes.to_f) * 4 + 1)
rating = video.info["avg_rating"].to_f64
-
engagement = ((video.dislikes.to_f + video.likes.to_f)/video.views * 100)
playability_status = video.player_response["playabilityStatus"]?
@@ -466,7 +464,7 @@ get "/embed/:id" do |env|
video.description = replace_links(video.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.delete_all("v")
@@ -552,14 +550,16 @@ get "/opensearch.xml" do |env|
locale = LOCALES[env.get("locale").as(String)]?
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.element("OpenSearchDescription", xmlns: "http://a9.com/-/spec/opensearch/1.1/") do
xml.element("ShortName") { xml.text "Invidious" }
xml.element("LongName") { xml.text "Invidious Search" }
xml.element("Description") { xml.text "Search for videos, channels, and playlists on Invidious" }
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("Url", type: "text/html", method: "get", template: "https://invidio.us/search?q={searchTerms}")
+ 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: "#{host}/search?q={searchTerms}")
end
end
end
@@ -1367,7 +1367,7 @@ get "/subscription_manager" do |env|
subscriptions.sort_by! { |channel| channel.author.downcase }
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"
env.response.content_type = "application/json"
@@ -1915,7 +1915,7 @@ get "/feed/channel/:ucid" do |env|
videos, count = get_60_videos(ucid, page, auto_generated)
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
feed = XML.build(indent: " ", encoding: "UTF-8") do |xml|
@@ -2037,7 +2037,7 @@ get "/feed/private" do |env|
videos = videos[0..max_results]
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
query = env.request.query.not_nil!
@@ -2084,7 +2084,7 @@ get "/feed/playlist/:plid" do |env|
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
client = make_client(YT_URL)
@@ -2521,7 +2521,8 @@ get "/api/v1/videos/:id" do |env|
end
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.delete_all("v")
@@ -3536,7 +3537,8 @@ get "/api/manifest/hls_variant/*" do |env|
env.response.content_type = "application/x-mpegURL"
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.gsub("https://www.youtube.com", host_url)
end
@@ -3549,7 +3551,7 @@ get "/api/manifest/hls_playlist/*" do |env|
halt env, status_code: manifest.status_code
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.gsub(/https:\/\/r\d---.{11}\.c\.youtube\.com/, host_url)
diff --git a/src/invidious/comments.cr b/src/invidious/comments.cr
index 86dbb6b5..1b81c6b7 100644
--- a/src/invidious/comments.cr
+++ b/src/invidious/comments.cr
@@ -270,7 +270,7 @@ end
def fetch_reddit_comments(id)
client = make_client(REDDIT_URL)
- headers = HTTP::Headers{"User-Agent" => "web:invidio.us:v0.13.0 (by /u/omarroth)"}
+ headers = HTTP::Headers{"User-Agent" => "web:invidio.us:v0.13.1 (by /u/omarroth)"}
query = "(url:3D#{id}%20OR%20url:#{id})%20(site:youtube.com%20OR%20site:youtu.be)"
search_results = client.get("/search.json?q=#{query}", headers)
diff --git a/src/invidious/helpers/helpers.cr b/src/invidious/helpers/helpers.cr
index 4af924c0..e25ea880 100644
--- a/src/invidious/helpers/helpers.cr
+++ b/src/invidious/helpers/helpers.cr
@@ -15,7 +15,10 @@ class Config
https_only: Bool?,
hmac_key: String?,
full_refresh: Bool,
- domain: String?,
+ domain: {
+ type: String?,
+ default: "invidio.us",
+ },
})
end
diff --git a/src/invidious/helpers/utils.cr b/src/invidious/helpers/utils.cr
index 496c3e0d..07c4bff3 100644
--- a/src/invidious/helpers/utils.cr
+++ b/src/invidious/helpers/utils.cr
@@ -205,8 +205,6 @@ def make_host_url(ssl, host)
scheme = "http://"
end
- host ||= "invidio.us"
-
return "#{scheme}#{host}"
end
diff --git a/src/invidious/videos.cr b/src/invidious/videos.cr
index b4705daa..18a2ff8a 100644
--- a/src/invidious/videos.cr
+++ b/src/invidious/videos.cr
@@ -137,7 +137,7 @@ BYPASS_REGIONS = {
}
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: "sddefault", host: "i.ytimg.com", url: "sddefault", height: 480, width: 640},
{name: "high", host: "i.ytimg.com", url: "hqdefault", height: 360, width: 480},