From f5393cda3b9bbad402d6b79d6228a8c166a54676 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Tronel?= Date: Sun, 2 Jun 2024 15:13:28 +0200 Subject: [PATCH] Improve robustness in case of bad packets. --- panasonic.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/panasonic.py b/panasonic.py index ce2973d..6e235a4 100755 --- a/panasonic.py +++ b/panasonic.py @@ -277,11 +277,12 @@ def downloadMovie(url, outputFileName): output.write(chunk) if nbiters == 1000: lastTS = getLastTSFromFD(outputFD) - delta = lastTS-initialTS - ratio = delta/total - length = fstat(outputFD).st_size - estimatedLength = ceil(length/ratio) - pb.total = estimatedLength + if lastTS != None: + delta = lastTS-initialTS + ratio = delta/total + length = fstat(outputFD).st_size + estimatedLength = ceil(length/ratio) + pb.total = estimatedLength lseek(outputFD, 0, SEEK_END) nbiters = 0 pb.update(len(chunk))