summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOmar Roth <omarroth@hotmail.com>2018-08-07 11:39:56 -0500
committerOmar Roth <omarroth@hotmail.com>2018-08-07 11:39:56 -0500
commit373c5378b25d25c9663b34db8274da7ce7f600f6 (patch)
treeb6756a9b7d6fcd699bf839c8d74f0623ba3fc26e
parenta5fb1d38e04298a6dfd8b4851052091db04d628f (diff)
downloadinvidious-373c5378b25d25c9663b34db8274da7ce7f600f6.tar.gz
invidious-373c5378b25d25c9663b34db8274da7ce7f600f6.tar.bz2
invidious-373c5378b25d25c9663b34db8274da7ce7f600f6.zip
Add '/videoplayback' redirect
-rw-r--r--src/invidious.cr25
-rw-r--r--src/invidious/helpers/helpers.cr2
-rw-r--r--src/invidious/videos.cr6
3 files changed, 25 insertions, 8 deletions
diff --git a/src/invidious.cr b/src/invidious.cr
index ce518a08..73e27f3e 100644
--- a/src/invidious.cr
+++ b/src/invidious.cr
@@ -223,6 +223,7 @@ get "/watch" do |env|
fmt_stream = video.fmt_stream(decrypt_function)
adaptive_fmts = video.adaptive_fmts(decrypt_function)
+ video_streams = video.video_streams(adaptive_fmts)
audio_streams = video.audio_streams(adaptive_fmts)
captions = video.captions
@@ -334,6 +335,7 @@ get "/embed/:id" do |env|
fmt_stream = video.fmt_stream(decrypt_function)
adaptive_fmts = video.adaptive_fmts(decrypt_function)
+ video_streams = video.video_streams(adaptive_fmts)
audio_streams = video.audio_streams(adaptive_fmts)
captions = video.captions
@@ -2553,8 +2555,8 @@ get "/api/manifest/dash/id/:id" do |env|
end
end
- video_streams = adaptive_fmts.compact_map { |s| s["type"].starts_with?("video/mp4") ? s : nil }
- audio_streams = adaptive_fmts.compact_map { |s| s["type"].starts_with?("audio/mp4") ? s : nil }
+ video_streams = adaptive_fmts.compact_map { |s| s["type"].starts_with?("video") ? s : nil }
+ audio_streams = adaptive_fmts.compact_map { |s| s["type"].starts_with?("audio") ? s : nil }
audio_streams.sort_by! { |s| s["bitrate"].to_i }.reverse!
audio_streams.each do |fmt|
@@ -2658,15 +2660,21 @@ get "/api/manifest/hls_playlist/*" do |env|
manifest
end
-options "/videoplayback/:wild/*" do |env|
+options "/videoplayback*" do |env|
env.response.headers["Access-Control-Allow-Origin"] = "*"
env.response.headers["Access-Control-Allow-Methods"] = "GET"
env.response.headers["Access-Control-Allow-Headers"] = "Content-Type, range"
end
-get "/videoplayback/:wild/*" do |env|
+options "/videoplayback/*" do |env|
+ env.response.headers["Access-Control-Allow-Origin"] = "*"
+ env.response.headers["Access-Control-Allow-Methods"] = "GET"
+ env.response.headers["Access-Control-Allow-Headers"] = "Content-Type, range"
+end
+
+get "/videoplayback/*" do |env|
path = env.request.path
- if path != "/videoplayback"
+
path = path.lchop("/videoplayback/")
path = path.rchop("/")
@@ -2690,9 +2698,12 @@ get "/videoplayback/:wild/*" do |env|
end
query_params = HTTP::Params.new(raw_params)
- else
+
+ env.redirect "/videoplayback?#{query_params}"
+end
+
+get "/videoplayback" do |env|
query_params = env.params.query
- end
fvip = query_params["fvip"]
mn = query_params["mn"].split(",")[0]
diff --git a/src/invidious/helpers/helpers.cr b/src/invidious/helpers/helpers.cr
index a7b202a9..874927e5 100644
--- a/src/invidious/helpers/helpers.cr
+++ b/src/invidious/helpers/helpers.cr
@@ -17,7 +17,7 @@ class Config
end
class FilteredCompressHandler < Kemal::Handler
- exclude ["/videoplayback/:wild/*", "/api/*"]
+ exclude ["/videoplayback/*", "/api/*"]
def call(env)
return call_next env if exclude_match? env
diff --git a/src/invidious/videos.cr b/src/invidious/videos.cr
index 346b60b6..01da1f1e 100644
--- a/src/invidious/videos.cr
+++ b/src/invidious/videos.cr
@@ -152,6 +152,12 @@ class Video
return adaptive_fmts
end
+ def video_streams(adaptive_fmts)
+ video_streams = adaptive_fmts.compact_map { |s| s["type"].starts_with?("video") ? s : nil }
+
+ return video_streams
+ end
+
def audio_streams(adaptive_fmts)
audio_streams = adaptive_fmts.compact_map { |s| s["type"].starts_with?("audio") ? s : nil }
audio_streams.sort_by! { |s| s["bitrate"].to_i }.reverse!