diff options
| author | Omar Roth <omarroth@hotmail.com> | 2018-09-15 08:56:47 -0500 |
|---|---|---|
| committer | Omar Roth <omarroth@hotmail.com> | 2018-09-15 08:56:47 -0500 |
| commit | d2bbf9d33c04e940e661492a03a6e0e5c5ac088d (patch) | |
| tree | bd8ff14136b988dec1afa3164fec1b3a42772428 | |
| parent | 3ccee120d3f0dca98eb9ecdd2897a4306ac4354c (diff) | |
| download | invidious-d2bbf9d33c04e940e661492a03a6e0e5c5ac088d.tar.gz invidious-d2bbf9d33c04e940e661492a03a6e0e5c5ac088d.tar.bz2 invidious-d2bbf9d33c04e940e661492a03a6e0e5c5ac088d.zip | |
Fix dash parsing for video info
| -rw-r--r-- | src/invidious/videos.cr | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/src/invidious/videos.cr b/src/invidious/videos.cr index 1359a999..4f07a76d 100644 --- a/src/invidious/videos.cr +++ b/src/invidious/videos.cr @@ -278,20 +278,22 @@ class Video clen = url.match(/clen\/(?<clen>\d+)/).try &.["clen"] clen ||= "0" - lmt = url.match(/lmt\/(?<lmt>\d+)/).not_nil!["lmt"] + lmt = url.match(/lmt\/(?<lmt>\d+)/).try &.["lmt"] + lmt ||= "#{((Time.now + 1.hour).epoch_f.to_f64 * 1000000).to_i64}" segment_list = representation.xpath_node(%q(.//segmentlist)).not_nil! - init = segment_list.xpath_node(%q(.//initialization)).not_nil!["sourceurl"] - index = segment_list.xpath_node(%q(.//segmenturl)).not_nil!["media"] + init = segment_list.xpath_node(%q(.//initialization)) # TODO: Replace with sane defaults when byteranges are absent - if init.starts_with? "sq" - init = "0-0" - index = "1-1" - else - init = init.lchop("range/") + if init + init = init["sourceurl"].lchop("range/") + + index = segment_list.xpath_node(%q(.//segmenturl)).not_nil!["media"] index = index.lchop("range/") index = "#{init.split("-")[1].to_i + 1}-#{index.split("-")[0].to_i}" + else + init = "0-0" + index = "1-1" end params = { |
