summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOmar Roth <omarroth@protonmail.com>2019-07-09 10:08:00 -0500
committerOmar Roth <omarroth@protonmail.com>2019-07-09 10:08:27 -0500
commitaa3c1d930ba4c078f8db42e984b59e961f790c9e (patch)
tree1c161b3ecbcabed52109c05784f34ba0b0a6592a
parent99b0b4f5b8d912afe62e88301628ffc7540c5f83 (diff)
downloadinvidious-aa3c1d930ba4c078f8db42e984b59e961f790c9e.tar.gz
invidious-aa3c1d930ba4c078f8db42e984b59e961f790c9e.tar.bz2
invidious-aa3c1d930ba4c078f8db42e984b59e961f790c9e.zip
Remove empty representations from dash manifests
-rw-r--r--src/invidious.cr14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/invidious.cr b/src/invidious.cr
index 17f30e21..ba7e65b5 100644
--- a/src/invidious.cr
+++ b/src/invidious.cr
@@ -4401,8 +4401,13 @@ get "/api/manifest/dash/id/:id" do |env|
i = 0
{"audio/mp4", "audio/webm"}.each do |mime_type|
+ mime_streams = audio_streams.select { |stream| stream["type"].starts_with? mime_type }
+ if mime_streams.empty?
+ next
+ end
+
xml.element("AdaptationSet", id: i, mimeType: mime_type, startWithSAP: 1, subsegmentAlignment: true) do
- audio_streams.select { |stream| stream["type"].starts_with? mime_type }.each do |fmt|
+ mime_streams.each do |fmt|
codecs = fmt["type"].split("codecs=")[1].strip('"')
bandwidth = fmt["bitrate"].to_i * 1000
itag = fmt["itag"]
@@ -4423,9 +4428,14 @@ get "/api/manifest/dash/id/:id" do |env|
end
{"video/mp4", "video/webm"}.each do |mime_type|
+ mime_streams = video_streams.select { |stream| stream["type"].starts_with? mime_type }
+ if mime_streams.empty?
+ next
+ end
+
heights = [] of Int32
xml.element("AdaptationSet", id: i, mimeType: mime_type, startWithSAP: 1, subsegmentAlignment: true, scanType: "progressive") do
- video_streams.select { |stream| stream["type"].starts_with? mime_type }.each do |fmt|
+ mime_streams.each do |fmt|
codecs = fmt["type"].split("codecs=")[1].strip('"')
bandwidth = fmt["bitrate"]
itag = fmt["itag"]