summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorOmar Roth <omarroth@protonmail.com>2019-05-30 15:39:02 -0500
committerOmar Roth <omarroth@protonmail.com>2019-05-30 19:00:30 -0500
commitac957db6d1f54f730f2ef08bc915fa52265e463e (patch)
tree7b3685da6763869c5ba1ccd5027eda165a334342 /src
parent64464f23aed3b7b3331db686c85926c72f0ef7e5 (diff)
downloadinvidious-ac957db6d1f54f730f2ef08bc915fa52265e463e.tar.gz
invidious-ac957db6d1f54f730f2ef08bc915fa52265e463e.tar.bz2
invidious-ac957db6d1f54f730f2ef08bc915fa52265e463e.zip
Provide dash qualities as reported by YouTube player
Diffstat (limited to 'src')
-rw-r--r--src/invidious.cr5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/invidious.cr b/src/invidious.cr
index dea32a39..01b1063a 100644
--- a/src/invidious.cr
+++ b/src/invidious.cr
@@ -4751,7 +4751,10 @@ get "/api/manifest/dash/id/:id" do |env|
bandwidth = fmt["bitrate"]
itag = fmt["itag"]
url = fmt["url"]
- width, height = fmt["size"].split("x")
+ width, height = fmt["size"].split("x").map { |i| i.to_i }
+
+ # Resolutions reported by YouTube player (may not accurately reflect source)
+ height = [4320, 2160, 1440, 1080, 720, 480, 360, 240, 144].sort_by { |i| (height - i).abs }[0]
xml.element("Representation", id: itag, codecs: codecs, width: width, height: height,
startWithSAP: "1", maxPlayoutRate: "1",