From 466fa4c094078df467020483959b80bb49e65644 Mon Sep 17 00:00:00 2001 From: Ricter Z Date: Sun, 5 Feb 2023 23:17:23 +0800 Subject: [PATCH] rename some constants --- nhentai/constant.py | 10 +++++----- nhentai/serializer.py | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/nhentai/constant.py b/nhentai/constant.py index 680fef6..c5c9092 100644 --- a/nhentai/constant.py +++ b/nhentai/constant.py @@ -4,9 +4,8 @@ import tempfile from urllib.parse import urlparse -BASE_URL = os.getenv('NHENTAI', 'https://nhentai.net') -__api_suspended_DETAIL_URL = f'{BASE_URL}/api/gallery' +BASE_URL = os.getenv('NHENTAI', 'https://nhentai.net') DETAIL_URL = f'{BASE_URL}/g' LEGACY_SEARCH_URL = f'{BASE_URL}/search/' @@ -17,13 +16,14 @@ LOGIN_URL = f'{BASE_URL}/login/' CHALLENGE_URL = f'{BASE_URL}/challenge' FAV_URL = f'{BASE_URL}/favorites/' -u = urlparse(BASE_URL) -IMAGE_URL = f'{u.scheme}://i.{u.hostname}/galleries' +IMAGE_URL = f'{urlparse(BASE_URL).scheme}://i.{urlparse(BASE_URL).hostname}/galleries' NHENTAI_HOME = os.path.join(os.getenv('HOME', tempfile.gettempdir()), '.nhentai') NHENTAI_HISTORY = os.path.join(NHENTAI_HOME, 'history.sqlite3') NHENTAI_CONFIG_FILE = os.path.join(NHENTAI_HOME, 'config.json') +__api_suspended_DETAIL_URL = f'{BASE_URL}/api/gallery' + CONFIG = { 'proxy': {'http': '', 'https': ''}, 'cookie': '', @@ -32,7 +32,7 @@ CONFIG = { 'useragent': 'nhentai command line client (https://github.com/RicterZ/nhentai)' } -LANGUAGEISO = { +LANGUAGE_ISO = { 'english': 'en', 'chinese': 'zh', 'japanese': 'ja', diff --git a/nhentai/serializer.py b/nhentai/serializer.py index bf5b12e..2cb93cd 100644 --- a/nhentai/serializer.py +++ b/nhentai/serializer.py @@ -2,7 +2,7 @@ import json import os from xml.sax.saxutils import escape -from nhentai.constant import LANGUAGEISO +from nhentai.constant import LANGUAGE_ISO def serialize_json(doujinshi, output_dir): @@ -67,8 +67,8 @@ def serialize_comic_xml(doujinshi, output_dir): if doujinshi.info.languages: languages = [i.strip() for i in doujinshi.info.languages.split(',')] xml_write_simple_tag(f, 'Translated', 'Yes' if 'translated' in languages else 'No') - [xml_write_simple_tag(f, 'LanguageISO', LANGUAGEISO[i]) for i in languages - if (i != 'translated' and i in LANGUAGEISO)] + [xml_write_simple_tag(f, 'LanguageISO', LANGUAGE_ISO[i]) for i in languages + if (i != 'translated' and i in LANGUAGE_ISO)] f.write('')