mirror of
https://github.com/RicterZ/nhentai.git
synced 2025-04-20 11:01:17 +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
|
continue
|
||||||
|
|
||||||
if options.generate_metadata:
|
if options.generate_metadata:
|
||||||
table = doujinshi.table
|
generate_metadata_file(options.output_dir, doujinshi)
|
||||||
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
|
|
||||||
|
|
||||||
if options.is_save_download_history:
|
if options.is_save_download_history:
|
||||||
with DB() as db:
|
with DB() as db:
|
||||||
db.add_one(doujinshi.id)
|
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'])
|
generate_html(options.output_dir, doujinshi, template=constant.CONFIG['template'])
|
||||||
|
|
||||||
if options.is_cbz:
|
if options.is_cbz:
|
||||||
|
@ -293,11 +293,9 @@ def paging(page_string):
|
|||||||
return page_list
|
return page_list
|
||||||
|
|
||||||
|
|
||||||
def generate_metadata_file(output_dir, table, doujinshi_obj=None):
|
def generate_metadata_file(output_dir, doujinshi_obj):
|
||||||
logger.info('Writing Metadata Info')
|
|
||||||
|
|
||||||
doujinshi_dir, filename = parse_doujinshi_obj(output_dir, doujinshi_obj)
|
info_txt_path = os.path.join(output_dir, doujinshi_obj.filename, 'info.txt')
|
||||||
info_txt_path = os.path.join(doujinshi_dir, 'info.txt')
|
|
||||||
|
|
||||||
f = open(info_txt_path, 'w', encoding='utf-8')
|
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)):
|
for i in range(len(fields)):
|
||||||
f.write(f'{fields[i]}: ')
|
f.write(f'{fields[i]}: ')
|
||||||
if fields[i] in special_fields:
|
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.write('\n')
|
||||||
|
|
||||||
f.close()
|
f.close()
|
||||||
|
logger.log(16, f'Metadata Info has been written to "{info_txt_path}"')
|
||||||
return True
|
|
||||||
|
|
||||||
|
|
||||||
class DB(object):
|
class DB(object):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user