Invidious is an alternative front-end to YouTube
Filter video streams to avoid duplicates in DASH player
Omar Roth9698988be381
diff --git a/src/invidious.cr b/src/invidious.crindex 87305db6..72ac8caf 100644--- a/src/invidious.cr+++ b/src/invidious.cr@@ -3530,7 +3530,12 @@ get "/api/manifest/dash/id/:id" do |env|beginvideo = get_video(id, PG_DB, proxies, region: region)rescue ex : VideoRedirect- next env.redirect "/api/manifest/dash/id/#{ex.message}"+ url = "/api/manifest/dash/id/#{ex.message}"+ if local+ url += "?local=true"+ end++ next env.redirect urlrescue exhalt env, status_code: 403end@@ -3560,8 +3565,8 @@ get "/api/manifest/dash/id/:id" do |env|endend- video_streams = video.video_streams(adaptive_fmts).select { |stream| stream["type"].starts_with? "video/mp4" }audio_streams = video.audio_streams(adaptive_fmts).select { |stream| stream["type"].starts_with? "audio/mp4" }+ video_streams = video.video_streams(adaptive_fmts).select { |stream| stream["type"].starts_with? "video/mp4" }.uniq { |stream| stream["size"] }manifest = XML.build(indent: " ", encoding: "UTF-8") do |xml|xml.element("MPD", "xmlns": "urn:mpeg:dash:schema:mpd:2011",@@ -3570,9 +3575,7 @@ get "/api/manifest/dash/id/:id" do |env|xml.element("Period") doxml.element("AdaptationSet", mimeType: "audio/mp4", startWithSAP: 1, subsegmentAlignment: true) doaudio_streams.each do |fmt|- mimetype = fmt["type"].split(";")[0]codecs = fmt["type"].split("codecs=")[1].strip('"')- fmt_type = mimetype.split("/")[0]bandwidth = fmt["bitrate"]itag = fmt["itag"]url = fmt["url"]@@ -3591,7 +3594,6 @@ get "/api/manifest/dash/id/:id" do |env|xml.element("AdaptationSet", mimeType: "video/mp4", startWithSAP: 1, subsegmentAlignment: true,scanType: "progressive") dovideo_streams.each do |fmt|- mimetype = fmt["type"].split(";")codecs = fmt["type"].split("codecs=")[1].strip('"')bandwidth = fmt["bitrate"]itag = fmt["itag"]