vkx 0.2.2__tar.gz → 0.2.3__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.
- {vkx-0.2.2 → vkx-0.2.3}/PKG-INFO +5 -1
- {vkx-0.2.2 → vkx-0.2.3}/README.md +4 -0
- {vkx-0.2.2 → vkx-0.2.3}/pyproject.toml +1 -1
- {vkx-0.2.2 → vkx-0.2.3}/src/vkx/client/client.py +8 -5
- {vkx-0.2.2 → vkx-0.2.3}/src/vkx/client/http.py +15 -0
- {vkx-0.2.2 → vkx-0.2.3}/src/vkx/client/tokens.py +28 -4
- {vkx-0.2.2 → vkx-0.2.3}/.gitignore +0 -0
- {vkx-0.2.2 → vkx-0.2.3}/LICENSE +0 -0
- {vkx-0.2.2 → vkx-0.2.3}/examples/README.md +0 -0
- {vkx-0.2.2 → vkx-0.2.3}/src/vkx/__init__.py +0 -0
- {vkx-0.2.2 → vkx-0.2.3}/src/vkx/adapters/__init__.py +0 -0
- {vkx-0.2.2 → vkx-0.2.3}/src/vkx/adapters/_common.py +0 -0
- {vkx-0.2.2 → vkx-0.2.3}/src/vkx/adapters/aiohttp.py +0 -0
- {vkx-0.2.2 → vkx-0.2.3}/src/vkx/adapters/django.py +0 -0
- {vkx-0.2.2 → vkx-0.2.3}/src/vkx/adapters/fastapi.py +0 -0
- {vkx-0.2.2 → vkx-0.2.3}/src/vkx/adapters/flask.py +0 -0
- {vkx-0.2.2 → vkx-0.2.3}/src/vkx/adapters/sanic.py +0 -0
- {vkx-0.2.2 → vkx-0.2.3}/src/vkx/adapters/starlette.py +0 -0
- {vkx-0.2.2 → vkx-0.2.3}/src/vkx/client/__init__.py +0 -0
- {vkx-0.2.2 → vkx-0.2.3}/src/vkx/client/errors.py +0 -0
- {vkx-0.2.2 → vkx-0.2.3}/src/vkx/client/pagination.py +0 -0
- {vkx-0.2.2 → vkx-0.2.3}/src/vkx/client/resolve.py +0 -0
- {vkx-0.2.2 → vkx-0.2.3}/src/vkx/client/storage.py +0 -0
- {vkx-0.2.2 → vkx-0.2.3}/src/vkx/client/upload.py +0 -0
- {vkx-0.2.2 → vkx-0.2.3}/src/vkx/models/__init__.py +0 -0
- {vkx-0.2.2 → vkx-0.2.3}/src/vkx/models/base_model.py +0 -0
- {vkx-0.2.2 → vkx-0.2.3}/src/vkx/models/categories.py +0 -0
- {vkx-0.2.2 → vkx-0.2.3}/src/vkx/models/events/__init__.py +0 -0
- {vkx-0.2.2 → vkx-0.2.3}/src/vkx/models/events/bot_events.py +0 -0
- {vkx-0.2.2 → vkx-0.2.3}/src/vkx/models/events/callback_events.py +0 -0
- {vkx-0.2.2 → vkx-0.2.3}/src/vkx/models/events/enums/__init__.py +0 -0
- {vkx-0.2.2 → vkx-0.2.3}/src/vkx/models/events/enums/callback_events.py +0 -0
- {vkx-0.2.2 → vkx-0.2.3}/src/vkx/models/events/enums/group_events.py +0 -0
- {vkx-0.2.2 → vkx-0.2.3}/src/vkx/models/events/enums/user_events.py +0 -0
- {vkx-0.2.2 → vkx-0.2.3}/src/vkx/models/events/objects/__init__.py +0 -0
- {vkx-0.2.2 → vkx-0.2.3}/src/vkx/models/events/objects/group_event_objects.py +0 -0
- {vkx-0.2.2 → vkx-0.2.3}/src/vkx/models/events/objects/user_event_objects.py +0 -0
- {vkx-0.2.2 → vkx-0.2.3}/src/vkx/models/events/user_events.py +0 -0
- {vkx-0.2.2 → vkx-0.2.3}/src/vkx/models/formatting.py +0 -0
- {vkx-0.2.2 → vkx-0.2.3}/src/vkx/models/methods/__init__.py +0 -0
- {vkx-0.2.2 → vkx-0.2.3}/src/vkx/models/methods/account.py +0 -0
- {vkx-0.2.2 → vkx-0.2.3}/src/vkx/models/methods/ads.py +0 -0
- {vkx-0.2.2 → vkx-0.2.3}/src/vkx/models/methods/app_widgets.py +0 -0
- {vkx-0.2.2 → vkx-0.2.3}/src/vkx/models/methods/apps.py +0 -0
- {vkx-0.2.2 → vkx-0.2.3}/src/vkx/models/methods/auth.py +0 -0
- {vkx-0.2.2 → vkx-0.2.3}/src/vkx/models/methods/base_category.py +0 -0
- {vkx-0.2.2 → vkx-0.2.3}/src/vkx/models/methods/board.py +0 -0
- {vkx-0.2.2 → vkx-0.2.3}/src/vkx/models/methods/bugtracker.py +0 -0
- {vkx-0.2.2 → vkx-0.2.3}/src/vkx/models/methods/calls.py +0 -0
- {vkx-0.2.2 → vkx-0.2.3}/src/vkx/models/methods/database.py +0 -0
- {vkx-0.2.2 → vkx-0.2.3}/src/vkx/models/methods/docs.py +0 -0
- {vkx-0.2.2 → vkx-0.2.3}/src/vkx/models/methods/donut.py +0 -0
- {vkx-0.2.2 → vkx-0.2.3}/src/vkx/models/methods/downloaded_games.py +0 -0
- {vkx-0.2.2 → vkx-0.2.3}/src/vkx/models/methods/fave.py +0 -0
- {vkx-0.2.2 → vkx-0.2.3}/src/vkx/models/methods/friends.py +0 -0
- {vkx-0.2.2 → vkx-0.2.3}/src/vkx/models/methods/gifts.py +0 -0
- {vkx-0.2.2 → vkx-0.2.3}/src/vkx/models/methods/groups.py +0 -0
- {vkx-0.2.2 → vkx-0.2.3}/src/vkx/models/methods/lead_forms.py +0 -0
- {vkx-0.2.2 → vkx-0.2.3}/src/vkx/models/methods/likes.py +0 -0
- {vkx-0.2.2 → vkx-0.2.3}/src/vkx/models/methods/market.py +0 -0
- {vkx-0.2.2 → vkx-0.2.3}/src/vkx/models/methods/messages.py +0 -0
- {vkx-0.2.2 → vkx-0.2.3}/src/vkx/models/methods/newsfeed.py +0 -0
- {vkx-0.2.2 → vkx-0.2.3}/src/vkx/models/methods/notes.py +0 -0
- {vkx-0.2.2 → vkx-0.2.3}/src/vkx/models/methods/notifications.py +0 -0
- {vkx-0.2.2 → vkx-0.2.3}/src/vkx/models/methods/orders.py +0 -0
- {vkx-0.2.2 → vkx-0.2.3}/src/vkx/models/methods/pages.py +0 -0
- {vkx-0.2.2 → vkx-0.2.3}/src/vkx/models/methods/photos.py +0 -0
- {vkx-0.2.2 → vkx-0.2.3}/src/vkx/models/methods/podcasts.py +0 -0
- {vkx-0.2.2 → vkx-0.2.3}/src/vkx/models/methods/polls.py +0 -0
- {vkx-0.2.2 → vkx-0.2.3}/src/vkx/models/methods/pretty_cards.py +0 -0
- {vkx-0.2.2 → vkx-0.2.3}/src/vkx/models/methods/search.py +0 -0
- {vkx-0.2.2 → vkx-0.2.3}/src/vkx/models/methods/secure.py +0 -0
- {vkx-0.2.2 → vkx-0.2.3}/src/vkx/models/methods/stats.py +0 -0
- {vkx-0.2.2 → vkx-0.2.3}/src/vkx/models/methods/status.py +0 -0
- {vkx-0.2.2 → vkx-0.2.3}/src/vkx/models/methods/storage.py +0 -0
- {vkx-0.2.2 → vkx-0.2.3}/src/vkx/models/methods/store.py +0 -0
- {vkx-0.2.2 → vkx-0.2.3}/src/vkx/models/methods/stories.py +0 -0
- {vkx-0.2.2 → vkx-0.2.3}/src/vkx/models/methods/streaming.py +0 -0
- {vkx-0.2.2 → vkx-0.2.3}/src/vkx/models/methods/translations.py +0 -0
- {vkx-0.2.2 → vkx-0.2.3}/src/vkx/models/methods/users.py +0 -0
- {vkx-0.2.2 → vkx-0.2.3}/src/vkx/models/methods/utils.py +0 -0
- {vkx-0.2.2 → vkx-0.2.3}/src/vkx/models/methods/video.py +0 -0
- {vkx-0.2.2 → vkx-0.2.3}/src/vkx/models/methods/wall.py +0 -0
- {vkx-0.2.2 → vkx-0.2.3}/src/vkx/models/methods/widgets.py +0 -0
- {vkx-0.2.2 → vkx-0.2.3}/src/vkx/models/objects.py +0 -0
- {vkx-0.2.2 → vkx-0.2.3}/src/vkx/models/responses/__init__.py +0 -0
- {vkx-0.2.2 → vkx-0.2.3}/src/vkx/models/responses/account.py +0 -0
- {vkx-0.2.2 → vkx-0.2.3}/src/vkx/models/responses/ads.py +0 -0
- {vkx-0.2.2 → vkx-0.2.3}/src/vkx/models/responses/app_widgets.py +0 -0
- {vkx-0.2.2 → vkx-0.2.3}/src/vkx/models/responses/apps.py +0 -0
- {vkx-0.2.2 → vkx-0.2.3}/src/vkx/models/responses/auth.py +0 -0
- {vkx-0.2.2 → vkx-0.2.3}/src/vkx/models/responses/base.py +0 -0
- {vkx-0.2.2 → vkx-0.2.3}/src/vkx/models/responses/board.py +0 -0
- {vkx-0.2.2 → vkx-0.2.3}/src/vkx/models/responses/bugtracker.py +0 -0
- {vkx-0.2.2 → vkx-0.2.3}/src/vkx/models/responses/calls.py +0 -0
- {vkx-0.2.2 → vkx-0.2.3}/src/vkx/models/responses/database.py +0 -0
- {vkx-0.2.2 → vkx-0.2.3}/src/vkx/models/responses/docs.py +0 -0
- {vkx-0.2.2 → vkx-0.2.3}/src/vkx/models/responses/donut.py +0 -0
- {vkx-0.2.2 → vkx-0.2.3}/src/vkx/models/responses/downloaded_games.py +0 -0
- {vkx-0.2.2 → vkx-0.2.3}/src/vkx/models/responses/fave.py +0 -0
- {vkx-0.2.2 → vkx-0.2.3}/src/vkx/models/responses/friends.py +0 -0
- {vkx-0.2.2 → vkx-0.2.3}/src/vkx/models/responses/gifts.py +0 -0
- {vkx-0.2.2 → vkx-0.2.3}/src/vkx/models/responses/groups.py +0 -0
- {vkx-0.2.2 → vkx-0.2.3}/src/vkx/models/responses/lead_forms.py +0 -0
- {vkx-0.2.2 → vkx-0.2.3}/src/vkx/models/responses/likes.py +0 -0
- {vkx-0.2.2 → vkx-0.2.3}/src/vkx/models/responses/market.py +0 -0
- {vkx-0.2.2 → vkx-0.2.3}/src/vkx/models/responses/messages.py +0 -0
- {vkx-0.2.2 → vkx-0.2.3}/src/vkx/models/responses/newsfeed.py +0 -0
- {vkx-0.2.2 → vkx-0.2.3}/src/vkx/models/responses/notes.py +0 -0
- {vkx-0.2.2 → vkx-0.2.3}/src/vkx/models/responses/notifications.py +0 -0
- {vkx-0.2.2 → vkx-0.2.3}/src/vkx/models/responses/orders.py +0 -0
- {vkx-0.2.2 → vkx-0.2.3}/src/vkx/models/responses/pages.py +0 -0
- {vkx-0.2.2 → vkx-0.2.3}/src/vkx/models/responses/photos.py +0 -0
- {vkx-0.2.2 → vkx-0.2.3}/src/vkx/models/responses/podcasts.py +0 -0
- {vkx-0.2.2 → vkx-0.2.3}/src/vkx/models/responses/pretty_cards.py +0 -0
- {vkx-0.2.2 → vkx-0.2.3}/src/vkx/models/responses/search.py +0 -0
- {vkx-0.2.2 → vkx-0.2.3}/src/vkx/models/responses/store.py +0 -0
- {vkx-0.2.2 → vkx-0.2.3}/src/vkx/models/responses/stories.py +0 -0
- {vkx-0.2.2 → vkx-0.2.3}/src/vkx/models/responses/streaming.py +0 -0
- {vkx-0.2.2 → vkx-0.2.3}/src/vkx/models/responses/translations.py +0 -0
- {vkx-0.2.2 → vkx-0.2.3}/src/vkx/models/responses/users.py +0 -0
- {vkx-0.2.2 → vkx-0.2.3}/src/vkx/models/responses/utils.py +0 -0
- {vkx-0.2.2 → vkx-0.2.3}/src/vkx/models/responses/video.py +0 -0
- {vkx-0.2.2 → vkx-0.2.3}/src/vkx/models/responses/wall.py +0 -0
- {vkx-0.2.2 → vkx-0.2.3}/src/vkx/models/responses/widgets.py +0 -0
- {vkx-0.2.2 → vkx-0.2.3}/src/vkx/py.typed +0 -0
- {vkx-0.2.2 → vkx-0.2.3}/src/vkx/server/__init__.py +0 -0
- {vkx-0.2.2 → vkx-0.2.3}/src/vkx/server/_polling.py +0 -0
- {vkx-0.2.2 → vkx-0.2.3}/src/vkx/server/bots_longpoll.py +0 -0
- {vkx-0.2.2 → vkx-0.2.3}/src/vkx/server/callback.py +0 -0
- {vkx-0.2.2 → vkx-0.2.3}/src/vkx/server/callback_server.py +0 -0
- {vkx-0.2.2 → vkx-0.2.3}/src/vkx/server/longpoll.py +0 -0
{vkx-0.2.2 → vkx-0.2.3}/PKG-INFO
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: vkx
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.3
|
|
4
4
|
Summary: Асинхронный клиент VK API: выбор токена по scope, батчинг через execute, типы API/событий и разбор Callback/Long Poll.
|
|
5
5
|
Project-URL: Homepage, https://github.com/matrixd0t/vkx
|
|
6
6
|
Project-URL: Repository, https://github.com/matrixd0t/vkx
|
|
@@ -108,10 +108,14 @@ from vkx import VKClient
|
|
|
108
108
|
vk = VKClient(tokens="vk1.a....")
|
|
109
109
|
vk = VKClient(cookies={"p": "...", "remixsid": "..."})
|
|
110
110
|
vk = VKClient(tokens=["tok_a", "tok_b"], cookies=[{"p": ..., "remixsid": ...}])
|
|
111
|
+
# переопределить User-Agent HTTP-клиента:
|
|
112
|
+
vk = VKClient(tokens="vk1.a....", user_agent="MyApp/1.0")
|
|
111
113
|
```
|
|
112
114
|
|
|
113
115
|
Конструктор не ходит в сеть; сеть трогается при первом `call()` или явном
|
|
114
116
|
`await vk.probe()`.
|
|
117
|
+
Если передан `user_agent`, он заменяет заголовок `User-Agent` HTTP-клиента;
|
|
118
|
+
переданный вручную `http_client` должен предоставлять изменяемый `headers`.
|
|
115
119
|
|
|
116
120
|
### Владелец и права
|
|
117
121
|
|
|
@@ -80,10 +80,14 @@ from vkx import VKClient
|
|
|
80
80
|
vk = VKClient(tokens="vk1.a....")
|
|
81
81
|
vk = VKClient(cookies={"p": "...", "remixsid": "..."})
|
|
82
82
|
vk = VKClient(tokens=["tok_a", "tok_b"], cookies=[{"p": ..., "remixsid": ...}])
|
|
83
|
+
# переопределить User-Agent HTTP-клиента:
|
|
84
|
+
vk = VKClient(tokens="vk1.a....", user_agent="MyApp/1.0")
|
|
83
85
|
```
|
|
84
86
|
|
|
85
87
|
Конструктор не ходит в сеть; сеть трогается при первом `call()` или явном
|
|
86
88
|
`await vk.probe()`.
|
|
89
|
+
Если передан `user_agent`, он заменяет заголовок `User-Agent` HTTP-клиента;
|
|
90
|
+
переданный вручную `http_client` должен предоставлять изменяемый `headers`.
|
|
87
91
|
|
|
88
92
|
### Владелец и права
|
|
89
93
|
|
|
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "vkx"
|
|
7
|
-
version = "0.2.
|
|
7
|
+
version = "0.2.3"
|
|
8
8
|
description = "Асинхронный клиент VK API: выбор токена по scope, батчинг через execute, типы API/событий и разбор Callback/Long Poll."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.12"
|
|
@@ -19,10 +19,10 @@ TokenSource), cookies (словари с p и remixsid) и sources (готовы
|
|
|
19
19
|
|
|
20
20
|
HTTP: клиент работает с протоколом HttpClient (асинхронные get/post); httpx —
|
|
21
21
|
опциональная зависимость, создаётся лениво, если свой клиент не передан.
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
приоритетнее.
|
|
22
|
+
user_agent при передаче заменяет User-Agent в заголовках HTTP-клиента.
|
|
23
|
+
http_client / base_api_url / v задаются у клиента и могут быть переопределены для
|
|
24
|
+
отдельного запроса (call); method_versions задаёт версии по умолчанию отдельных
|
|
25
|
+
методов (messages.send и messages.edit используют v=5.281). Явный v вызова приоритетнее.
|
|
26
26
|
|
|
27
27
|
Очередь и батчинг: call() фиксирует маршрут запроса (_Queued: кандидаты, HTTP-
|
|
28
28
|
настройки и текущий источник) и кладёт его в очередь; PendingApiCall ждёт
|
|
@@ -60,7 +60,7 @@ from ..models.formatting import (
|
|
|
60
60
|
)
|
|
61
61
|
from . import pagination
|
|
62
62
|
from .errors import VKError, VKTimeoutError, VKTransportError, build_error
|
|
63
|
-
from .http import API_HOST, API_VERSION, HttpClient, create_http_client
|
|
63
|
+
from .http import API_HOST, API_VERSION, HttpClient, create_http_client, override_user_agent
|
|
64
64
|
from .resolve import (
|
|
65
65
|
DEFAULT_RESOLVE_CACHE_SIZE,
|
|
66
66
|
DEFAULT_RESOLVE_CACHE_TTL,
|
|
@@ -504,6 +504,7 @@ class VKClient(APICategories):
|
|
|
504
504
|
*,
|
|
505
505
|
logger: logging.Logger | None = None,
|
|
506
506
|
http_client: HttpClient | None = None,
|
|
507
|
+
user_agent: str | None = None,
|
|
507
508
|
base_api_url: str = API_HOST,
|
|
508
509
|
v: str = API_VERSION,
|
|
509
510
|
method_versions: Mapping[str, str] | None = None,
|
|
@@ -539,6 +540,8 @@ class VKClient(APICategories):
|
|
|
539
540
|
explicit_sources = _source_objects(sources)
|
|
540
541
|
self._own_http = http_client is None
|
|
541
542
|
self._http: HttpClient = http_client or create_http_client()
|
|
543
|
+
if user_agent is not None:
|
|
544
|
+
override_user_agent(self._http, user_agent)
|
|
542
545
|
self._base_api_url = base_api_url.rstrip("/")
|
|
543
546
|
built: list[TokenSource] = [
|
|
544
547
|
*token_sources,
|
|
@@ -8,6 +8,7 @@ status_code / text / json(). httpx — опциональная зависимо
|
|
|
8
8
|
|
|
9
9
|
from __future__ import annotations
|
|
10
10
|
|
|
11
|
+
from collections.abc import MutableMapping
|
|
11
12
|
from typing import Any, Protocol, cast, runtime_checkable
|
|
12
13
|
|
|
13
14
|
DEFAULT_USER_AGENT = "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:159.0) Gecko/20100101 Firefox/159.0"
|
|
@@ -43,6 +44,20 @@ class HttpClient(Protocol):
|
|
|
43
44
|
async def aclose(self) -> None: ...
|
|
44
45
|
|
|
45
46
|
|
|
47
|
+
def override_user_agent(http_client: HttpClient, user_agent: str) -> None:
|
|
48
|
+
"""Переопределить User-Agent в заголовках HTTP-клиента."""
|
|
49
|
+
headers = getattr(http_client, "headers", None)
|
|
50
|
+
if not isinstance(headers, MutableMapping):
|
|
51
|
+
raise TypeError(
|
|
52
|
+
"user_agent: HTTP-клиент должен предоставлять изменяемые заголовки headers"
|
|
53
|
+
)
|
|
54
|
+
|
|
55
|
+
for name in tuple(headers):
|
|
56
|
+
if isinstance(name, str) and name.casefold() == "user-agent":
|
|
57
|
+
del headers[name]
|
|
58
|
+
headers["User-Agent"] = user_agent
|
|
59
|
+
|
|
60
|
+
|
|
46
61
|
def create_http_client() -> HttpClient:
|
|
47
62
|
"""HTTP-клиент по умолчанию; httpx импортируется лениво (опциональная зависимость)."""
|
|
48
63
|
try:
|
|
@@ -20,7 +20,8 @@ from __future__ import annotations
|
|
|
20
20
|
|
|
21
21
|
import contextlib
|
|
22
22
|
import time
|
|
23
|
-
from
|
|
23
|
+
from collections.abc import Iterable
|
|
24
|
+
from typing import Any, Protocol, Self, cast, runtime_checkable
|
|
24
25
|
|
|
25
26
|
from .http import HttpClient, create_http_client
|
|
26
27
|
from .storage import State, Store
|
|
@@ -279,8 +280,9 @@ class WebCookieSource(_StatefulSource):
|
|
|
279
280
|
|
|
280
281
|
refresh_seconds=300 — токен живёт максимум 5 минут, затем обновляется.
|
|
281
282
|
Если VK вернул свой expires — берётся минимальный срок. Cookies и токен
|
|
282
|
-
переживают перезапуск через Store (по умолчанию SQLite CWD/.vkx/vkx.sqlite)
|
|
283
|
-
|
|
283
|
+
переживают перезапуск через Store (по умолчанию SQLite CWD/.vkx/vkx.sqlite).
|
|
284
|
+
Если ответ VK содержит новые p/remixsid в Set-Cookie, источник сохраняет
|
|
285
|
+
их для следующих запросов. Это не продлевает сессию без решения сервера.
|
|
284
286
|
"""
|
|
285
287
|
|
|
286
288
|
def __init__(
|
|
@@ -326,7 +328,7 @@ class WebCookieSource(_StatefulSource):
|
|
|
326
328
|
return self._token
|
|
327
329
|
|
|
328
330
|
async def refresh(self) -> None:
|
|
329
|
-
"""
|
|
331
|
+
"""Обновить веб-токен и принять новые значения cookies, если их прислал VK."""
|
|
330
332
|
await self._ensure_cookies()
|
|
331
333
|
response = await self._http.post(
|
|
332
334
|
WEB_TOKEN_URL,
|
|
@@ -338,11 +340,14 @@ class WebCookieSource(_StatefulSource):
|
|
|
338
340
|
},
|
|
339
341
|
cookies=self._cookies,
|
|
340
342
|
)
|
|
343
|
+
cookies_updated = self._update_cookies(response)
|
|
341
344
|
try:
|
|
342
345
|
data = response.json()["data"]
|
|
343
346
|
value = str(data["access_token"])
|
|
344
347
|
expires = float(data["expires"])
|
|
345
348
|
except (ValueError, KeyError, TypeError) as exc:
|
|
349
|
+
if cookies_updated:
|
|
350
|
+
await self._save()
|
|
346
351
|
raise TokenSourceError(
|
|
347
352
|
f"act=web_token: не удалось получить токен (HTTP {response.status_code}) "
|
|
348
353
|
f"— сессия истекла, либо ошибка: {response.text[:200]}"
|
|
@@ -356,6 +361,25 @@ class WebCookieSource(_StatefulSource):
|
|
|
356
361
|
)
|
|
357
362
|
await self._save()
|
|
358
363
|
|
|
364
|
+
def _update_cookies(self, response: Any) -> bool:
|
|
365
|
+
"""Скопировать ротацию p/remixsid из Set-Cookie-ответа HTTP-клиента."""
|
|
366
|
+
response_cookies = getattr(response, "cookies", None)
|
|
367
|
+
items = getattr(response_cookies, "items", None)
|
|
368
|
+
if not callable(items):
|
|
369
|
+
return False
|
|
370
|
+
|
|
371
|
+
cookies = self._cookies
|
|
372
|
+
if cookies is None:
|
|
373
|
+
return False
|
|
374
|
+
|
|
375
|
+
updated = False
|
|
376
|
+
entries = cast(Iterable[tuple[str, object]], items())
|
|
377
|
+
for name, value in entries:
|
|
378
|
+
if name in REQUIRED_WEB_COOKIES and cookies.get(name) != str(value):
|
|
379
|
+
cookies[name] = str(value)
|
|
380
|
+
updated = True
|
|
381
|
+
return updated
|
|
382
|
+
|
|
359
383
|
# --- персистентность состояния ---
|
|
360
384
|
|
|
361
385
|
def state(self) -> State:
|
|
File without changes
|
{vkx-0.2.2 → vkx-0.2.3}/LICENSE
RENAMED
|
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
|
|
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
|
|
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
|