Skip to content

Commit

Permalink
fix #363
Browse files Browse the repository at this point in the history
  • Loading branch information
RicterZ committed Dec 18, 2024
1 parent 7483b8f commit 3cae13e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion nhentai/doujinshi.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def __init__(self, name=None, pretty_name=None, id=None, favorite_counts=0, img_

self.table = [
['Parodies', self.info.parodies],
['Doujinshi', self.name],
['Title', self.name],
['Subtitle', self.info.subtitle],
['Date', self.info.date],
['Characters', self.info.characters],
Expand Down
1 change: 0 additions & 1 deletion nhentai/downloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import asyncio
import httpx
import urllib3.exceptions
import math

from urllib.parse import urlparse
from nhentai import constant
Expand Down
21 changes: 11 additions & 10 deletions nhentai/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
import os
import zipfile
import shutil
import copy

import httpx
import requests
import sqlite3
import urllib.parse
from typing import Optional, Tuple
from typing import Tuple
from requests.structures import CaseInsensitiveDict

from nhentai import constant
from nhentai.logger import logger
Expand Down Expand Up @@ -335,14 +335,15 @@ def generate_metadata_file(output_dir, doujinshi_obj):
'TRANSLATOR', 'PUBLISHER', 'DESCRIPTION', 'STATUS', 'CHAPTERS', 'PAGES',
'TAGS', 'TYPE', 'LANGUAGE', 'RELEASED', 'READING DIRECTION', 'CHARACTERS',
'SERIES', 'PARODY', 'URL']
special_fields = ['PARODY', 'TITLE', 'ORIGINAL TITLE', 'DATE', 'CHARACTERS', 'AUTHOR', 'GROUPS',
'LANGUAGE', 'TAGS', 'URL', 'PAGES']

for i in range(len(fields)):
f.write(f'{fields[i]}: ')
if fields[i] in special_fields:
f.write(str(doujinshi_obj.table[special_fields.index(fields[i])][1]))
f.write('\n')

temp_dict = CaseInsensitiveDict(dict(doujinshi_obj.table))
print(doujinshi_obj.info)
for i in fields:
v = temp_dict.get(i)
v = temp_dict.get(f'{i}s') if v is None else v
v = doujinshi_obj.info.get(i.lower(), None) if v is None else v
v = doujinshi_obj.info.get(f'{i.lower()}s', "Unknown") if v is None else v
f.write(f'{i}: {v}\n')

f.close()
logger.log(16, f'Metadata Info has been written to "{info_txt_path}"')
Expand Down

0 comments on commit 3cae13e

Please sign in to comment.