download_imgs.py without download limit

andre
Castro0o 5 years ago
parent 183dfcf283
commit ce2d679f10

@ -24,28 +24,27 @@ with open(os.path.join(wd, 'login.txt'), 'r') as login: # read login user & pwd
print(site) print(site)
for n , img in enumerate(site.allimages()): for img in site.allimages():
if n < 3: print(img)
print(img) # print(img.__dict__) # info contained in each img object
# print(img.__dict__) # info contained in each img object # important img info to dictionary
# important img info to dictionary img_dict = {
img_dict = { 'name': img.name,
'name': img.name, 'filename': img.page_title,
'filename': img.page_title, 'timestamp': img.imageinfo['timestamp'],
'timestamp': img.imageinfo['timestamp'], 'url': img.imageinfo['url'],
'url': img.imageinfo['url'], 'urldesc': img.imageinfo['descriptionshorturl'],
'urldesc': img.imageinfo['descriptionshorturl'], }
} pprint(img_dict)
pprint(img_dict)
# location of image storage
# location of image storage img_fn = os.path.join(imgdir, img_dict['filename'])
img_fn = os.path.join(imgdir, img_dict['filename']) # function updates images.json and returns whether the img needs to be downloaded or not
# function updates images.json and returns whether the img needs to be downloaded or not download = update_json(imgsjson_fn, img_dict, img_fn)
download = update_json(imgsjson_fn, img_dict, img_fn)
# image download
# image download if download is True:
if download is True: print('DOWNLOADING:', img_fn)
print('DOWNLOADING:', img_fn) with open(img_fn, 'wb') as img_file:
with open(img_fn, 'wb') as img_file: img.download(destination=img_file)
img.download(destination=img_file) print('\n')
print('\n')

Loading…
Cancel
Save