mirror of
https://github.com/RicterZ/nhentai.git
synced 2025-04-18 18:01:24 +02:00
generate_metadata_file no need to use parse_doujinshi_obj
This commit is contained in:
parent
cbf9448ed9
commit
984ae4262c
@ -94,19 +94,13 @@ def main():
|
||||
continue
|
||||
|
||||
if options.generate_metadata:
|
||||
table = doujinshi.table
|
||||
result = generate_metadata_file(options.output_dir, table, doujinshi)
|
||||
# Already downloaded; continue on with the other doujins.
|
||||
# if cbz / pdf file exists, skip the download process?
|
||||
# regenerate but not re-download?
|
||||
if not result:
|
||||
continue
|
||||
generate_metadata_file(options.output_dir, doujinshi)
|
||||
|
||||
if options.is_save_download_history:
|
||||
with DB() as db:
|
||||
db.add_one(doujinshi.id)
|
||||
|
||||
if not options.is_nohtml and not options.is_cbz and not options.is_pdf:
|
||||
if not options.is_nohtml:
|
||||
generate_html(options.output_dir, doujinshi, template=constant.CONFIG['template'])
|
||||
|
||||
if options.is_cbz:
|
||||
|
@ -293,11 +293,9 @@ def paging(page_string):
|
||||
return page_list
|
||||
|
||||
|
||||
def generate_metadata_file(output_dir, table, doujinshi_obj=None):
|
||||
logger.info('Writing Metadata Info')
|
||||
def generate_metadata_file(output_dir, doujinshi_obj):
|
||||
|
||||
doujinshi_dir, filename = parse_doujinshi_obj(output_dir, doujinshi_obj)
|
||||
info_txt_path = os.path.join(doujinshi_dir, 'info.txt')
|
||||
info_txt_path = os.path.join(output_dir, doujinshi_obj.filename, 'info.txt')
|
||||
|
||||
f = open(info_txt_path, 'w', encoding='utf-8')
|
||||
|
||||
@ -311,12 +309,11 @@ def generate_metadata_file(output_dir, table, doujinshi_obj=None):
|
||||
for i in range(len(fields)):
|
||||
f.write(f'{fields[i]}: ')
|
||||
if fields[i] in special_fields:
|
||||
f.write(str(table[special_fields.index(fields[i])][1]))
|
||||
f.write(str(doujinshi_obj.table[special_fields.index(fields[i])][1]))
|
||||
f.write('\n')
|
||||
|
||||
f.close()
|
||||
|
||||
return True
|
||||
logger.log(16, f'Metadata Info has been written to "{info_txt_path}"')
|
||||
|
||||
|
||||
class DB(object):
|
||||
|
Loading…
x
Reference in New Issue
Block a user