diff options
Diffstat (limited to 'src/invidious.cr')
| -rw-r--r-- | src/invidious.cr | 28 |
1 files changed, 15 insertions, 13 deletions
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) |
