@@ -52,18 +52,27 @@ class JmModuleConfig:
5252 SCRAMBLE_NUM_8 = 421926 # 2023-02-08后改了图片切割算法
5353 SCRAMBLE_CACHE = {}
5454
55- # API的相关配置
56- # 移动端api密钥
55+ # 移动端API的相关配置
56+ # API密钥
5757 MAGIC_18COMICAPPCONTENT = '18comicAPPContent'
58- # 移动端的图片域名
59- DOMAIN_IMAGE_LIST = [f"cdn-msp.jmapiproxy{ i } .cc" for i in range (1 , 4 )]
6058
61- # 下载时的一些默认值配置
62- default_author = 'default-author'
63-
64- # 模块级别的可重写配置
65- DOMAIN = None
66- DOMAIN_LIST = None
59+ # 域名配置 - 移动端
60+ # 图片域名
61+ DOMAIN_API_IMAGE_LIST = [f"cdn-msp.jmapiproxy{ i } .cc" for i in range (1 , 4 )]
62+ # API域名
63+ DOMAIN_API_LIST = [
64+ "www.jmapinode1.cc" ,
65+ "www.jmapinode2.cc" ,
66+ "www.jmapinode3.cc" ,
67+ "www.jmapibranch2.cc" ,
68+ ]
69+
70+ # 域名配置 - 网页端
71+ # 无需配置,默认为None,需要的时候会发起请求获得
72+ DOMAIN_HTML = None
73+ DOMAIN_HTML_LIST = None
74+
75+ # 模块级别的可重写类配置
6776 CLASS_DOWNLOADER = None
6877 CLASS_OPTION = None
6978 CLASS_ALBUM = None
@@ -86,6 +95,8 @@ class JmModuleConfig:
8695 enable_jm_debug = True
8796 # debug时解码url
8897 decode_url_when_debug = True
98+ # 下载时的一些默认值配置
99+ default_author = 'default-author'
89100
90101 @classmethod
91102 def downloader_class (cls ):
@@ -139,33 +150,33 @@ def client_impl_class(cls, client_key: str):
139150 return clazz
140151
141152 @classmethod
142- @field_cache ("DOMAIN " )
143- def domain (cls , postman = None ):
153+ @field_cache ("DOMAIN_HTML " )
154+ def get_html_domain (cls , postman = None ):
144155 """
145156 由于禁漫的域名经常变化,调用此方法可以获取一个当前可用的最新的域名 domain,
146157 并且设置把 domain 设置为禁漫模块的默认域名。
147158 这样一来,配置文件也不用配置域名了,一切都在运行时动态获取。
148159 """
149160 from .jm_toolkit import JmcomicText
150- return JmcomicText .parse_to_jm_domain (cls .get_jmcomic_url (postman ))
161+ return JmcomicText .parse_to_jm_domain (cls .get_html_url (postman ))
151162
152163 @classmethod
153- def get_jmcomic_url (cls , postman = None ):
164+ def get_html_url (cls , postman = None ):
154165 """
155166 访问禁漫的永久网域,从而得到一个可用的禁漫网址
156167 @return: https://jm-comic2.cc
157168 """
158169 postman = postman or cls .new_postman (session = True )
159170
160171 url = postman .with_redirect_catching ().get (cls .JM_REDIRECT_URL )
161- cls .jm_debug ('获取禁漫URL ' , f'[{ cls .JM_REDIRECT_URL } ] → [{ url } ]' )
172+ cls .jm_debug ('获取禁漫网页URL ' , f'[{ cls .JM_REDIRECT_URL } ] → [{ url } ]' )
162173 return url
163174
164175 @classmethod
165- @field_cache ("DOMAIN_LIST " )
166- def get_jmcomic_domain_all (cls , postman = None ):
176+ @field_cache ("DOMAIN_HTML_LIST " )
177+ def get_html_domain_all (cls , postman = None ):
167178 """
168- 访问禁漫发布页,得到所有禁漫的域名
179+ 访问禁漫发布页,得到所有的禁漫网页域名
169180
170181 @return: ['18comic.vip', ..., 'jm365.xyz/ZNPJam'], 最后一个是【APP軟件下載】
171182 """
@@ -179,7 +190,7 @@ def get_jmcomic_domain_all(cls, postman=None):
179190 from .jm_toolkit import JmcomicText
180191 domain_list = JmcomicText .analyse_jm_pub_html (resp .text )
181192
182- cls .jm_debug ('获取禁漫全部域名 ' , f'[{ resp .url } ] → { domain_list } ' )
193+ cls .jm_debug ('获取禁漫网页全部域名 ' , f'[{ resp .url } ] → { domain_list } ' )
183194 return domain_list
184195
185196 @classmethod
@@ -240,6 +251,8 @@ def new_postman(cls, session=False, **kwargs):
240251
241252 # option 默认配置字典
242253 JM_OPTION_VER = '2.1'
254+ CLIENT_IMPL_DEFAULT = 'html'
255+
243256 default_option_dict : dict = {
244257 'version' : JM_OPTION_VER ,
245258 'debug' : None ,
@@ -262,7 +275,7 @@ def new_postman(cls, session=False, **kwargs):
262275 'headers' : None ,
263276 }
264277 },
265- 'impl' : 'html' ,
278+ 'impl' : None ,
266279 'retry_times' : 5
267280 },
268281 'plugin' : {},
@@ -293,10 +306,9 @@ def option_default_dict(cls) -> dict:
293306 if client ['cache' ] is None :
294307 client ['cache' ] = True
295308
296- # headers
297- meta_data = client ['postman' ]['meta_data' ]
298- if meta_data ['headers' ] is None :
299- meta_data ['headers' ] = cls .headers ()
309+ # client impl
310+ if client ['impl' ] is None :
311+ client ['impl' ] = cls .CLIENT_IMPL_DEFAULT
300312
301313 # threading photo
302314 dt = option_dict ['download' ]['threading' ]
@@ -312,7 +324,12 @@ def register_plugin(cls, plugin_class):
312324
313325 @classmethod
314326 def register_client (cls , client_class ):
315- cls .CLASS_CLIENT_IMPL [client_class .client_key ] = client_class
327+ client_key = getattr (client_class , 'client_key' , None )
328+ if client_key is None :
329+ from .jm_toolkit import ExceptionTool
330+ ExceptionTool .raises (f'未配置client_key, class: { client_class } ' )
331+
332+ cls .CLASS_CLIENT_IMPL [client_key ] = client_class
316333
317334
318335jm_debug = JmModuleConfig .jm_debug
0 commit comments