jmcomic 2.5.35__tar.gz → 2.5.36__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.35/src/jmcomic.egg-info → jmcomic-2.5.36}/PKG-INFO +1 -1
  2. {jmcomic-2.5.35 → jmcomic-2.5.36}/src/jmcomic/__init__.py +1 -1
  3. {jmcomic-2.5.35 → jmcomic-2.5.36}/src/jmcomic/jm_client_interface.py +4 -1
  4. {jmcomic-2.5.35 → jmcomic-2.5.36}/src/jmcomic/jm_config.py +1 -1
  5. {jmcomic-2.5.35 → jmcomic-2.5.36}/src/jmcomic/jm_entity.py +26 -0
  6. {jmcomic-2.5.35 → jmcomic-2.5.36}/src/jmcomic/jm_option.py +13 -5
  7. {jmcomic-2.5.35 → jmcomic-2.5.36/src/jmcomic.egg-info}/PKG-INFO +1 -1
  8. {jmcomic-2.5.35 → jmcomic-2.5.36}/LICENSE +0 -0
  9. {jmcomic-2.5.35 → jmcomic-2.5.36}/README.md +0 -0
  10. {jmcomic-2.5.35 → jmcomic-2.5.36}/setup.cfg +0 -0
  11. {jmcomic-2.5.35 → jmcomic-2.5.36}/setup.py +0 -0
  12. {jmcomic-2.5.35 → jmcomic-2.5.36}/src/jmcomic/api.py +0 -0
  13. {jmcomic-2.5.35 → jmcomic-2.5.36}/src/jmcomic/cl.py +0 -0
  14. {jmcomic-2.5.35 → jmcomic-2.5.36}/src/jmcomic/jm_client_impl.py +0 -0
  15. {jmcomic-2.5.35 → jmcomic-2.5.36}/src/jmcomic/jm_downloader.py +0 -0
  16. {jmcomic-2.5.35 → jmcomic-2.5.36}/src/jmcomic/jm_exception.py +0 -0
  17. {jmcomic-2.5.35 → jmcomic-2.5.36}/src/jmcomic/jm_plugin.py +0 -0
  18. {jmcomic-2.5.35 → jmcomic-2.5.36}/src/jmcomic/jm_toolkit.py +0 -0
  19. {jmcomic-2.5.35 → jmcomic-2.5.36}/src/jmcomic.egg-info/SOURCES.txt +0 -0
  20. {jmcomic-2.5.35 → jmcomic-2.5.36}/src/jmcomic.egg-info/dependency_links.txt +0 -0
  21. {jmcomic-2.5.35 → jmcomic-2.5.36}/src/jmcomic.egg-info/entry_points.txt +0 -0
  22. {jmcomic-2.5.35 → jmcomic-2.5.36}/src/jmcomic.egg-info/requires.txt +0 -0
  23. {jmcomic-2.5.35 → jmcomic-2.5.36}/src/jmcomic.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: jmcomic
3
- Version: 2.5.35
3
+ Version: 2.5.36
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.35'
5
+ __version__ = '2.5.36'
6
6
 
7
7
  from .api import *
8
8
  from .jm_plugin import *
@@ -62,13 +62,16 @@ class JmImageResp(JmResp):
62
62
  img_url=None,
63
63
  ):
64
64
  img_url = img_url or self.url
65
+ index = img_url.find("?")
66
+ if index != -1:
67
+ img_url = img_url[0:index]
65
68
 
66
69
  if decode_image is False or scramble_id is None:
67
70
  # 不解密图片,直接保存文件
68
71
  JmImageTool.save_resp_img(
69
72
  self,
70
73
  path,
71
- need_convert=suffix_not_equal(img_url[:img_url.find("?")], path),
74
+ need_convert=suffix_not_equal(img_url, path),
72
75
  )
73
76
  else:
74
77
  # 解密图片并保存文件
@@ -414,7 +414,7 @@ class JmModuleConfig:
414
414
  'cache': None, # see CacheRegistry
415
415
  'domain': [],
416
416
  'postman': {
417
- 'type': 'cffi',
417
+ 'type': 'curl_cffi',
418
418
  'meta_data': {
419
419
  'impersonate': 'chrome110',
420
420
  'headers': None,
@@ -164,6 +164,32 @@ class DetailEntity(JmBaseEntity, IndexedEntity):
164
164
 
165
165
  return getattr(detail, ref)
166
166
 
167
+ def get_properties_dict(self):
168
+ import inspect
169
+
170
+ prefix = self.__class__.__name__[2]
171
+ result = {}
172
+
173
+ # field
174
+ for k, v in self.__dict__.items():
175
+ result[prefix + k] = v
176
+
177
+ # property
178
+ for cls in inspect.getmro(type(self)):
179
+ for name, attr in cls.__dict__.items():
180
+ k = prefix + name
181
+ if k not in result and isinstance(attr, property):
182
+ v = attr.__get__(self, cls)
183
+ result[k] = v
184
+
185
+ # advice
186
+ advice_dict = JmModuleConfig.AFIELD_ADVICE if self.is_album() else JmModuleConfig.PFIELD_ADVICE
187
+ for name, func in advice_dict.items():
188
+ k = prefix + name
189
+ result[k] = func(self)
190
+
191
+ return result
192
+
167
193
 
168
194
  class JmImageDetail(JmBaseEntity, Downloadable):
169
195
 
@@ -71,7 +71,7 @@ class DirRule:
71
71
  ]
72
72
 
73
73
  Detail = Union[JmAlbumDetail, JmPhotoDetail, None]
74
- RuleFunc = Callable[[Detail], str]
74
+ RuleFunc = Callable
75
75
  RuleSolver = Tuple[str, RuleFunc, str]
76
76
  RuleSolverList = List[RuleSolver]
77
77
 
@@ -154,6 +154,12 @@ class DirRule:
154
154
 
155
155
  @classmethod
156
156
  def get_rule_solver(cls, rule: str) -> Optional[RuleSolver]:
157
+ if '{' in rule:
158
+ def format_path(album, photo):
159
+ return fix_windir_name(rule.format(**album.get_properties_dict(), **photo.get_properties_dict())).strip()
160
+
161
+ return 'F', format_path, rule
162
+
157
163
  # 检查dsl
158
164
  if not rule.startswith(('A', 'P')):
159
165
  return None
@@ -176,15 +182,17 @@ class DirRule:
176
182
 
177
183
  def choose_detail(key):
178
184
  if key == 'Bd':
179
- return None
185
+ return None,
180
186
  if key == 'A':
181
- return album
187
+ return album,
182
188
  if key == 'P':
183
- return photo
189
+ return photo,
190
+ if key == 'F':
191
+ return album, photo
184
192
 
185
193
  key, func, _ = rule_solver
186
194
  detail = choose_detail(key)
187
- return func(detail)
195
+ return func(*detail)
188
196
 
189
197
  @classmethod
190
198
  def apply_rule_directly(cls, album, photo, rule: str) -> str:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: jmcomic
3
- Version: 2.5.35
3
+ Version: 2.5.36
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