Invidious is an alternative front-end to YouTube
Pull dash URL from player response
Omar Roth09d0972ab452
diff --git a/src/invidious.cr b/src/invidious.crindex 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: 403end- 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).bodymanifest = manifest.gsub(/<BaseURL>[^<]+<\/BaseURL>/) do |baseurl|url = baseurl.lchop("<BaseURL>")@@ -3993,7 +3993,7 @@ get "/videoplayback" do |env|endif response.status_code >= 400- halt env, status_code: 403+ halt env, status_code: response.status_codeendclient = make_client(URI.parse(host), proxies, region)diff --git a/src/invidious/videos.cr b/src/invidious/videos.crindex 03770af7..e02378f7 100644--- a/src/invidious/videos.cr+++ b/src/invidious/videos.cr@@ -300,9 +300,9 @@ class Videoself.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_sclient = 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|