@@ -139,20 +139,8 @@ def __init__(self,
139139
140140 self .call_all_plugin ('after_init' )
141141
142- @property
143- def download_cache (self ):
144- return self .download .cache
145-
146- @property
147- def download_image_decode (self ):
148- return self .download .image .decode
149-
150- @property
151- def download_image_suffix (self ):
152- return self .download .image .suffix
153-
154142 """
155- 下面是决定图片保存路径的方法
143+ 下面是decide系列方法,为了支持重写和增加程序动态性。
156144 """
157145
158146 # noinspection PyUnusedLocal
@@ -196,19 +184,28 @@ def decide_album_dir(self, album: JmAlbumDetail) -> str:
196184
197185 def decide_image_suffix (self , image : JmImageDetail ):
198186 # 动图则使用原后缀
199- suffix = image .img_file_suffix
200- if suffix .endswith ("gif" ):
201- return suffix
187+ if image .is_gif :
188+ return image .img_file_suffix
202189
203190 # 非动图,以配置为先
204- return self .download_image_suffix or suffix
191+ return self .download . image . suffix or image . img_file_suffix
205192
206- def decide_image_filepath (self , image : JmImageDetail ) -> str :
193+ def decide_image_filepath (self , image : JmImageDetail , consider_custom_suffix = True ) -> str :
207194 # 通过拼接生成绝对路径
208195 save_dir = self .decide_image_save_dir (image .from_photo )
209- suffix = self .decide_image_suffix (image )
196+ suffix = self .decide_image_suffix (image ) if consider_custom_suffix else image . img_file_suffix
210197 return os .path .join (save_dir , image .filename_without_suffix + suffix )
211198
199+ def decide_download_cache (self , _image : JmImageDetail ) -> bool :
200+ return self .download .cache
201+
202+ def decide_download_image_decode (self , image : JmImageDetail ) -> bool :
203+ # .gif file needn't be decoded
204+ if image .is_gif :
205+ return False
206+
207+ return self .download .image .decode
208+
212209 """
213210 下面是创建对象相关方法
214211 """
@@ -272,6 +269,10 @@ def deconstruct(self) -> Dict:
272269 'client' : self .client .src_dict ,
273270 }
274271
272+ """
273+ 下面是文件IO方法
274+ """
275+
275276 @classmethod
276277 def from_file (cls , filepath : str ) -> 'JmOption' :
277278 dic : dict = PackerUtil .unpack (filepath )[0 ]
@@ -286,7 +287,7 @@ def to_file(self, filepath=None):
286287 PackerUtil .pack (self .deconstruct (), filepath )
287288
288289 """
289- 下面是 build 方法
290+ 下面是创建客户端的相关方法
290291 """
291292
292293 @field_cache ("__jm_client_cache__" )
0 commit comments