mirror of
https://github.com/RicterZ/nhentai.git
synced 2025-07-01 16:09:28 +02:00
Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
17bc33c6cb | |||
09bb8460f6 | |||
eb5b93d654 | |||
cb6cf6df1a |
1
.gitignore
vendored
1
.gitignore
vendored
@ -8,3 +8,4 @@ dist/
|
||||
output/
|
||||
venv/
|
||||
.vscode/
|
||||
test-output
|
@ -94,6 +94,7 @@ def main():
|
||||
doujinshi.download()
|
||||
else:
|
||||
logger.info(f'Skip download doujinshi because a PDF/CBZ file exists of doujinshi {doujinshi.name}')
|
||||
continue
|
||||
|
||||
if options.generate_metadata:
|
||||
generate_metadata_file(options.output_dir, doujinshi)
|
||||
@ -106,10 +107,10 @@ def main():
|
||||
generate_html(options.output_dir, doujinshi, template=constant.CONFIG['template'])
|
||||
|
||||
if options.is_cbz:
|
||||
generate_doc('cbz', options.output_dir, doujinshi, options.rm_origin_dir)
|
||||
generate_doc('cbz', options.output_dir, doujinshi, options.regenerate)
|
||||
|
||||
if options.is_pdf:
|
||||
generate_doc('pdf', options.output_dir, doujinshi, options.rm_origin_dir)
|
||||
generate_doc('pdf', options.output_dir, doujinshi, options.regenerate)
|
||||
|
||||
if options.move_to_folder:
|
||||
if options.is_cbz:
|
||||
|
@ -75,26 +75,27 @@ class Doujinshi(object):
|
||||
def check_if_need_download(self, options):
|
||||
base_path = os.path.join(self.downloader.path, self.filename)
|
||||
|
||||
# doujinshi directory is not exist, we need to download definitely
|
||||
if not (os.path.exists(base_path) and os.path.isdir(base_path)):
|
||||
return True
|
||||
|
||||
# regenerate, we need to re-download from nhentai
|
||||
# regenerate, re-download
|
||||
if options.regenerate:
|
||||
return True
|
||||
|
||||
# pdf or cbz file exists, skip re-download
|
||||
# doujinshi directory may not exist b/c of --rm-origin-dir option set.
|
||||
# user should pass --regenerate option to get back origin dir.
|
||||
ret_pdf = ret_cbz = None
|
||||
if options.is_pdf:
|
||||
file_ext = 'pdf'
|
||||
elif options.is_cbz:
|
||||
file_ext = 'cbz'
|
||||
else:
|
||||
# re-download
|
||||
return True
|
||||
ret_pdf = os.path.exists(f'{base_path}.pdf') or os.path.exists(f'{base_path}/{self.filename}.pdf')
|
||||
|
||||
# pdf or cbz file exists, we needn't to re-download it
|
||||
if os.path.exists(f'{base_path}.{file_ext}') or os.path.exists(f'{base_path}/{self.filename}.{file_ext}'):
|
||||
if options.is_cbz:
|
||||
ret_cbz = os.path.exists(f'{base_path}.cbz') or os.path.exists(f'{base_path}/{self.filename}.cbz')
|
||||
|
||||
if all(filter(lambda s: s is not None, [ret_cbz, ret_pdf])):
|
||||
return False
|
||||
|
||||
# doujinshi directory doesn't exist, re-download
|
||||
if not (os.path.exists(base_path) and os.path.isdir(base_path)):
|
||||
return True
|
||||
|
||||
# fallback
|
||||
return True
|
||||
|
||||
|
Reference in New Issue
Block a user