Add the option to perform a dry-run and only download meta-data / generate file structure

This commit is contained in:
Lieuwe Leene 2021-05-16 19:44:01 +02:00
parent 8cd4b948e7
commit 2cf4e6718e
No known key found for this signature in database
GPG Key ID: FD6DB59EC3B879CD
3 changed files with 18 additions and 5 deletions

View File

@ -89,6 +89,7 @@ def cmd_parser():
parser.add_option('--file', '-f', type='string', dest='file', action='store', help='read gallery IDs from file.')
parser.add_option('--format', type='string', dest='name_format', action='store',
help='format the saved folder name', default='[%i][%a][%t]')
parser.add_option('--dry-run', '-r', action='store_true', dest='dryrun', help='Dry run, skip file download.')
# generate options
parser.add_option('--html', dest='html_viewer', action='store_true',
@ -214,4 +215,8 @@ def cmd_parser():
logger.critical('Maximum number of used threads is 15')
exit(1)
if args.dryrun and (args.is_cbz or args.is_pdf):
logger.critical('Cannot generate PDF or CBZ during dry-run')
exit(1)
return args

View File

@ -89,9 +89,10 @@ def main():
timeout=options.timeout, delay=options.delay)
for doujinshi in doujinshi_list:
if not options.dryrun:
doujinshi.downloader = downloader
doujinshi.download()
if options.is_save_download_history:
with DB() as db:
db.add_one(doujinshi.id)

View File

@ -70,6 +70,13 @@ def generate_html(output_dir='.', doujinshi_obj=None, template='default'):
else:
doujinshi_dir = '.'
if not os.path.exists(doujinshi_dir):
logger.warning('Path \'{0}\' does not exist, creating.'.format(doujinshi_dir))
try:
os.makedirs(doujinshi_dir)
except EnvironmentError as e:
logger.critical('{0}'.format(str(e)))
file_list = os.listdir(doujinshi_dir)
file_list.sort()