jmcomic 2.5.9__tar.gz → 2.5.10__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (23) hide show
  1. {jmcomic-2.5.9/src/jmcomic.egg-info → jmcomic-2.5.10}/PKG-INFO +1 -1
  2. {jmcomic-2.5.9 → jmcomic-2.5.10}/src/jmcomic/__init__.py +1 -1
  3. {jmcomic-2.5.9 → jmcomic-2.5.10}/src/jmcomic/jm_config.py +1 -1
  4. {jmcomic-2.5.9 → jmcomic-2.5.10}/src/jmcomic/jm_option.py +0 -22
  5. {jmcomic-2.5.9 → jmcomic-2.5.10}/src/jmcomic/jm_plugin.py +39 -39
  6. {jmcomic-2.5.9 → jmcomic-2.5.10/src/jmcomic.egg-info}/PKG-INFO +1 -1
  7. {jmcomic-2.5.9 → jmcomic-2.5.10}/LICENSE +0 -0
  8. {jmcomic-2.5.9 → jmcomic-2.5.10}/README.md +0 -0
  9. {jmcomic-2.5.9 → jmcomic-2.5.10}/setup.cfg +0 -0
  10. {jmcomic-2.5.9 → jmcomic-2.5.10}/setup.py +0 -0
  11. {jmcomic-2.5.9 → jmcomic-2.5.10}/src/jmcomic/api.py +0 -0
  12. {jmcomic-2.5.9 → jmcomic-2.5.10}/src/jmcomic/cl.py +0 -0
  13. {jmcomic-2.5.9 → jmcomic-2.5.10}/src/jmcomic/jm_client_impl.py +0 -0
  14. {jmcomic-2.5.9 → jmcomic-2.5.10}/src/jmcomic/jm_client_interface.py +0 -0
  15. {jmcomic-2.5.9 → jmcomic-2.5.10}/src/jmcomic/jm_downloader.py +0 -0
  16. {jmcomic-2.5.9 → jmcomic-2.5.10}/src/jmcomic/jm_entity.py +0 -0
  17. {jmcomic-2.5.9 → jmcomic-2.5.10}/src/jmcomic/jm_exception.py +0 -0
  18. {jmcomic-2.5.9 → jmcomic-2.5.10}/src/jmcomic/jm_toolkit.py +0 -0
  19. {jmcomic-2.5.9 → jmcomic-2.5.10}/src/jmcomic.egg-info/SOURCES.txt +0 -0
  20. {jmcomic-2.5.9 → jmcomic-2.5.10}/src/jmcomic.egg-info/dependency_links.txt +0 -0
  21. {jmcomic-2.5.9 → jmcomic-2.5.10}/src/jmcomic.egg-info/entry_points.txt +0 -0
  22. {jmcomic-2.5.9 → jmcomic-2.5.10}/src/jmcomic.egg-info/requires.txt +0 -0
  23. {jmcomic-2.5.9 → jmcomic-2.5.10}/src/jmcomic.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: jmcomic
3
- Version: 2.5.9
3
+ Version: 2.5.10
4
4
  Summary: Python API For JMComic (禁漫天堂)
5
5
  Home-page: https://github.com/hect0x7/JMComic-Crawler-Python
6
6
  Author: hect0x7
@@ -2,7 +2,7 @@
2
2
  # 被依赖方 <--- 使用方
3
3
  # config <--- entity <--- toolkit <--- client <--- option <--- downloader
4
4
 
5
- __version__ = '2.5.9'
5
+ __version__ = '2.5.10'
6
6
 
7
7
  from .api import *
8
8
  from .jm_plugin import *
@@ -368,7 +368,7 @@ class JmModuleConfig:
368
368
  'postman': {
369
369
  'type': 'cffi',
370
370
  'meta_data': {
371
- 'impersonate': 'chrome',
371
+ 'impersonate': 'chrome110',
372
372
  'headers': None,
373
373
  'proxies': None,
374
374
  }
@@ -236,28 +236,6 @@ class JmOption:
236
236
  def decide_photo_batch_count(self, album: JmAlbumDetail):
237
237
  return self.download.threading.photo
238
238
 
239
- def decide_album_dir(self, album: JmAlbumDetail) -> str:
240
- """
241
- 该方法目前仅在 plugin-zip 中使用,不建议外部调用
242
- """
243
- dir_layer = []
244
- dir_rule = self.dir_rule
245
- for rule in dir_rule.rule_dsl.split('_'):
246
- if rule == 'Bd':
247
- dir_layer.append(dir_rule.base_dir)
248
- continue
249
-
250
- if rule[0] == 'A':
251
- name = dir_rule.apply_rule_directly(album, None, rule)
252
- dir_layer.append(name)
253
-
254
- if rule[0] == 'P':
255
- break
256
-
257
- from os.path import join
258
- # noinspection PyTypeChecker
259
- return join(*dir_layer)
260
-
261
239
  # noinspection PyMethodMayBeStatic
262
240
  def decide_image_filename(self, image: JmImageDetail) -> str:
263
241
  """
@@ -302,27 +302,19 @@ class ZipPlugin(JmOptionPlugin):
302
302
 
303
303
  if level == 'album':
304
304
  zip_path = self.get_zip_path(album, None, filename_rule, suffix, zip_dir)
305
- dir_path = self.zip_album(album, photo_dict, zip_path)
306
- if dir_path is not None:
307
- # 要删除这个album文件夹
308
- dir_zip_dict[dir_path] = zip_path
309
- # 也要删除album下的photo文件夹
310
- for d in files_of_dir(dir_path):
311
- dir_zip_dict[d] = None
305
+ self.zip_album(album, photo_dict, zip_path, dir_zip_dict)
312
306
 
313
307
  elif level == 'photo':
314
308
  for photo, image_list in photo_dict.items():
315
309
  zip_path = self.get_zip_path(None, photo, filename_rule, suffix, zip_dir)
316
- dir_path = self.zip_photo(photo, image_list, zip_path)
317
- if dir_path is not None:
318
- dir_zip_dict[dir_path] = zip_path
310
+ self.zip_photo(photo, image_list, zip_path, dir_zip_dict)
319
311
 
320
312
  else:
321
313
  ExceptionTool.raises(f'Not Implemented Zip Level: {level}')
322
314
 
323
315
  self.after_zip(dir_zip_dict)
324
316
 
325
- def zip_photo(self, photo, image_list: list, zip_path: str) -> Optional[str]:
317
+ def zip_photo(self, photo, image_list: list, zip_path: str, dir_zip_dict) -> Optional[str]:
326
318
  """
327
319
  压缩photo文件夹
328
320
  :returns: photo文件夹路径
@@ -333,50 +325,58 @@ class ZipPlugin(JmOptionPlugin):
333
325
 
334
326
  all_filepath = set(map(lambda t: self.unified_path(t[0]), image_list))
335
327
 
336
- return self.do_zip(photo_dir,
337
- zip_path,
338
- all_filepath,
339
- f'压缩章节[{photo.photo_id}]成功 → {zip_path}',
340
- )
328
+ if len(all_filepath) == 0:
329
+ self.log('无下载文件,无需压缩', 'skip')
330
+ return None
331
+
332
+ from common import backup_dir_to_zip
333
+ backup_dir_to_zip(
334
+ photo_dir,
335
+ zip_path,
336
+ acceptor=lambda f: os.path.isdir(f) or self.unified_path(f) in all_filepath
337
+ ).close()
338
+
339
+ self.log(f'压缩章节[{photo.photo_id}]成功 → {zip_path}', 'finish')
340
+ dir_zip_dict[self.unified_path(photo_dir)] = zip_path
341
341
 
342
342
  @staticmethod
343
343
  def unified_path(f):
344
344
  return fix_filepath(f, os.path.isdir(f))
345
345
 
346
- def zip_album(self, album, photo_dict: dict, zip_path) -> Optional[str]:
346
+ def zip_album(self, album, photo_dict: dict, zip_path, dir_zip_dict) -> Optional[str]:
347
347
  """
348
348
  压缩album文件夹
349
349
  :returns: album文件夹路径
350
350
  """
351
- all_filepath: Set[str] = set()
352
-
353
- def addpath(f):
354
- all_filepath.update(set(f))
355
351
 
356
- album_dir = self.option.decide_album_dir(album)
357
- # addpath(self.option.decide_image_save_dir(photo) for photo in photo_dict.keys())
358
- addpath(path for ls in photo_dict.values() for path, _ in ls)
352
+ # 所有下载了的图片文件的路径
353
+ all_filepath: Set[str] = set(path for ls in photo_dict.values() for path, _ in ls)
359
354
 
360
- return self.do_zip(album_dir,
361
- zip_path,
362
- all_filepath,
363
- msg=f'压缩本子[{album.album_id}]成功 → {zip_path}',
364
- )
365
-
366
- def do_zip(self, source_dir, zip_path, all_filepath, msg):
367
355
  if len(all_filepath) == 0:
368
356
  self.log('无下载文件,无需压缩', 'skip')
369
- return None
357
+ return
370
358
 
359
+ # 该本子的所有章节的图片所在文件夹
360
+ photo_dir_list = [self.option.decide_image_save_dir(photo) for photo in photo_dict.keys()]
361
+
362
+ # 压缩文件对象
371
363
  from common import backup_dir_to_zip
372
- backup_dir_to_zip(
373
- source_dir,
374
- zip_path,
375
- acceptor=lambda f: os.path.isdir(f) or self.unified_path(f) in all_filepath
376
- ).close()
364
+ import zipfile
365
+ zfile = zipfile.ZipFile(zip_path, 'w')
366
+
367
+ for photo_dir in photo_dir_list:
368
+ photo_dir = self.unified_path(photo_dir)
369
+ backup_dir_to_zip(
370
+ photo_dir,
371
+ zip_path,
372
+ zfile=zfile,
373
+ prefix=os.path.basename(photo_dir.rstrip('/')),
374
+ acceptor=lambda f: os.path.isdir(f) or self.unified_path(f) in all_filepath
375
+ )
376
+ dir_zip_dict[photo_dir] = zip_path
377
377
 
378
- self.log(msg, 'finish')
379
- return self.unified_path(source_dir)
378
+ zfile.close()
379
+ self.log(f'压缩本子[{album.album_id}]成功 → {zip_path}', 'finish')
380
380
 
381
381
  def after_zip(self, dir_zip_dict: Dict[str, Optional[str]]):
382
382
  # 删除所有原文件
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: jmcomic
3
- Version: 2.5.9
3
+ Version: 2.5.10
4
4
  Summary: Python API For JMComic (禁漫天堂)
5
5
  Home-page: https://github.com/hect0x7/JMComic-Crawler-Python
6
6
  Author: hect0x7
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes