aioqzone 1.8.2.dev3__tar.gz → 1.8.3.dev1__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.
- {aioqzone-1.8.2.dev3 → aioqzone-1.8.3.dev1}/PKG-INFO +1 -1
- {aioqzone-1.8.2.dev3 → aioqzone-1.8.3.dev1}/pyproject.toml +1 -1
- {aioqzone-1.8.2.dev3 → aioqzone-1.8.3.dev1}/src/aioqzone/model/protocol/config.py +2 -0
- aioqzone-1.8.3.dev1/src/qqqr/__init__.py +4 -0
- {aioqzone-1.8.2.dev3 → aioqzone-1.8.3.dev1}/src/qqqr/qr/__init__.py +50 -8
- {aioqzone-1.8.2.dev3 → aioqzone-1.8.3.dev1}/src/qqqr/up/web.py +9 -4
- aioqzone-1.8.2.dev3/src/qqqr/__init__.py +0 -4
- {aioqzone-1.8.2.dev3 → aioqzone-1.8.3.dev1}/LICENSE +0 -0
- {aioqzone-1.8.2.dev3 → aioqzone-1.8.3.dev1}/README.md +0 -0
- {aioqzone-1.8.2.dev3 → aioqzone-1.8.3.dev1}/src/aioqzone/__init__.py +0 -0
- {aioqzone-1.8.2.dev3 → aioqzone-1.8.3.dev1}/src/aioqzone/api/__init__.py +0 -0
- {aioqzone-1.8.2.dev3 → aioqzone-1.8.3.dev1}/src/aioqzone/api/h5/__init__.py +0 -0
- {aioqzone-1.8.2.dev3 → aioqzone-1.8.3.dev1}/src/aioqzone/api/h5/model.py +0 -0
- {aioqzone-1.8.2.dev3 → aioqzone-1.8.3.dev1}/src/aioqzone/api/login/__init__.py +0 -0
- {aioqzone-1.8.2.dev3 → aioqzone-1.8.3.dev1}/src/aioqzone/api/login/_base.py +0 -0
- {aioqzone-1.8.2.dev3 → aioqzone-1.8.3.dev1}/src/aioqzone/exception.py +0 -0
- {aioqzone-1.8.2.dev3 → aioqzone-1.8.3.dev1}/src/aioqzone/message.py +0 -0
- {aioqzone-1.8.2.dev3 → aioqzone-1.8.3.dev1}/src/aioqzone/model/__init__.py +0 -0
- {aioqzone-1.8.2.dev3 → aioqzone-1.8.3.dev1}/src/aioqzone/model/api/__init__.py +0 -0
- {aioqzone-1.8.2.dev3 → aioqzone-1.8.3.dev1}/src/aioqzone/model/api/feed.py +0 -0
- {aioqzone-1.8.2.dev3 → aioqzone-1.8.3.dev1}/src/aioqzone/model/api/profile.py +0 -0
- {aioqzone-1.8.2.dev3 → aioqzone-1.8.3.dev1}/src/aioqzone/model/api/request.py +0 -0
- {aioqzone-1.8.2.dev3 → aioqzone-1.8.3.dev1}/src/aioqzone/model/api/response.py +0 -0
- {aioqzone-1.8.2.dev3 → aioqzone-1.8.3.dev1}/src/aioqzone/model/protocol/__init__.py +0 -0
- {aioqzone-1.8.2.dev3 → aioqzone-1.8.3.dev1}/src/aioqzone/model/protocol/entity.py +0 -0
- {aioqzone-1.8.2.dev3 → aioqzone-1.8.3.dev1}/src/aioqzone/utils/__init__.py +0 -0
- {aioqzone-1.8.2.dev3 → aioqzone-1.8.3.dev1}/src/aioqzone/utils/entity.py +0 -0
- {aioqzone-1.8.2.dev3 → aioqzone-1.8.3.dev1}/src/aioqzone/utils/regex.py +0 -0
- {aioqzone-1.8.2.dev3 → aioqzone-1.8.3.dev1}/src/aioqzone/utils/retry.py +0 -0
- {aioqzone-1.8.2.dev3 → aioqzone-1.8.3.dev1}/src/aioqzone/utils/time.py +0 -0
- {aioqzone-1.8.2.dev3 → aioqzone-1.8.3.dev1}/src/qqqr/base.py +0 -0
- {aioqzone-1.8.2.dev3 → aioqzone-1.8.3.dev1}/src/qqqr/constant.py +0 -0
- {aioqzone-1.8.2.dev3 → aioqzone-1.8.3.dev1}/src/qqqr/exception.py +0 -0
- {aioqzone-1.8.2.dev3 → aioqzone-1.8.3.dev1}/src/qqqr/message.py +0 -0
- {aioqzone-1.8.2.dev3 → aioqzone-1.8.3.dev1}/src/qqqr/py.typed +0 -0
- {aioqzone-1.8.2.dev3 → aioqzone-1.8.3.dev1}/src/qqqr/qr/type.py +0 -0
- {aioqzone-1.8.2.dev3 → aioqzone-1.8.3.dev1}/src/qqqr/type.py +0 -0
- {aioqzone-1.8.2.dev3 → aioqzone-1.8.3.dev1}/src/qqqr/up/__init__.py +0 -0
- {aioqzone-1.8.2.dev3 → aioqzone-1.8.3.dev1}/src/qqqr/up/_model.py +0 -0
- {aioqzone-1.8.2.dev3 → aioqzone-1.8.3.dev1}/src/qqqr/up/captcha/__init__.py +0 -0
- {aioqzone-1.8.2.dev3 → aioqzone-1.8.3.dev1}/src/qqqr/up/captcha/_model.py +0 -0
- {aioqzone-1.8.2.dev3 → aioqzone-1.8.3.dev1}/src/qqqr/up/captcha/capsess.py +0 -0
- {aioqzone-1.8.2.dev3 → aioqzone-1.8.3.dev1}/src/qqqr/up/captcha/pil_utils.py +0 -0
- {aioqzone-1.8.2.dev3 → aioqzone-1.8.3.dev1}/src/qqqr/up/captcha/select/__init__.py +0 -0
- {aioqzone-1.8.2.dev3 → aioqzone-1.8.3.dev1}/src/qqqr/up/captcha/select/_types.py +0 -0
- {aioqzone-1.8.2.dev3 → aioqzone-1.8.3.dev1}/src/qqqr/up/captcha/slide/__init__.py +0 -0
- {aioqzone-1.8.2.dev3 → aioqzone-1.8.3.dev1}/src/qqqr/up/captcha/slide/_types.py +0 -0
- {aioqzone-1.8.2.dev3 → aioqzone-1.8.3.dev1}/src/qqqr/up/encrypt.py +0 -0
- {aioqzone-1.8.2.dev3 → aioqzone-1.8.3.dev1}/src/qqqr/up/h5.py +0 -0
- {aioqzone-1.8.2.dev3 → aioqzone-1.8.3.dev1}/src/qqqr/utils/encrypt.py +0 -0
- {aioqzone-1.8.2.dev3 → aioqzone-1.8.3.dev1}/src/qqqr/utils/iter.py +0 -0
- {aioqzone-1.8.2.dev3 → aioqzone-1.8.3.dev1}/src/qqqr/utils/jsjson.py +0 -0
- {aioqzone-1.8.2.dev3 → aioqzone-1.8.3.dev1}/src/qqqr/utils/net.py +0 -0
|
@@ -28,13 +28,17 @@ PTLOGIN2 = URL("https://ptlogin2.qq.com")
|
|
|
28
28
|
|
|
29
29
|
@dataclass(unsafe_hash=True)
|
|
30
30
|
class QR:
|
|
31
|
+
"""Class :class:`QR` represents a QR code."""
|
|
32
|
+
|
|
31
33
|
png: t.Optional[bytes]
|
|
32
|
-
"""If None, the QR is pushed to user's client."""
|
|
34
|
+
"""QR code content. If None, the QR is pushed to user's client."""
|
|
33
35
|
sig: str
|
|
34
36
|
expired: bool = False
|
|
37
|
+
"""Whether the QR code is expired."""
|
|
35
38
|
|
|
36
39
|
@property
|
|
37
40
|
def pushed(self):
|
|
41
|
+
"""Whether the QR code is pushed to user's client."""
|
|
38
42
|
return self.png is None
|
|
39
43
|
|
|
40
44
|
|
|
@@ -49,9 +53,12 @@ class QrSession(LoginSession):
|
|
|
49
53
|
) -> None:
|
|
50
54
|
super().__init__(login_sig=login_sig, create_time=create_time)
|
|
51
55
|
self.refreshed = refresh_times
|
|
56
|
+
"""QR code refresh times counter."""
|
|
52
57
|
self.current_qr = first_qr
|
|
58
|
+
"""A :class:`QrSession` keeps a :class:`QR` object as current QR code."""
|
|
53
59
|
|
|
54
60
|
def new_qr(self, qr: QR):
|
|
61
|
+
"""Add a new QR code to this session."""
|
|
55
62
|
self.current_qr.expired = True
|
|
56
63
|
self.current_qr = qr
|
|
57
64
|
self.refreshed += 1
|
|
@@ -61,14 +68,36 @@ class _QrHookMixin:
|
|
|
61
68
|
def __init__(self, *args, **kwds) -> None:
|
|
62
69
|
super().__init__(*args, **kwds)
|
|
63
70
|
self.qr_fetched = MT.qr_fetched.with_timeout(60)
|
|
71
|
+
"""This emitter is triggered when a QR code is fetched."""
|
|
64
72
|
self.qr_cancelled = MT.qr_cancelled()
|
|
73
|
+
"""This emitter is triggered when QR login is cancelled."""
|
|
65
74
|
self.cancel = asyncio.Event()
|
|
75
|
+
"""Async-event indicating whether the loop should cancel the QR login."""
|
|
66
76
|
self.refresh = asyncio.Event()
|
|
77
|
+
"""Async-event indicating whether the loop should refresh the QR code immediately."""
|
|
67
78
|
|
|
68
79
|
|
|
69
80
|
class QrLogin(LoginBase[QrSession], _QrHookMixin):
|
|
70
|
-
async def new(self) -> QrSession:
|
|
81
|
+
async def new(self, no_push=False) -> QrSession:
|
|
82
|
+
"""Create a :class:`QrSession`. This method will:
|
|
83
|
+
|
|
84
|
+
1. GET ``xlogin`` url to get ``pt_login_sig`` cookie;
|
|
85
|
+
|
|
86
|
+
#. Try "quick login" (the QR code is pushed to user's client);
|
|
87
|
+
|
|
88
|
+
#. Whether the QR code is pushed or not, a :class:`QR` object is created
|
|
89
|
+
and is hold by the returned :class:`QrSession`.
|
|
90
|
+
|
|
91
|
+
:param no_push: Do not try to push the QR code to user's client.
|
|
92
|
+
:return: a :class:`QrSession`
|
|
93
|
+
|
|
94
|
+
.. versionchanged:: 1.8.3
|
|
95
|
+
|
|
96
|
+
Added :obj:`no_push` param.
|
|
97
|
+
"""
|
|
71
98
|
login_sig = await self._pt_login_sig()
|
|
99
|
+
if no_push:
|
|
100
|
+
return QrSession(await self.show(), login_sig=login_sig)
|
|
72
101
|
|
|
73
102
|
cookie = self.client.cookie_jar.filter_cookies(PTLOGIN2).get("pt_guid_sig")
|
|
74
103
|
push_qr = False
|
|
@@ -88,9 +117,10 @@ class QrLogin(LoginBase[QrSession], _QrHookMixin):
|
|
|
88
117
|
return QrSession(await self.show(push_qr), login_sig=login_sig)
|
|
89
118
|
|
|
90
119
|
async def show(self, push_qr=False) -> QR:
|
|
91
|
-
"""``ptqrshow`` api
|
|
120
|
+
"""This method will call ``ptqrshow`` api and wrap the response QR bytes into :class:`QR`.
|
|
92
121
|
|
|
93
122
|
:param push_qr: push QR to mobile client.
|
|
123
|
+
:return: a :class:`QR` object.
|
|
94
124
|
"""
|
|
95
125
|
data = {
|
|
96
126
|
"appid": self.app.appid,
|
|
@@ -170,26 +200,37 @@ class QrLogin(LoginBase[QrSession], _QrHookMixin):
|
|
|
170
200
|
*,
|
|
171
201
|
refresh_times: int = 6,
|
|
172
202
|
poll_freq: float = 3,
|
|
203
|
+
no_push=False,
|
|
173
204
|
):
|
|
174
|
-
"""Loop until cookie is returned or max
|
|
205
|
+
"""Loop until cookie is returned or max :obj:`refresh_times` exceeds.
|
|
206
|
+
|
|
175
207
|
- This method will emit :obj:`.qr_fetched` event if a new qrcode is fetched.
|
|
176
|
-
|
|
208
|
+
|
|
209
|
+
- If the QR code is not scanned after :obj:`refresh_times`,
|
|
210
|
+
it will raise :exc:`~qqqr.exception.UserTimeout`.
|
|
211
|
+
|
|
177
212
|
- If :obj:`.refresh` is set, it will refresh qrcode at once without increasing expire counter.
|
|
178
|
-
|
|
213
|
+
|
|
214
|
+
- If :obj:`.cancel` is set, it will raise :exc:`~qqqr.exception.UserBreak` before next polling.
|
|
179
215
|
|
|
180
216
|
:meta public:
|
|
181
217
|
:param refresh_times: max qr expire times.
|
|
182
218
|
:param poll_freq: interval between two status polling, in seconds, default as 3.
|
|
219
|
+
:param no_push: Do not try to push the QR code to user's client.
|
|
183
220
|
|
|
184
|
-
:raise `UserTimeout`: if
|
|
221
|
+
:raise `UserTimeout`: if the QR code is not scanned after :obj:`refresh_times` expires.
|
|
185
222
|
:raise `UserBreak`: if :obj:`.cancel` is set.
|
|
223
|
+
|
|
224
|
+
.. versionchanged:: 1.8.3
|
|
225
|
+
|
|
226
|
+
Added :obj:`no_push` param.
|
|
186
227
|
"""
|
|
187
228
|
self.refresh.clear()
|
|
188
229
|
self.cancel.clear()
|
|
189
230
|
|
|
190
231
|
cnt_expire = 0
|
|
191
232
|
renew = False
|
|
192
|
-
sess = await self.new()
|
|
233
|
+
sess = await self.new(no_push)
|
|
193
234
|
|
|
194
235
|
while cnt_expire < refresh_times:
|
|
195
236
|
# BUG: should we wrap hook errors here?
|
|
@@ -206,6 +247,7 @@ class QrLogin(LoginBase[QrSession], _QrHookMixin):
|
|
|
206
247
|
await asyncio.sleep(poll_freq)
|
|
207
248
|
stat = await self.poll(sess)
|
|
208
249
|
if stat.code == StatusCode.Expired:
|
|
250
|
+
sess.current_qr.expired = True
|
|
209
251
|
cnt_expire += 1
|
|
210
252
|
break
|
|
211
253
|
elif stat.code == StatusCode.Authenticated:
|
|
@@ -99,6 +99,7 @@ class _UpHookMixin:
|
|
|
99
99
|
def __init__(self, *args, **kwds) -> None:
|
|
100
100
|
super().__init__(*args, **kwds)
|
|
101
101
|
self.sms_code_input = MT.sms_code_input.with_timeout(60)
|
|
102
|
+
"""This emitter is triggered when SMS verify code is needed during login."""
|
|
102
103
|
|
|
103
104
|
|
|
104
105
|
class UpWebLogin(LoginBase[UpWebSession], _UpHookMixin):
|
|
@@ -132,9 +133,8 @@ class UpWebLogin(LoginBase[UpWebSession], _UpHookMixin):
|
|
|
132
133
|
self.client, self.app.appid, str(self.login_page_url), fake_ip=fake_ip
|
|
133
134
|
)
|
|
134
135
|
|
|
135
|
-
async def new(self):
|
|
136
|
-
"""Create a :class:`UpWebSession`. This will
|
|
137
|
-
about whether this login needs a captcha, sms verification, etc.
|
|
136
|
+
async def new(self) -> UpWebSession:
|
|
137
|
+
"""Create a :class:`UpWebSession`. This will trigger a GET to ``xlogin`` url.
|
|
138
138
|
|
|
139
139
|
:raise `aiohttp.ClientResponseError`: if response status != 200
|
|
140
140
|
|
|
@@ -143,6 +143,11 @@ class UpWebLogin(LoginBase[UpWebSession], _UpHookMixin):
|
|
|
143
143
|
return UpWebSession(await self._pt_login_sig())
|
|
144
144
|
|
|
145
145
|
async def check(self, sess: UpWebSession):
|
|
146
|
+
"""This will call ``check`` api of Qzone, and receive result about
|
|
147
|
+
whether this login needs a captcha, sms verification, etc.
|
|
148
|
+
|
|
149
|
+
:param sess: Session got from :meth:`~UpWebLogin.new`.
|
|
150
|
+
"""
|
|
146
151
|
data = {
|
|
147
152
|
"regmaster": "",
|
|
148
153
|
"pt_tea": 2,
|
|
@@ -217,7 +222,7 @@ class UpWebLogin(LoginBase[UpWebSession], _UpHookMixin):
|
|
|
217
222
|
data.update(const)
|
|
218
223
|
return data
|
|
219
224
|
|
|
220
|
-
async def try_login(self, sess: UpWebSession):
|
|
225
|
+
async def try_login(self, sess: UpWebSession) -> LoginResp:
|
|
221
226
|
"""
|
|
222
227
|
Check if current session meets the login condition.
|
|
223
228
|
It takes a session object and returns response of this try.
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|