diff options
| author | Omar Roth <omarroth@hotmail.com> | 2018-07-15 20:39:56 -0500 |
|---|---|---|
| committer | Omar Roth <omarroth@hotmail.com> | 2018-07-15 20:39:56 -0500 |
| commit | f05afaf3422ba89de8a86228d360ce8d9aa47a4c (patch) | |
| tree | e8a0301cc95ad85a6384b8ed7b32382d3f8657b5 | |
| parent | c19b373944b9fb70c2da0d9bcbd33a455f7422aa (diff) | |
| download | invidious-f05afaf3422ba89de8a86228d360ce8d9aa47a4c.tar.gz invidious-f05afaf3422ba89de8a86228d360ce8d9aa47a4c.tar.bz2 invidious-f05afaf3422ba89de8a86228d360ce8d9aa47a4c.zip | |
Add dash support for videos that already have manifest
| -rw-r--r-- | src/invidious.cr | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/src/invidious.cr b/src/invidious.cr index b5fea229..83a6414b 100644 --- a/src/invidious.cr +++ b/src/invidious.cr @@ -678,8 +678,6 @@ get "/redirect" do |env| end end -# Return dash manifest for the given video ID, note this will not work on -# videos that already have a dashmpd in video info. get "/api/manifest/dash/id/:id" do |env| env.response.headers.add("Access-Control-Allow-Origin", "*") env.response.content_type = "application/dash+xml" @@ -694,6 +692,28 @@ get "/api/manifest/dash/id/:id" do |env| halt env, status_code: 403 end + if video.info["dashmpd"]? + manifest = client.get(video.info["dashmpd"]).body + + manifest = manifest.gsub(/<BaseURL>[^<]+<\/BaseURL>/) do |baseurl| + url = baseurl.lchop("<BaseURL>") + url = url.rchop("</BaseURL>") + + if local + if Kemal.config.ssl + scheme = "https://" + end + scheme ||= "http://" + + url = scheme + env.request.headers["Host"] + URI.parse(url).full_path + end + + "<BaseURL>#{url}</BaseURL>" + end + + next manifest + end + adaptive_fmts = [] of HTTP::Params if video.info.has_key?("adaptive_fmts") video.info["adaptive_fmts"].split(",") do |string| |
