Skip to content

Commit

Permalink
Pull dash URL from player response
Browse files Browse the repository at this point in the history
  • Loading branch information
omarroth committed Feb 25, 2019
1 parent 6b12449 commit 09d0972
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/invidious.cr
Original file line number Diff line number Diff line change
Expand Up @@ -3735,8 +3735,8 @@ 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
if dashmpd = video.player_response["streamingData"]["dashManifestUrl"]?.try &.as_s
manifest = client.get(dashmpd).body

manifest = manifest.gsub(/<BaseURL>[^<]+<\/BaseURL>/) do |baseurl|
url = baseurl.lchop("<BaseURL>")
Expand Down Expand Up @@ -3993,7 +3993,7 @@ get "/videoplayback" do |env|
end

if response.status_code >= 400
halt env, status_code: 403
halt env, status_code: response.status_code
end

client = make_client(URI.parse(host), proxies, region)
Expand Down
4 changes: 2 additions & 2 deletions src/invidious/videos.cr
Original file line number Diff line number Diff line change
Expand Up @@ -300,9 +300,9 @@ class Video
self.info["adaptive_fmts"].split(",") do |string|
adaptive_fmts << HTTP::Params.parse(string)
end
elsif self.info.has_key?("dashmpd")
elsif dashmpd = self.player_response["streamingData"]["dashManifestUrl"]?.try &.as_s
client = make_client(YT_URL)
response = client.get(self.info["dashmpd"])
response = client.get(dashmpd)
document = XML.parse_html(response.body)

document.xpath_nodes(%q(//adaptationset)).each do |adaptation_set|
Expand Down

0 comments on commit 09d0972

Please sign in to comment.