mirror of
https://github.com/RicterZ/nhentai.git
synced 2025-04-20 02:41:19 +02:00
fix #33
This commit is contained in:
parent
8cbb334d36
commit
7e56d9b901
@ -103,9 +103,6 @@ class Downloader(Singleton):
|
||||
if self.path:
|
||||
folder = os.path.join(self.path, folder)
|
||||
|
||||
if len(folder) > 100:
|
||||
folder = folder[:100]
|
||||
|
||||
if not os.path.exists(folder):
|
||||
logger.warn('Path \'{0}\' does not exist, creating.'.format(folder))
|
||||
try:
|
||||
|
@ -86,9 +86,9 @@ def generate_html(output_dir='.', doujinshi_obj=None):
|
||||
def generate_cbz(output_dir='.', doujinshi_obj=None):
|
||||
if doujinshi_obj is not None:
|
||||
doujinshi_dir = os.path.join(output_dir, format_filename('%s-%s' % (doujinshi_obj.id,
|
||||
str(doujinshi_obj.name[:200]))))
|
||||
doujinshi_obj.name)))
|
||||
cbz_filename = os.path.join(output_dir, format_filename('%s-%s.cbz' % (doujinshi_obj.id,
|
||||
str(doujinshi_obj.name[:200]))))
|
||||
doujinshi_obj.name)))
|
||||
else:
|
||||
cbz_filename = './doujinshi.cbz'
|
||||
doujinshi_dir = '.'
|
||||
@ -105,11 +105,6 @@ def generate_cbz(output_dir='.', doujinshi_obj=None):
|
||||
logger.log(15, 'Comic Book CBZ file has been write to \'{0}\''.format(doujinshi_dir))
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def format_filename(s):
|
||||
"""Take a string and return a valid filename constructed from the string.
|
||||
Uses a whitelist approach: any characters not present in valid_chars are
|
||||
@ -124,4 +119,6 @@ an invalid filename.
|
||||
valid_chars = "-_.() %s%s" % (string.ascii_letters, string.digits)
|
||||
filename = ''.join(c for c in s if c in valid_chars)
|
||||
filename = filename.replace(' ', '_') # I don't like spaces in filenames.
|
||||
if len(filename) > 100:
|
||||
filename = filename[:100]
|
||||
return filename
|
||||
|
Loading…
x
Reference in New Issue
Block a user