diff --git a/nhentai/constant.py b/nhentai/constant.py index 585250b..7dadbbd 100644 --- a/nhentai/constant.py +++ b/nhentai/constant.py @@ -5,6 +5,7 @@ import tempfile from urllib.parse import urlparse from platform import system + def get_nhentai_home() -> str: home = os.getenv('HOME', tempfile.gettempdir()) @@ -20,6 +21,7 @@ def get_nhentai_home() -> str: # Use old default path in other systems return os.path.join(home, '.nhentai') + DEBUG = os.getenv('DEBUG', False) BASE_URL = os.getenv('NHENTAI', 'https://nhentai.net') @@ -52,7 +54,8 @@ CONFIG = { 'cookie': '', 'language': '', 'template': '', - 'useragent': 'nhentai command line client (https://github.com/RicterZ/nhentai)' + 'useragent': 'nhentai command line client (https://github.com/RicterZ/nhentai)', + 'max_filename': 85 } LANGUAGE_ISO = { diff --git a/nhentai/parser.py b/nhentai/parser.py index 65d92cd..5b7f26c 100644 --- a/nhentai/parser.py +++ b/nhentai/parser.py @@ -327,7 +327,9 @@ def search_parser(keyword, sorting, page, is_page_all=False): for row in response['result']: title = row['title']['english'] - title = title[:85] + '..' if len(title) > 85 else title + title = title[:constant.CONFIG['max_filename']] + '..' if \ + len(title) > constant.CONFIG['max_filename'] else title + result.append({'id': row['id'], 'title': title}) not_exists_persist = False