From 8c22c226c0e6aba62709153bbc0dc8f9bd5d4475 Mon Sep 17 00:00:00 2001 From: Omar Roth Date: Sun, 5 Aug 2018 14:03:13 -0500 Subject: [PATCH] Add 'raw=1' to '/watch' page --- src/invidious.cr | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/invidious.cr b/src/invidious.cr index 70e243a7..111f0cbf 100644 --- a/src/invidious.cr +++ b/src/invidious.cr @@ -193,7 +193,7 @@ get "/watch" do |env| end subscriptions ||= [] of String - autoplay, video_loop, video_start, video_end, listen = process_video_params(env.params.query, preferences) + autoplay, video_loop, video_start, video_end, listen, raw, quality, autoplay = process_video_params(env.params.query, preferences) if listen env.params.query.delete_all("listen") end @@ -228,6 +228,18 @@ get "/watch" do |env| # TODO: Find highest resolution thumbnail automatically thumbnail = "https://i.ytimg.com/vi/#{video.id}/mqdefault.jpg" + if raw + url = fmt_stream[0]["url"] + + fmt_stream.each do |fmt| + if fmt["label"].split(" - ")[0] == quality + url = fmt["url"] + end + end + + next env.redirect url + end + rvs = [] of Hash(String, String) if video.info.has_key?("rvs") video.info["rvs"].split(",").each do |rv|