mirror of
https://github.com/iv-org/invidious.git
synced 2024-11-26 07:27:22 +00:00
Filter video streams to avoid duplicates in DASH player
This commit is contained in:
parent
29af5fc4a6
commit
9698988be3
@ -3530,7 +3530,12 @@ get "/api/manifest/dash/id/:id" do |env|
|
|||||||
begin
|
begin
|
||||||
video = get_video(id, PG_DB, proxies, region: region)
|
video = get_video(id, PG_DB, proxies, region: region)
|
||||||
rescue ex : VideoRedirect
|
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
|
rescue ex
|
||||||
halt env, status_code: 403
|
halt env, status_code: 403
|
||||||
end
|
end
|
||||||
@ -3560,8 +3565,8 @@ get "/api/manifest/dash/id/:id" do |env|
|
|||||||
end
|
end
|
||||||
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" }
|
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|
|
manifest = XML.build(indent: " ", encoding: "UTF-8") do |xml|
|
||||||
xml.element("MPD", "xmlns": "urn:mpeg:dash:schema:mpd:2011",
|
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("Period") do
|
||||||
xml.element("AdaptationSet", mimeType: "audio/mp4", startWithSAP: 1, subsegmentAlignment: true) do
|
xml.element("AdaptationSet", mimeType: "audio/mp4", startWithSAP: 1, subsegmentAlignment: true) do
|
||||||
audio_streams.each do |fmt|
|
audio_streams.each do |fmt|
|
||||||
mimetype = fmt["type"].split(";")[0]
|
|
||||||
codecs = fmt["type"].split("codecs=")[1].strip('"')
|
codecs = fmt["type"].split("codecs=")[1].strip('"')
|
||||||
fmt_type = mimetype.split("/")[0]
|
|
||||||
bandwidth = fmt["bitrate"]
|
bandwidth = fmt["bitrate"]
|
||||||
itag = fmt["itag"]
|
itag = fmt["itag"]
|
||||||
url = fmt["url"]
|
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,
|
xml.element("AdaptationSet", mimeType: "video/mp4", startWithSAP: 1, subsegmentAlignment: true,
|
||||||
scanType: "progressive") do
|
scanType: "progressive") do
|
||||||
video_streams.each do |fmt|
|
video_streams.each do |fmt|
|
||||||
mimetype = fmt["type"].split(";")
|
|
||||||
codecs = fmt["type"].split("codecs=")[1].strip('"')
|
codecs = fmt["type"].split("codecs=")[1].strip('"')
|
||||||
bandwidth = fmt["bitrate"]
|
bandwidth = fmt["bitrate"]
|
||||||
itag = fmt["itag"]
|
itag = fmt["itag"]
|
||||||
|
Loading…
Reference in New Issue
Block a user