summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOmar Roth <omarroth@hotmail.com>2019-02-08 09:49:40 -0600
committerOmar Roth <omarroth@hotmail.com>2019-02-08 09:49:40 -0600
commit9698988be3814e84cb8bfe1bf1d9fda86c7f7de0 (patch)
treeacabb8d84fdfee2baaa1ffa193bfaa7311f6a413
parent29af5fc4a684ce6e47234e58cb53591f682f9e35 (diff)
downloadinvidious-9698988be3814e84cb8bfe1bf1d9fda86c7f7de0.tar.gz
invidious-9698988be3814e84cb8bfe1bf1d9fda86c7f7de0.tar.bz2
invidious-9698988be3814e84cb8bfe1bf1d9fda86c7f7de0.zip
Filter video streams to avoid duplicates in DASH player
-rw-r--r--src/invidious.cr12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/invidious.cr b/src/invidious.cr
index 87305db6..72ac8caf 100644
--- a/src/invidious.cr
+++ b/src/invidious.cr
@@ -3530,7 +3530,12 @@ get "/api/manifest/dash/id/:id" do |env|
begin
video = 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 url
rescue ex
halt env, status_code: 403
end
@@ -3560,8 +3565,8 @@ get "/api/manifest/dash/id/:id" do |env|
end
end
- 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") do
xml.element("AdaptationSet", mimeType: "audio/mp4", startWithSAP: 1, subsegmentAlignment: true) do
audio_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") do
video_streams.each do |fmt|
- mimetype = fmt["type"].split(";")
codecs = fmt["type"].split("codecs=")[1].strip('"')
bandwidth = fmt["bitrate"]
itag = fmt["itag"]