From 09d0972ab45227be66e3e3a29934c3378dc6dc1f Mon Sep 17 00:00:00 2001 From: Omar Roth Date: Mon, 25 Feb 2019 09:11:41 -0600 Subject: [PATCH] Pull dash URL from player response --- src/invidious.cr | 6 +++--- src/invidious/videos.cr | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/invidious.cr b/src/invidious.cr index 3129f6d2..dda725ff 100644 --- a/src/invidious.cr +++ b/src/invidious.cr @@ -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>/) do |baseurl| url = baseurl.lchop("") @@ -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) diff --git a/src/invidious/videos.cr b/src/invidious/videos.cr index 03770af7..e02378f7 100644 --- a/src/invidious/videos.cr +++ b/src/invidious/videos.cr @@ -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|