From ce2d679f103de0057b5c627eecbfd19e48a8ee34 Mon Sep 17 00:00:00 2001 From: Castro0o Date: Sun, 2 Feb 2020 15:55:26 +0100 Subject: [PATCH] download_imgs.py without download limit --- download_imgs.py | 49 ++++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 25 deletions(-) diff --git a/download_imgs.py b/download_imgs.py index 0322fe7..712c75b 100644 --- a/download_imgs.py +++ b/download_imgs.py @@ -24,28 +24,27 @@ with open(os.path.join(wd, 'login.txt'), 'r') as login: # read login user & pwd print(site) -for n , img in enumerate(site.allimages()): - if n < 3: - print(img) - # print(img.__dict__) # info contained in each img object - # important img info to dictionary - img_dict = { - 'name': img.name, - 'filename': img.page_title, - 'timestamp': img.imageinfo['timestamp'], - 'url': img.imageinfo['url'], - 'urldesc': img.imageinfo['descriptionshorturl'], - } - pprint(img_dict) - - # location of image storage - img_fn = os.path.join(imgdir, img_dict['filename']) - # function updates images.json and returns whether the img needs to be downloaded or not - download = update_json(imgsjson_fn, img_dict, img_fn) - - # image download - if download is True: - print('DOWNLOADING:', img_fn) - with open(img_fn, 'wb') as img_file: - img.download(destination=img_file) - print('\n') +for img in site.allimages(): + print(img) + # print(img.__dict__) # info contained in each img object + # important img info to dictionary + img_dict = { + 'name': img.name, + 'filename': img.page_title, + 'timestamp': img.imageinfo['timestamp'], + 'url': img.imageinfo['url'], + 'urldesc': img.imageinfo['descriptionshorturl'], + } + pprint(img_dict) + + # location of image storage + img_fn = os.path.join(imgdir, img_dict['filename']) + # function updates images.json and returns whether the img needs to be downloaded or not + download = update_json(imgsjson_fn, img_dict, img_fn) + + # image download + if download is True: + print('DOWNLOADING:', img_fn) + with open(img_fn, 'wb') as img_file: + img.download(destination=img_file) + print('\n')