From 7116421fa4d6e5a0e7bf4651731bad8a31518997 Mon Sep 17 00:00:00 2001 From: Omar Roth Date: Sat, 11 Aug 2018 14:29:51 -0500 Subject: [PATCH] Use http-streaming for livestreams --- src/invidious.cr | 7 ++++--- src/invidious/helpers/helpers.cr | 2 +- src/invidious/views/components/player_sources.ecr | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/invidious.cr b/src/invidious.cr index 0cf6eb72..6d95a04e 100644 --- a/src/invidious.cr +++ b/src/invidious.cr @@ -2401,7 +2401,7 @@ get "/api/manifest/dash/id/:id" do |env| mimetype = fmt["type"].split(";")[0] codecs = fmt["type"].split("codecs=")[1].strip('"') fmt_type = mimetype.split("/")[0] - bandwidth = fmt["clen"] + bandwidth = fmt["bitrate"] itag = fmt["itag"] url = fmt["url"] @@ -2421,7 +2421,7 @@ get "/api/manifest/dash/id/:id" do |env| video_streams.each do |fmt| mimetype = fmt["type"].split(";") codecs = fmt["type"].split("codecs=")[1].strip('"') - bandwidth = fmt["clen"] + bandwidth = fmt["bitrate"] itag = fmt["itag"] url = fmt["url"] height, width = fmt["size"].split("x") @@ -2532,6 +2532,7 @@ get "/videoplayback/*" do |env| query_params = HTTP::Params.new(raw_params) + env.response.headers["Access-Control-Allow-Origin"] = "*" env.redirect "/videoplayback?#{query_params}" end @@ -2539,7 +2540,7 @@ get "/videoplayback" do |env| query_params = env.params.query fvip = query_params["fvip"] - mn = query_params["mn"].split(",")[0] + mn = query_params["mn"].split(",")[-1] host = "https://r#{fvip}---#{mn}.googlevideo.com" url = "/videoplayback?#{query_params.to_s}" diff --git a/src/invidious/helpers/helpers.cr b/src/invidious/helpers/helpers.cr index 68b7faf2..58450d94 100644 --- a/src/invidious/helpers/helpers.cr +++ b/src/invidious/helpers/helpers.cr @@ -18,7 +18,7 @@ class Config end class FilteredCompressHandler < Kemal::Handler - exclude ["/videoplayback", "/api/*"] + exclude ["/videoplayback", "/videoplayback/*", "/api/*"] def call(env) return call_next env if exclude_match? env diff --git a/src/invidious/views/components/player_sources.ecr b/src/invidious/views/components/player_sources.ecr index 0132a57f..37a0df9c 100644 --- a/src/invidious/views/components/player_sources.ecr +++ b/src/invidious/views/components/player_sources.ecr @@ -8,5 +8,5 @@ <% if hlsvp %> - + <% end %>