|
|
|
@ -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')
|
|
|
|
|