@@ -50,42 +50,40 @@ class JmDownloader(DownloadCallback):
5050 JmDownloader = JmOption + 调度逻辑
5151 """
5252
53- def __init__ (self , option ) -> None :
53+ def __init__ (self , option : JmOption ) -> None :
5454 self .option = option
5555 self .use_cache = self .option .download_cache
5656 self .decode_image = self .option .download_image_decode
5757
5858 def download_album (self , album_id ):
5959 client = self .client_for_album (album_id )
6060 album = client .get_album_detail (album_id )
61-
62- self .before_album (album )
6361 self .download_by_album_detail (album , client )
64- self .after_album (album )
6562
6663 def download_by_album_detail (self , album : JmAlbumDetail , client : JmcomicClient ):
64+ self .before_album (album )
6765 self .execute_by_condition (
6866 iter_objs = album ,
6967 apply = lambda photo : self .download_by_photo_detail (photo , client ),
7068 count_batch = self .option .decide_photo_batch_count (album )
7169 )
70+ self .after_album (album )
7271
7372 def download_photo (self , photo_id ):
7473 client = self .client_for_photo (photo_id )
7574 photo = client .get_photo_detail (photo_id )
76-
77- self .before_photo (photo )
7875 self .download_by_photo_detail (photo , client )
79- self .after_photo (photo )
8076
8177 def download_by_photo_detail (self , photo : JmPhotoDetail , client : JmcomicClient ):
8278 client .check_photo (photo )
8379
80+ self .before_photo (photo )
8481 self .execute_by_condition (
8582 iter_objs = photo ,
8683 apply = lambda image : self .download_by_image_detail (image , client ),
8784 count_batch = self .option .decide_image_batch_count (photo )
8885 )
86+ self .after_photo (photo )
8987
9088 def download_by_image_detail (self , image : JmImageDetail , client : JmcomicClient ):
9189 img_save_path = self .option .decide_image_filepath (image )
@@ -123,20 +121,18 @@ def execute_by_condition(self, iter_objs, apply: Callable, count_batch: int):
123121 )
124122
125123 # noinspection PyUnusedLocal
126- def client_for_album (self , jm_album_id ):
124+ def client_for_album (self , jm_album_id ) -> JmcomicClient :
127125 """
128- 默认情况下,每次调用JmDownloader的download_album或download_photo,
129- 都会使用一个新的 JmcomicClient
126+ 默认情况下,所有的JmDownloader共用一个JmcomicClient
130127 """
131- return self .option .new_jm_client ()
128+ return self .option .build_jm_client ()
132129
133130 # noinspection PyUnusedLocal
134- def client_for_photo (self , jm_photo_id ):
131+ def client_for_photo (self , jm_photo_id ) -> JmcomicClient :
135132 """
136- 默认情况下,每次调用JmDownloader的download_album或download_photo,
137- 都会使用一个新的 JmcomicClient
133+ 默认情况下,所有的JmDownloader共用一个JmcomicClient
138134 """
139- return self .option .new_jm_client ()
135+ return self .option .build_jm_client ()
140136
141137 def __enter__ (self ):
142138 return self
0 commit comments