jmcomic 2.0.5__tar.gz → 2.0.6__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: jmcomic
3
- Version: 2.0.5
3
+ Version: 2.0.6
4
4
  Summary: Python API For JMComic (禁漫天堂)
5
5
  Home-page: https://github.com/hect0x7/JMComic-Crawler-Python
6
6
  Author: hect0x7
@@ -2,6 +2,6 @@
2
2
  # 被依赖方 <--- 使用方
3
3
  # config <--- entity <--- toolkit <--- client <--- option
4
4
 
5
- __version__ = '2.0.5'
5
+ __version__ = '2.0.6'
6
6
 
7
7
  from .api import *
@@ -95,9 +95,18 @@ class AbstractJmClient(
95
95
 
96
96
  setattr(self, func_name, wrap_func)
97
97
 
98
- wrap_func_cache('get_photo_detail', 'album_cache_dict')
99
- wrap_func_cache('get_album_detail', 'photo_cache_dict')
100
- wrap_func_cache('search_album', 'search_album_cache_dict')
98
+ for func in {
99
+ 'get_photo_detail',
100
+ 'get_album_detail',
101
+ 'search_album',
102
+ }:
103
+ wrap_func_cache(func, func + '.cache.dict')
104
+
105
+ def get_jmcomic_url(self, postman=None):
106
+ return JmModuleConfig.get_jmcomic_url(postman or self.get_root_postman())
107
+
108
+ def get_jmcomic_domain_all(self, postman=None):
109
+ return JmModuleConfig.get_jmcomic_domain_all(postman or self.get_root_postman())
101
110
 
102
111
 
103
112
  # 基于网页实现的JmClient
@@ -3,11 +3,23 @@ def default_jm_debug(topic: str, msg: str):
3
3
  print(f'{format_ts()}:【{topic}】{msg}')
4
4
 
5
5
 
6
+ def default_postman_constructor(session, **kwargs):
7
+ from common import Postmans
8
+
9
+ kwargs.setdefault('impersonate', 'chrome110')
10
+ kwargs.setdefault('headers', JmModuleConfig.headers())
11
+
12
+ if session is True:
13
+ return Postmans.new_session(**kwargs)
14
+
15
+ return Postmans.new_postman(**kwargs)
16
+
17
+
6
18
  class JmModuleConfig:
7
19
  # 网站相关
8
20
  PROT = "https://"
9
21
  DOMAIN = None
10
- JM_REDIRECT_URL = f'{PROT}jm365.xyz/3YeBdF' # 永久網域,怕走失的小伙伴收藏起来
22
+ JM_REDIRECT_URL = f'{PROT}jm365.work/3YeBdF' # 永久網域,怕走失的小伙伴收藏起来
11
23
  JM_PUB_URL = f'{PROT}jmcomic2.bet'
12
24
  JM_CDN_IMAGE_URL_TEMPLATE = PROT + 'cdn-msp.{domain}/media/photos/{photo_id}/{index:05}{suffix}' # index 从1开始
13
25
  JM_IMAGE_SUFFIX = ['.jpg', '.webp', '.png', '.gif']
@@ -40,6 +52,7 @@ class JmModuleConfig:
40
52
  # debug
41
53
  enable_jm_debug = True
42
54
  debug_executor = default_jm_debug
55
+ postman_constructor = default_postman_constructor
43
56
 
44
57
  @classmethod
45
58
  def domain(cls, postman=None):
@@ -84,15 +97,17 @@ class JmModuleConfig:
84
97
  def disable_jm_debug(cls):
85
98
  cls.enable_jm_debug = False
86
99
 
100
+ @classmethod
101
+ def new_postman(cls, session=False, **kwargs):
102
+ return cls.postman_constructor(session, **kwargs)
103
+
87
104
  @classmethod
88
105
  def get_jmcomic_url(cls, postman=None):
89
106
  """
90
107
  访问禁漫的永久网域,从而得到一个可用的禁漫网址
91
108
  @return: https://jm-comic2.cc
92
109
  """
93
- if postman is None:
94
- from common import Postmans
95
- postman = Postmans.new_session()
110
+ postman = postman or cls.new_postman(session=True)
96
111
 
97
112
  resp = postman.get(cls.JM_REDIRECT_URL)
98
113
  url = resp.url
@@ -105,9 +120,7 @@ class JmModuleConfig:
105
120
  访问禁漫发布页,得到所有禁漫的域名
106
121
  @return:['18comic.vip', ..., 'jm365.xyz/ZNPJam'], 最后一个是【APP軟件下載】
107
122
  """
108
- if postman is None:
109
- from common import Postmans
110
- postman = Postmans.get_impl_clazz('cffi').create()
123
+ postman = postman or cls.new_postman(session=True)
111
124
 
112
125
  resp = postman.get(cls.JM_PUB_URL)
113
126
  if resp.status_code != 200:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: jmcomic
3
- Version: 2.0.5
3
+ Version: 2.0.6
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