Improve robustness in case of bad packets.

This commit is contained in:
Frédéric Tronel
2024-06-02 15:13:28 +02:00
parent 3e8f868d87
commit f5393cda3b

View File

@@ -277,11 +277,12 @@ def downloadMovie(url, outputFileName):
output.write(chunk) output.write(chunk)
if nbiters == 1000: if nbiters == 1000:
lastTS = getLastTSFromFD(outputFD) lastTS = getLastTSFromFD(outputFD)
delta = lastTS-initialTS if lastTS != None:
ratio = delta/total delta = lastTS-initialTS
length = fstat(outputFD).st_size ratio = delta/total
estimatedLength = ceil(length/ratio) length = fstat(outputFD).st_size
pb.total = estimatedLength estimatedLength = ceil(length/ratio)
pb.total = estimatedLength
lseek(outputFD, 0, SEEK_END) lseek(outputFD, 0, SEEK_END)
nbiters = 0 nbiters = 0
pb.update(len(chunk)) pb.update(len(chunk))