Python Telethon, how to resume a download media
Solution 1:
iter_download
is the correct way, however, you need to manually specify the resume offset (and you should open the file in append mode):
import os
file = 'file.rar'
try:
offset = os.path.getsize(file)
except OSError:
offset = 0
with open(file, 'ab') as fd:
# ^ append
async for chunk in client.iter_download(dialog.media, offset=offset):
# ^~~~~~~~~~~~~ resume from offset
fd.write(chunk)