mirror of
https://github.com/iv-org/invidious.git
synced 2024-11-30 02:32:56 +05:30
Partially fix generation of DASH manifests
This commit is contained in:
parent
373c5378b2
commit
47a284e378
@ -2555,19 +2555,8 @@ get "/api/manifest/dash/id/:id" do |env|
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
video_streams = adaptive_fmts.compact_map { |s| s["type"].starts_with?("video") ? s : nil }
|
video_streams = video.video_streams(adaptive_fmts).select { |stream| stream["type"].starts_with? "video/mp4" }
|
||||||
audio_streams = adaptive_fmts.compact_map { |s| s["type"].starts_with?("audio") ? s : nil }
|
audio_streams = video.audio_streams(adaptive_fmts).select { |stream| stream["type"].starts_with? "audio/mp4" }
|
||||||
|
|
||||||
audio_streams.sort_by! { |s| s["bitrate"].to_i }.reverse!
|
|
||||||
audio_streams.each do |fmt|
|
|
||||||
fmt["bitrate"] = (fmt["bitrate"].to_f64/1000).to_i.to_s
|
|
||||||
end
|
|
||||||
|
|
||||||
(audio_streams + video_streams).each do |fmt|
|
|
||||||
fmt["url"] = fmt["url"].gsub('?', '/')
|
|
||||||
fmt["url"] = fmt["url"].gsub('&', '/')
|
|
||||||
fmt["url"] = fmt["url"].gsub('=', '/')
|
|
||||||
end
|
|
||||||
|
|
||||||
manifest = XML.build(indent: " ", encoding: "UTF-8") do |xml|
|
manifest = XML.build(indent: " ", encoding: "UTF-8") do |xml|
|
||||||
xml.element("MPD", "xmlns:xsi": "http://www.w3.org/2001/XMLSchema-instance", "xmlns": "urn:mpeg:DASH:schema:MPD:2011",
|
xml.element("MPD", "xmlns:xsi": "http://www.w3.org/2001/XMLSchema-instance", "xmlns": "urn:mpeg:DASH:schema:MPD:2011",
|
||||||
@ -2578,10 +2567,10 @@ get "/api/manifest/dash/id/:id" do |env|
|
|||||||
xml.element("AdaptationSet", id: 0, mimeType: "audio/mp4", subsegmentAlignment: true) do
|
xml.element("AdaptationSet", id: 0, mimeType: "audio/mp4", subsegmentAlignment: true) do
|
||||||
xml.element("Role", schemeIdUri: "urn:mpeg:DASH:role:2011", value: "main")
|
xml.element("Role", schemeIdUri: "urn:mpeg:DASH:role:2011", value: "main")
|
||||||
audio_streams.each do |fmt|
|
audio_streams.each do |fmt|
|
||||||
mimetype, codecs = fmt["type"].split(";")
|
mimetype = fmt["type"].split(";")[0]
|
||||||
codecs = codecs[9..-2]
|
codecs = fmt["type"].split("codecs=")[1].strip('"')
|
||||||
fmt_type = mimetype.split("/")[0]
|
fmt_type = mimetype.split("/")[0]
|
||||||
bandwidth = fmt["bitrate"]
|
bandwidth = fmt["clen"]
|
||||||
itag = fmt["itag"]
|
itag = fmt["itag"]
|
||||||
url = fmt["url"]
|
url = fmt["url"]
|
||||||
|
|
||||||
@ -2599,9 +2588,9 @@ get "/api/manifest/dash/id/:id" do |env|
|
|||||||
xml.element("AdaptationSet", id: 1, mimeType: "video/mp4", subsegmentAlignment: true) do
|
xml.element("AdaptationSet", id: 1, mimeType: "video/mp4", subsegmentAlignment: true) do
|
||||||
xml.element("Role", schemeIdUri: "urn:mpeg:DASH:role:2011", value: "main")
|
xml.element("Role", schemeIdUri: "urn:mpeg:DASH:role:2011", value: "main")
|
||||||
video_streams.each do |fmt|
|
video_streams.each do |fmt|
|
||||||
mimetype, codecs = fmt["type"].split(";")
|
mimetype = fmt["type"].split(";")
|
||||||
codecs = codecs[9..-2]
|
codecs = fmt["type"].split("codecs=")[1].strip('"')
|
||||||
bandwidth = fmt["bitrate"]
|
bandwidth = fmt["clen"]
|
||||||
itag = fmt["itag"]
|
itag = fmt["itag"]
|
||||||
url = fmt["url"]
|
url = fmt["url"]
|
||||||
height, width = fmt["size"].split("x")
|
height, width = fmt["size"].split("x")
|
||||||
|
Loading…
Reference in New Issue
Block a user