santosderek / Imgur-To-Folder

Download Imgur albums and images to desired folder
Other
80 stars 9 forks source link

Save timestamps #15

Open Doliman100 opened 3 years ago

Doliman100 commented 3 years ago

Imgur API returns image upload time. It can be used as the last modified time of the file. You can add an option like --timestamps for it. To do this, you need to add a line to this. Where datetime is image['datetime'] located in download_account_images, passed to parse_id.

with open(os.path.join(path, filename), 'wb') as image_file:
    req.raw.decode_content = True
    shutil.copyfileobj(req.raw, image_file)
os.utime(image_file.name, (datetime, datetime))