mirror of
https://github.com/RicterZ/nhentai.git
synced 2025-07-01 16:09:28 +02:00
Compare commits
7 Commits
Author | SHA1 | Date | |
---|---|---|---|
a0f6e3f857 | |||
413657e076 | |||
4ecffaff55 | |||
457f12d40d | |||
0b80458c6f | |||
499081a9cd | |||
53aa04af1e |
@ -141,9 +141,7 @@ Supported doujinshi folder formatter:
|
|||||||
- %t: Doujinshi name
|
- %t: Doujinshi name
|
||||||
- %s: Doujinshi subtitle (translated name)
|
- %s: Doujinshi subtitle (translated name)
|
||||||
- %a: Doujinshi authors' name
|
- %a: Doujinshi authors' name
|
||||||
- %g: Doujinshi groups name
|
|
||||||
- %p: Doujinshi pretty name
|
- %p: Doujinshi pretty name
|
||||||
- %ag: Doujinshi authors name or groups name
|
|
||||||
|
|
||||||
|
|
||||||
Other options:
|
Other options:
|
||||||
|
@ -73,15 +73,17 @@ def cmd_parser():
|
|||||||
help='search doujinshi by keyword')
|
help='search doujinshi by keyword')
|
||||||
parser.add_option('--favorites', '-F', action='store_true', dest='favorites',
|
parser.add_option('--favorites', '-F', action='store_true', dest='favorites',
|
||||||
help='list or download your favorites')
|
help='list or download your favorites')
|
||||||
|
parser.add_option('--artist', '-a', action='store', dest='artist',
|
||||||
|
help='list doujinshi by artist name')
|
||||||
|
|
||||||
# page options
|
# page options
|
||||||
parser.add_option('--page-all', dest='page_all', action='store_true', default=False,
|
parser.add_option('--page-all', dest='page_all', action='store_true', default=False,
|
||||||
help='all search results')
|
help='all search results')
|
||||||
parser.add_option('--page', '--page-range', type='string', dest='page', action='store', default='1',
|
parser.add_option('--page', '--page-range', type='string', dest='page', action='store', default='1',
|
||||||
help='page number of search results. e.g. 1,2-5,14')
|
help='page number of search results. e.g. 1,2-5,14')
|
||||||
parser.add_option('--sorting', '--sort', dest='sorting', action='store', default='popular',
|
parser.add_option('--sorting', '--sort', dest='sorting', action='store', default='popular-all',
|
||||||
help='sorting of doujinshi (recent / popular / popular-[today|week])',
|
help='sorting of doujinshi (recent / popular-all / popular-[today|week])',
|
||||||
choices=['recent', 'popular', 'popular-today', 'popular-week', 'date'])
|
choices=['recent', 'popular-all', 'popular-today', 'popular-week', 'date'])
|
||||||
|
|
||||||
# download options
|
# download options
|
||||||
parser.add_option('--output', '-o', type='string', dest='output_dir', action='store', default='./',
|
parser.add_option('--output', '-o', type='string', dest='output_dir', action='store', default='./',
|
||||||
@ -112,6 +114,8 @@ def cmd_parser():
|
|||||||
help='generate PDF file')
|
help='generate PDF file')
|
||||||
parser.add_option('--rm-origin-dir', dest='rm_origin_dir', action='store_true', default=False,
|
parser.add_option('--rm-origin-dir', dest='rm_origin_dir', action='store_true', default=False,
|
||||||
help='remove downloaded doujinshi dir when generated CBZ or PDF file')
|
help='remove downloaded doujinshi dir when generated CBZ or PDF file')
|
||||||
|
parser.add_option('--move-to-folder', dest='move_to_folder', action='store_true', default=False,
|
||||||
|
help='remove files in doujinshi dir then move new file to folder when generated CBZ or PDF file')
|
||||||
parser.add_option('--meta', dest='generate_metadata', action='store_true',
|
parser.add_option('--meta', dest='generate_metadata', action='store_true',
|
||||||
help='generate a metadata file in doujinshi format')
|
help='generate a metadata file in doujinshi format')
|
||||||
parser.add_option('--regenerate-cbz', dest='regenerate_cbz', action='store_true', default=False,
|
parser.add_option('--regenerate-cbz', dest='regenerate_cbz', action='store_true', default=False,
|
||||||
@ -209,12 +213,12 @@ def cmd_parser():
|
|||||||
_ = [i.strip() for i in f.readlines()]
|
_ = [i.strip() for i in f.readlines()]
|
||||||
args.id = set(int(i) for i in _ if i.isdigit())
|
args.id = set(int(i) for i in _ if i.isdigit())
|
||||||
|
|
||||||
if (args.is_download or args.is_show) and not args.id and not args.keyword and not args.favorites:
|
if (args.is_download or args.is_show) and not args.id and not args.keyword and not args.favorites and not args.artist:
|
||||||
logger.critical('Doujinshi id(s) are required for downloading')
|
logger.critical('Doujinshi id(s) are required for downloading')
|
||||||
parser.print_help()
|
parser.print_help()
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
if not args.keyword and not args.id and not args.favorites:
|
if not args.keyword and not args.id and not args.favorites and not args.artist:
|
||||||
parser.print_help()
|
parser.print_help()
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
@ -20,10 +20,9 @@ class DoujinshiInfo(dict):
|
|||||||
|
|
||||||
def __getattr__(self, item):
|
def __getattr__(self, item):
|
||||||
try:
|
try:
|
||||||
ret = dict.__getitem__(self, item)
|
return dict.__getitem__(self, item)
|
||||||
return ret if ret else 'Unknown'
|
|
||||||
except KeyError:
|
except KeyError:
|
||||||
return 'Unknown'
|
return ''
|
||||||
|
|
||||||
|
|
||||||
class Doujinshi(object):
|
class Doujinshi(object):
|
||||||
@ -39,12 +38,8 @@ class Doujinshi(object):
|
|||||||
self.url = f'{DETAIL_URL}/{self.id}'
|
self.url = f'{DETAIL_URL}/{self.id}'
|
||||||
self.info = DoujinshiInfo(**kwargs)
|
self.info = DoujinshiInfo(**kwargs)
|
||||||
|
|
||||||
ag_value = self.info.groups if self.info.artists == 'Unknown' else self.info.artists
|
|
||||||
name_format = name_format.replace('%ag', format_filename(ag_value))
|
|
||||||
|
|
||||||
name_format = name_format.replace('%i', format_filename(str(self.id)))
|
name_format = name_format.replace('%i', format_filename(str(self.id)))
|
||||||
name_format = name_format.replace('%a', format_filename(self.info.artists))
|
name_format = name_format.replace('%a', format_filename(self.info.artists))
|
||||||
name_format = name_format.replace('%g', format_filename(self.info.groups))
|
|
||||||
|
|
||||||
name_format = name_format.replace('%t', format_filename(self.name))
|
name_format = name_format.replace('%t', format_filename(self.name))
|
||||||
name_format = name_format.replace('%p', format_filename(self.pretty_name))
|
name_format = name_format.replace('%p', format_filename(self.pretty_name))
|
||||||
@ -52,16 +47,15 @@ class Doujinshi(object):
|
|||||||
self.filename = format_filename(name_format, 255, True)
|
self.filename = format_filename(name_format, 255, True)
|
||||||
|
|
||||||
self.table = [
|
self.table = [
|
||||||
['Parodies', self.info.parodies],
|
["Parodies", self.info.parodies],
|
||||||
['Doujinshi', self.name],
|
["Doujinshi", self.name],
|
||||||
['Subtitle', self.info.subtitle],
|
["Subtitle", self.info.subtitle],
|
||||||
['Characters', self.info.characters],
|
["Characters", self.info.characters],
|
||||||
['Authors', self.info.artists],
|
["Authors", self.info.artists],
|
||||||
['Groups', self.info.groups],
|
["Languages", self.info.languages],
|
||||||
['Languages', self.info.languages],
|
["Tags", self.info.tags],
|
||||||
['Tags', self.info.tags],
|
["URL", self.url],
|
||||||
['URL', self.url],
|
["Pages", self.pages],
|
||||||
['Pages', self.pages],
|
|
||||||
]
|
]
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
|
@ -123,7 +123,6 @@ class Downloader(Singleton):
|
|||||||
logger.warning(f'CBZ file "{folder}.cbz" exists, ignored download request')
|
logger.warning(f'CBZ file "{folder}.cbz" exists, ignored download request')
|
||||||
return
|
return
|
||||||
|
|
||||||
logger.info(f'Doujinshi will be saved at "{folder}"')
|
|
||||||
if not os.path.exists(folder):
|
if not os.path.exists(folder):
|
||||||
try:
|
try:
|
||||||
os.makedirs(folder)
|
os.makedirs(folder)
|
||||||
|
@ -166,6 +166,9 @@ def generate_main_html(output_dir='./'):
|
|||||||
def generate_cbz(output_dir='.', doujinshi_obj=None, rm_origin_dir=False, write_comic_info=True):
|
def generate_cbz(output_dir='.', doujinshi_obj=None, rm_origin_dir=False, write_comic_info=True):
|
||||||
if doujinshi_obj is not None:
|
if doujinshi_obj is not None:
|
||||||
doujinshi_dir = os.path.join(output_dir, doujinshi_obj.filename)
|
doujinshi_dir = os.path.join(output_dir, doujinshi_obj.filename)
|
||||||
|
if os.path.exists(doujinshi_dir+".cbz"):
|
||||||
|
logger.warning(f'Comic Book CBZ file exists, skip "{doujinshi_dir}"')
|
||||||
|
return
|
||||||
if write_comic_info:
|
if write_comic_info:
|
||||||
serialize_comic_xml(doujinshi_obj, doujinshi_dir)
|
serialize_comic_xml(doujinshi_obj, doujinshi_dir)
|
||||||
cbz_filename = os.path.join(os.path.join(doujinshi_dir, '..'), f'{doujinshi_obj.filename}.cbz')
|
cbz_filename = os.path.join(os.path.join(doujinshi_dir, '..'), f'{doujinshi_obj.filename}.cbz')
|
||||||
@ -287,11 +290,11 @@ def generate_metadata_file(output_dir, table, doujinshi_obj=None):
|
|||||||
|
|
||||||
f = open(os.path.join(doujinshi_dir, 'info.txt'), 'w', encoding='utf-8')
|
f = open(os.path.join(doujinshi_dir, 'info.txt'), 'w', encoding='utf-8')
|
||||||
|
|
||||||
fields = ['TITLE', 'ORIGINAL TITLE', 'AUTHOR', 'ARTIST', 'GROUPS', 'CIRCLE', 'SCANLATOR',
|
fields = ['TITLE', 'ORIGINAL TITLE', 'AUTHOR', 'ARTIST', 'CIRCLE', 'SCANLATOR',
|
||||||
'TRANSLATOR', 'PUBLISHER', 'DESCRIPTION', 'STATUS', 'CHAPTERS', 'PAGES',
|
'TRANSLATOR', 'PUBLISHER', 'DESCRIPTION', 'STATUS', 'CHAPTERS', 'PAGES',
|
||||||
'TAGS', 'TYPE', 'LANGUAGE', 'RELEASED', 'READING DIRECTION', 'CHARACTERS',
|
'TAGS', 'TYPE', 'LANGUAGE', 'RELEASED', 'READING DIRECTION', 'CHARACTERS',
|
||||||
'SERIES', 'PARODY', 'URL']
|
'SERIES', 'PARODY', 'URL']
|
||||||
special_fields = ['PARODY', 'TITLE', 'ORIGINAL TITLE', 'CHARACTERS', 'AUTHOR', 'GROUPS',
|
special_fields = ['PARODY', 'TITLE', 'ORIGINAL TITLE', 'CHARACTERS', 'AUTHOR',
|
||||||
'LANGUAGE', 'TAGS', 'URL', 'PAGES']
|
'LANGUAGE', 'TAGS', 'URL', 'PAGES']
|
||||||
|
|
||||||
for i in range(len(fields)):
|
for i in range(len(fields)):
|
||||||
|
Reference in New Issue
Block a user