|
|
|
@ -50,6 +50,7 @@ config = {
|
|
|
|
|
|
|
|
|
|
'output': './images/downloaded/', # directory to save your files
|
|
|
|
|
'cache': './data/cache.json', # JSON file of cached tags, will speed up processing when used for the renamer script
|
|
|
|
|
'images': './images/cache/', # total cache of images, will copy if file exists here
|
|
|
|
|
|
|
|
|
|
'limit': 320, # how many posts to pull in one go
|
|
|
|
|
|
|
|
|
@ -127,6 +128,11 @@ def parse():
|
|
|
|
|
if os.path.exists(f"{config['output']}{post['filename']}"):
|
|
|
|
|
print(f"Skipping existing file: {booru['urls']['posts']}{post['id']}")
|
|
|
|
|
continue
|
|
|
|
|
|
|
|
|
|
if os.path.exists(f"{config['images']}{post['filename']}"):
|
|
|
|
|
print(f"Copying cached file: {booru['urls']['posts']}{post['id']}")
|
|
|
|
|
shutil.copy(os.path.join(config['images'], post['filename']), os.path.join(config['output'], post['filename']))
|
|
|
|
|
continue
|
|
|
|
|
|
|
|
|
|
if post['url'] is None:
|
|
|
|
|
print(f"Skipping file that requires logging in: {booru['urls']['posts']}{post['id']}")
|
|
|
|
@ -151,6 +157,9 @@ def parse():
|
|
|
|
|
|
|
|
|
|
if not config['skipSave']:
|
|
|
|
|
urllib.request.urlretrieve(post['url'], f"{config['output']}{post['filename']}")
|
|
|
|
|
if os.path.exists(f"{config['images']}"):
|
|
|
|
|
shutil.copy(os.path.join(config['output'], post['filename']), os.path.join(config['images'], post['filename']))
|
|
|
|
|
|
|
|
|
|
print(f"Downloaded : {booru['urls']['posts']}{post['id']}")
|
|
|
|
|
|
|
|
|
|
if config['rateLimit']:
|
|
|
|
|