def run(self):
file_size_dl = 0
response = requests.get(self.url, stream=True)
data_chunks = response.iter_content(chunk_size=1024)
if not os.path.exists('bin'):
os.mkdir('bin')
with open('bin/ffmpeg.7z', 'wb') as f:
while not self.is_aborted():
try:
chunk = next(data_chunks)
file_size_dl += len(chunk)
logger.info("FFmpeg downloader: Downloaded chunk: {chunk}".format(chunk=len(chunk)))
logger.info("FFmpeg downloader: Total downloaded so far: {total}".format(total=file_size_dl))
logger.info("FFmpeg downloader: Remaining: {r}".format(r=self.file_size - file_size_dl))
if chunk:
f.write(chunk)
f.flush()
# This makes the download super slow.
# os.fsync(f.fileno())
wx.CallAfter(self.parent.ff_update, message=file_size_dl)
except StopIteration:
wx.CallAfter(self.parent.ff_complete)
break
评论列表
文章目录