mirror of https://github.com/iv-org/invidious.git
Fix chunking for livestream segments
This commit is contained in:
parent
28df6881a7
commit
8033d1ca6d
|
@ -4651,6 +4651,7 @@ get "/videoplayback" do |env|
|
|||
chunk_end = chunk_start + HTTP_CHUNK_SIZE - 1
|
||||
end
|
||||
|
||||
# TODO: Record bytes written so we can restart after a chunk fails
|
||||
while true
|
||||
if !range_end && content_length
|
||||
range_end = content_length
|
||||
|
@ -4700,6 +4701,7 @@ get "/videoplayback" do |env|
|
|||
env.response.headers["Content-Disposition"] = "attachment; filename=\"#{URI.escape(title)}\"; filename*=UTF-8''#{URI.escape(title)}"
|
||||
end
|
||||
|
||||
if !response.headers.includes_word?("Transfer-Encoding", "chunked")
|
||||
content_length = response.headers["Content-Range"].split("/")[-1].to_i64
|
||||
if env.request.headers["Range"]?
|
||||
env.response.headers["Content-Range"] = "bytes #{range_start}-#{range_end || (content_length - 1)}/#{content_length}"
|
||||
|
@ -4708,9 +4710,15 @@ get "/videoplayback" do |env|
|
|||
env.response.content_length = content_length
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
proxy_file(response, env)
|
||||
end
|
||||
|
||||
# For livestream segments, break after first chunk
|
||||
if url.includes? "&file=seg.ts"
|
||||
break
|
||||
end
|
||||
rescue ex
|
||||
if ex.message != "Error reading socket: Connection reset by peer"
|
||||
break
|
||||
|
|
Loading…
Reference in New Issue