-
This commit is contained in:
parent
2361f3024d
commit
8ebcd48eaf
1 changed files with 5 additions and 0 deletions
|
@ -55,11 +55,16 @@ for item in response.json()['response']['publishedfiledetails']:
|
||||||
response = session.get(item['file_url'], stream=True)
|
response = session.get(item['file_url'], stream=True)
|
||||||
response.raise_for_status()
|
response.raise_for_status()
|
||||||
|
|
||||||
|
# one chunk at a time
|
||||||
with open(target_path, 'wb') as file:
|
with open(target_path, 'wb') as file:
|
||||||
for chunk in response.iter_content(chunk_size=65_536):
|
for chunk in response.iter_content(chunk_size=65_536):
|
||||||
print('.', end='', flush=True)
|
print('.', end='', flush=True)
|
||||||
if chunk:
|
if chunk:
|
||||||
file.write(chunk)
|
file.write(chunk)
|
||||||
|
|
||||||
|
# update modify time
|
||||||
print(' done', flush=True)
|
print(' done', flush=True)
|
||||||
utime(target_path, (getatime(target_path), item['time_updated']))
|
utime(target_path, (getatime(target_path), item['time_updated']))
|
||||||
|
|
||||||
|
# close session
|
||||||
|
session.close()
|
||||||
|
|
Loading…
Reference in a new issue