Fix dash parsing for video info

pull/186/head
Omar Roth 6 years ago
parent 3ccee120d3
commit d2bbf9d33c

@ -278,20 +278,22 @@ class Video
clen = url.match(/clen\/(?<clen>\d+)/).try &.["clen"] clen = url.match(/clen\/(?<clen>\d+)/).try &.["clen"]
clen ||= "0" 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! segment_list = representation.xpath_node(%q(.//segmentlist)).not_nil!
init = segment_list.xpath_node(%q(.//initialization)).not_nil!["sourceurl"] init = segment_list.xpath_node(%q(.//initialization))
index = segment_list.xpath_node(%q(.//segmenturl)).not_nil!["media"]
# TODO: Replace with sane defaults when byteranges are absent # TODO: Replace with sane defaults when byteranges are absent
if init.starts_with? "sq" if init
init = "0-0" init = init["sourceurl"].lchop("range/")
index = "1-1"
else index = segment_list.xpath_node(%q(.//segmenturl)).not_nil!["media"]
init = init.lchop("range/")
index = index.lchop("range/") index = index.lchop("range/")
index = "#{init.split("-")[1].to_i + 1}-#{index.split("-")[0].to_i}" index = "#{init.split("-")[1].to_i + 1}-#{index.split("-")[0].to_i}"
else
init = "0-0"
index = "1-1"
end end
params = { params = {

Loading…
Cancel
Save