@@ -49,7 +49,7 @@ def request_with_retry(self,
4949 @param kwargs: 请求方法的kwargs
5050 """
5151 if domain_index >= len (self .domain_list ):
52- raise AssertionError ( f"请求重试全部失败: [ { url } ], { self . domain_list } " )
52+ self . fallback ( request , url , domain_index , retry_count , ** kwargs )
5353
5454 if url .startswith ('/' ):
5555 # path
@@ -81,7 +81,6 @@ def request_with_retry(self,
8181 else :
8282 return self .request_with_retry (request , url , domain_index + 1 , 0 , ** kwargs )
8383
84-
8584 # noinspection PyMethodMayBeStatic, PyUnusedLocal
8685 def before_retry (self , e , kwargs , retry_count , url ):
8786 jm_debug ('error' , str (e ))
@@ -130,6 +129,9 @@ def get_jmcomic_url(self, postman=None):
130129 def get_jmcomic_domain_all (self , postman = None ):
131130 return JmModuleConfig .get_jmcomic_domain_all (postman or self .get_root_postman ())
132131
132+ def fallback (self , request , url , domain_index , retry_count , ** kwargs ):
133+ raise AssertionError (f"请求重试全部失败: [{ url } ], { self .domain_list } " )
134+
133135
134136# 基于网页实现的JmClient
135137class JmHtmlClient (AbstractJmClient ):
@@ -160,17 +162,6 @@ def get_photo_detail(self, photo_id, fetch_album=True) -> JmPhotoDetail:
160162
161163 return photo_detail
162164
163- def ensure_photo_can_use (self , photo_detail : JmPhotoDetail ):
164- # 检查 from_album
165- if photo_detail .from_album is None :
166- photo_detail .from_album = self .get_album_detail (photo_detail .album_id )
167-
168- # 检查 page_arr 和 data_original_domain
169- if photo_detail .page_arr is None or photo_detail .data_original_domain is None :
170- new = self .get_photo_detail (photo_detail .photo_id , False )
171- new .from_album = photo_detail .from_album
172- photo_detail .__dict__ .update (new .__dict__ )
173-
174165 def search_album (self , search_query , main_tag = 0 , page = 1 ) -> JmSearchPage :
175166 params = {
176167 'main_tag' : main_tag ,
@@ -226,7 +217,7 @@ def get_jm_html(self, url, require_200=True, **kwargs):
226217 resp = self .get (url , ** kwargs )
227218
228219 if require_200 is True and resp .status_code != 200 :
229- write_text ('./resp.html' , resp .text )
220+ # write_text('./resp.html', resp.text)
230221 self .check_special_http_code (resp )
231222 self .raise_request_error (resp )
232223
0 commit comments