From 1db59149f443c9ff951e952ceb8211cfbfdcb287 Mon Sep 17 00:00:00 2001 From: Rationess Date: Tue, 3 Feb 2026 20:32:43 +0300 Subject: [PATCH 01/11] =?UTF-8?q?=D0=BF=D0=BE=D0=BF=D1=80=D0=BE=D0=B2?= =?UTF-8?q?=D0=B0=D0=B8=D0=BB=20get=5Fhastags=20=D0=BD=D0=B0=20get=5Fhasht?= =?UTF-8?q?ags?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- itd/client.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/itd/client.py b/itd/client.py index 714f5cd..54c4786 100644 --- a/itd/client.py +++ b/itd/client.py @@ -1,3 +1,4 @@ +from warnings import deprecated from uuid import UUID from _io import BufferedReader from typing import cast @@ -490,11 +491,23 @@ class Client: raise Forbidden('delete comment') res.raise_for_status() - + @deprecated("get_hastags устарел используйте get_hashtags") @refresh_on_error def get_hastags(self, limit: int = 10) -> list[Hashtag]: """Получить список популярных хэштэгов + Args: + limit (int, optional): Лимит. Defaults to 10. + + Returns: + list[Hashtag]: Список хэштэгов + """ + return self.get_hashtags(10) + + @refresh_on_error + def get_hashtags(self, limit: int = 10) -> list[Hashtag]: + """Получить список популярных хэштэгов + Args: limit (int, optional): Лимит. Defaults to 10. From c9a5dcad10733b0d15ed20ba0d660877baac8a0e Mon Sep 17 00:00:00 2001 From: Rationess Date: Tue, 3 Feb 2026 20:33:28 +0300 Subject: [PATCH 02/11] =?UTF-8?q?=D0=9E=D1=88=D0=B8=D0=B1=D0=BA=D0=B0=20?= =?UTF-8?q?=D0=B2=20=D1=81=D0=BB=D0=BE=D0=B2=D0=B5=20=D0=A1=D1=82=D0=B0?= =?UTF-8?q?=D1=80=D1=8B=D0=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- itd/client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/itd/client.py b/itd/client.py index 54c4786..0823fc3 100644 --- a/itd/client.py +++ b/itd/client.py @@ -81,7 +81,7 @@ class Client: """Смена пароля Args: - old (str): Страый пароль + old (str): Старый пароль new (str): Новый пароль Raises: From af0b2a1acc576048cee24528d7373e1686e2afae Mon Sep 17 00:00:00 2001 From: Rationess Date: Tue, 3 Feb 2026 20:41:34 +0300 Subject: [PATCH 03/11] =?UTF-8?q?=D0=9E=D1=88=D0=B8=D0=B1=D0=BA=D0=B0=20?= =?UTF-8?q?=D0=B2=20=D1=81=D0=BB=D0=BE=D0=B2=D0=B5=20verificate?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- itd/client.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/itd/client.py b/itd/client.py index 0823fc3..487cbd4 100644 --- a/itd/client.py +++ b/itd/client.py @@ -281,7 +281,7 @@ class Client: return [UserFollower.model_validate(user) for user in res.json()['data']['users']], Pagination.model_validate(res.json()['data']['pagination']) - + @deprecated("verificate устарел используйте verify") @refresh_on_error def verificate(self, file_url: str) -> Verification: """Отправить запрос на верификацию @@ -295,6 +295,21 @@ class Client: Returns: Verification: Верификация """ + return self.verify(file_url) + + @refresh_on_error + def verify(self, file_url: str) -> Verification: + """Отправить запрос на верификацию + + Args: + file_url (str): Ссылка на видео + + Raises: + PendingRequestExists: Запрос уже отправлен + + Returns: + Verification: Верификация + """ res = verificate(self.token, file_url) if res.json().get('error', {}).get('code') == 'PENDING_REQUEST_EXISTS': raise PendingRequestExists() @@ -314,7 +329,6 @@ class Client: return VerificationStatus.model_validate(res.json()) - @refresh_on_error def get_who_to_follow(self) -> list[UserWhoToFollow]: """Получить список популярнык пользователей (кого читать) From 2ccd26fc9bb3f5b99cf58ef6d51e81fcec11e738 Mon Sep 17 00:00:00 2001 From: Rationess Date: Tue, 3 Feb 2026 20:42:55 +0300 Subject: [PATCH 04/11] =?UTF-8?q?=D0=9E=D1=88=D0=B8=D0=B1=D0=BA=D0=B0=20?= =?UTF-8?q?=D0=B2=20=D1=81=D0=BB=D0=BE=D0=B2=D0=B5=20=D0=BF=D0=BE=D0=BF?= =?UTF-8?q?=D1=83=D0=BB=D1=8F=D1=80=D0=BD=D1=8B=D1=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- itd/client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/itd/client.py b/itd/client.py index 487cbd4..2bfaf24 100644 --- a/itd/client.py +++ b/itd/client.py @@ -331,7 +331,7 @@ class Client: @refresh_on_error def get_who_to_follow(self) -> list[UserWhoToFollow]: - """Получить список популярнык пользователей (кого читать) + """Получить список популярных пользователей (кого читать) Returns: list[UserWhoToFollow]: Список пользователей From 3ad003a0b1d0a7c0eb6092516da007e4d2099891 Mon Sep 17 00:00:00 2001 From: Rationess Date: Tue, 3 Feb 2026 20:45:06 +0300 Subject: [PATCH 05/11] user limit --- itd/client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/itd/client.py b/itd/client.py index 2bfaf24..217a237 100644 --- a/itd/client.py +++ b/itd/client.py @@ -516,7 +516,7 @@ class Client: Returns: list[Hashtag]: Список хэштэгов """ - return self.get_hashtags(10) + return self.get_hashtags(limit) @refresh_on_error def get_hashtags(self, limit: int = 10) -> list[Hashtag]: From 7ce699e42a1f1651ce6610f4fe4e2cadfd07aeb8 Mon Sep 17 00:00:00 2001 From: Rationess Date: Tue, 3 Feb 2026 20:48:08 +0300 Subject: [PATCH 06/11] =?UTF-8?q?=D0=BB=D0=B8=D1=88=D0=BD=D0=B8=D0=B9=20?= =?UTF-8?q?=D0=B0=D1=80=D0=B3=D1=83=D0=BC=D0=B5=D0=BD=D1=82=20=D0=B2=20doc?= =?UTF-8?q?string?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- itd/client.py | 1 - 1 file changed, 1 deletion(-) diff --git a/itd/client.py b/itd/client.py index 217a237..c4f5602 100644 --- a/itd/client.py +++ b/itd/client.py @@ -373,7 +373,6 @@ class Client: Args: post_id (str): UUID поста content (str): Содержание - reply_comment_id (UUID | None, optional): ID коммента для ответа. Defaults to None. Raises: ValidationError: Ошибка валидации From 80a5a3344379136178917c57f446d0f0faf0abef Mon Sep 17 00:00:00 2001 From: Rationess Date: Tue, 3 Feb 2026 20:55:33 +0300 Subject: [PATCH 07/11] =?UTF-8?q?=D0=BE=D1=88=D0=B8=D0=B1=D0=BA=D0=B0=20?= =?UTF-8?q?=D0=B2=20=D0=BD=D0=B0=D0=B7=D0=B2=D0=B0=D0=BD=D0=B8=D1=8F=D1=85?= =?UTF-8?q?=20get=5Fhastags=20=D0=B8=20get=5Fposts=5Fby=5Fhastag?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- itd/client.py | 6 +++--- itd/routes/hashtags.py | 9 +++++++++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/itd/client.py b/itd/client.py index c4f5602..48c83cd 100644 --- a/itd/client.py +++ b/itd/client.py @@ -8,7 +8,7 @@ from requests.exceptions import HTTPError, ConnectionError from itd.routes.users import get_user, update_profile, follow, unfollow, get_followers, get_following, update_privacy from itd.routes.etc import get_top_clans, get_who_to_follow, get_platform_status from itd.routes.comments import get_comments, add_comment, delete_comment, like_comment, unlike_comment, add_reply_comment -from itd.routes.hashtags import get_hastags, get_posts_by_hastag +from itd.routes.hashtags import get_hashtags, get_posts_by_hashtag from itd.routes.notifications import get_notifications, mark_as_read, mark_all_as_read, get_unread_notifications_count from itd.routes.posts import create_post, get_posts, get_post, edit_post, delete_post, pin_post, repost, view_post, get_liked_posts from itd.routes.reports import report @@ -527,7 +527,7 @@ class Client: Returns: list[Hashtag]: Список хэштэгов """ - res = get_hastags(self.token, limit) + res = get_hashtags(self.token, limit) res.raise_for_status() return [Hashtag.model_validate(hashtag) for hashtag in res.json()['data']['hashtags']] @@ -546,7 +546,7 @@ class Client: list[Post]: Посты Pagination: Пагинация """ - res = get_posts_by_hastag(self.token, hashtag, limit, cursor) + res = get_posts_by_hashtag(self.token, hashtag, limit, cursor) res.raise_for_status() data = res.json()['data'] diff --git a/itd/routes/hashtags.py b/itd/routes/hashtags.py index 72404c4..cd4a836 100644 --- a/itd/routes/hashtags.py +++ b/itd/routes/hashtags.py @@ -1,8 +1,17 @@ +from warnings import deprecated from uuid import UUID from itd.request import fetch +@deprecated("get_hastags устарела используйте get_hashtags") def get_hastags(token: str, limit: int = 10): return fetch(token, 'get', 'hashtags/trending', {'limit': limit}) +def get_hashtags(token: str, limit: int = 10): + return fetch(token, 'get', 'hashtags/trending', {'limit': limit}) + +@deprecated("get_posts_by_hastag устерла используй get_posts_by_hashtag") def get_posts_by_hastag(token: str, hashtag: str, limit: int = 20, cursor: UUID | None = None): return fetch(token, 'get', f'hashtags/{hashtag}/posts', {'limit': limit, 'cursor': cursor}) + +def get_posts_by_hashtag(token: str, hashtag: str, limit: int = 20, cursor: UUID | None = None): + return fetch(token, 'get', f'hashtags/{hashtag}/posts', {'limit': limit, 'cursor': cursor}) From 0c212e41cb8b90a87add5152584c0a85031ef33d Mon Sep 17 00:00:00 2001 From: Rationess Date: Tue, 3 Feb 2026 20:58:22 +0300 Subject: [PATCH 08/11] =?UTF-8?q?=D0=BE=D1=88=D0=B8=D0=B1=D0=BA=D0=B0=20?= =?UTF-8?q?=D0=B2=20=D0=BD=D0=B0=D0=B7=D0=B2=D0=B0=D0=BD=D0=B8=D0=B8=20ver?= =?UTF-8?q?ificate?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- itd/client.py | 4 ++-- itd/routes/verification.py | 8 +++++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/itd/client.py b/itd/client.py index 48c83cd..2ed3ac0 100644 --- a/itd/client.py +++ b/itd/client.py @@ -15,7 +15,7 @@ from itd.routes.reports import report from itd.routes.search import search from itd.routes.files import upload_file from itd.routes.auth import refresh_token, change_password, logout -from itd.routes.verification import verificate, get_verification_status +from itd.routes.verification import verify, get_verification_status from itd.models.comment import Comment from itd.models.notification import Notification @@ -310,7 +310,7 @@ class Client: Returns: Verification: Верификация """ - res = verificate(self.token, file_url) + res = verify(self.token, file_url) if res.json().get('error', {}).get('code') == 'PENDING_REQUEST_EXISTS': raise PendingRequestExists() res.raise_for_status() diff --git a/itd/routes/verification.py b/itd/routes/verification.py index 8c66426..ec643d5 100644 --- a/itd/routes/verification.py +++ b/itd/routes/verification.py @@ -1,8 +1,14 @@ +from warnings import deprecated from itd.request import fetch -def verificate(token: str, file_url: str): +def verify(token: str, file_url: str): # {"success":true,"request":{"id":"fc54e54f-8586-4d8c-809e-df93161f99da","userId":"9096a85b-c319-483e-8940-6921be427ad0","videoUrl":"https://943701f000610900cbe86b72234e451d.bckt.ru/videos/354f28a6-9ac7-48a6-879a-a454062b1d6b.mp4","status":"pending","rejectionReason":null,"reviewedBy":null,"reviewedAt":null,"createdAt":"2026-01-30T12:58:14.228Z","updatedAt":"2026-01-30T12:58:14.228Z"}} return fetch(token, 'post', 'verification/submit', {'videoUrl': file_url}) +@deprecated("verificate устарела используйте verify") +def verificate(token: str, file_url: str): + return verify(token, file_url) + + def get_verification_status(token: str): return fetch(token, 'get', 'verification/status') \ No newline at end of file From 6ac12c6f79b3a3e4d4882d5739aaf3957ee37c51 Mon Sep 17 00:00:00 2001 From: Rationess Date: Tue, 3 Feb 2026 22:20:33 +0300 Subject: [PATCH 09/11] =?UTF-8?q?attachment=5Fids=20=D0=B4=D0=BB=D1=8F=20?= =?UTF-8?q?=D0=BA=D0=BE=D0=BC=D0=BC=D0=B5=D0=BD=D1=82=D0=B0=D1=80=D0=B8?= =?UTF-8?q?=D0=B5=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- itd/client.py | 10 ++++++---- itd/routes/comments.py | 8 ++++---- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/itd/client.py b/itd/client.py index 714f5cd..9b8bd38 100644 --- a/itd/client.py +++ b/itd/client.py @@ -352,12 +352,13 @@ class Client: @refresh_on_error - def add_comment(self, post_id: UUID, content: str) -> Comment: + def add_comment(self, post_id: UUID, content: str, attachment_ids: list[UUID] = []) -> Comment: """Добавить комментарий Args: post_id (str): UUID поста content (str): Содержание + attachment_ids (list[UUID]): Список UUID прикреплённых файлов reply_comment_id (UUID | None, optional): ID коммента для ответа. Defaults to None. Raises: @@ -367,7 +368,7 @@ class Client: Returns: Comment: Комментарий """ - res = add_comment(self.token, post_id, content) + res = add_comment(self.token, post_id, content, attachment_ids) if res.status_code == 422 and 'found' in res.json(): raise ValidationError(*list(res.json()['found'].items())[0]) if res.json().get('error', {}).get('code') == 'NOT_FOUND': @@ -378,13 +379,14 @@ class Client: @refresh_on_error - def add_reply_comment(self, comment_id: UUID, content: str, author_id: UUID) -> Comment: + def add_reply_comment(self, comment_id: UUID, content: str, author_id: UUID, attachment_ids: list[UUID] = []) -> Comment: """Добавить ответный комментарий Args: comment_id (str): UUID комментария content (str): Содержание author_id (UUID | None, optional): ID пользователя, отправившего комментарий. Defaults to None. + attachment_ids (list[UUID]): Список UUID прикреплённых файлов Raises: ValidationError: Ошибка валидации @@ -393,7 +395,7 @@ class Client: Returns: Comment: Комментарий """ - res = add_reply_comment(self.token, comment_id, content, author_id) + res = add_reply_comment(self.token, comment_id, content, author_id, attachment_ids) if res.status_code == 500 and 'Failed query' in res.text: raise NotFound('User') if res.status_code == 422 and 'found' in res.json(): diff --git a/itd/routes/comments.py b/itd/routes/comments.py index d98ddf2..c211b17 100644 --- a/itd/routes/comments.py +++ b/itd/routes/comments.py @@ -2,11 +2,11 @@ from uuid import UUID from itd.request import fetch -def add_comment(token: str, post_id: UUID, content: str): - return fetch(token, 'post', f'posts/{post_id}/comments', {'content': content}) +def add_comment(token: str, post_id: UUID, content: str, attachment_ids: list[UUID] = []): + return fetch(token, 'post', f'posts/{post_id}/comments', {'content': content, "attachmentIds": list(map(str, attachment_ids))}) -def add_reply_comment(token: str, comment_id: UUID, content: str, author_id: UUID): - return fetch(token, 'post', f'comments/{comment_id}/replies', {'content': content, 'replyToUserId': str(author_id)}) +def add_reply_comment(token: str, comment_id: UUID, content: str, author_id: UUID, attachment_ids: list[UUID] = []): + return fetch(token, 'post', f'comments/{comment_id}/replies', {'content': content, 'replyToUserId': str(author_id), "attachmentIds": list(map(str, attachment_ids))}) def get_comments(token: str, post_id: UUID, limit: int = 20, cursor: int = 0, sort: str = 'popular'): return fetch(token, 'get', f'posts/{post_id}/comments', {'limit': limit, 'sort': sort, 'cursor': cursor}) From a547bbfdfb833866aa9182545d99426ddf540dbe Mon Sep 17 00:00:00 2001 From: Rationess Date: Tue, 3 Feb 2026 22:22:27 +0300 Subject: [PATCH 10/11] =?UTF-8?q?mime=5Ftype=20=D0=BD=D0=B5=20=D1=82=D0=BE?= =?UTF-8?q?=D0=BB=D1=8C=D0=BA=D0=BE=20png=20=D1=82=D0=B0=D0=BC=20=D0=BC?= =?UTF-8?q?=D0=BE=D0=B6=D0=B5=D1=82=20=D0=B1=D1=8B=D1=82=D1=8C=20=D0=B8=20?= =?UTF-8?q?jpg=20=D0=B8=20gid.=20=D0=95=D1=89=D1=91=20=D0=B8=20=D0=B0?= =?UTF-8?q?=D1=83=D0=B4=D0=B8=D0=BE=20=D1=84=D0=BE=D1=80=D0=BC=D0=B0=D1=82?= =?UTF-8?q?=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- itd/models/file.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/itd/models/file.py b/itd/models/file.py index f7f34e7..635df8c 100644 --- a/itd/models/file.py +++ b/itd/models/file.py @@ -8,7 +8,7 @@ class File(BaseModel): id: UUID url: str filename: str - mime_type: str = Field('image/png', alias='mimeType') + mime_type: str = Field(alias='mimeType') size: int From 2f026a32d7a9ee6909d50aea5891156880327da8 Mon Sep 17 00:00:00 2001 From: firedotguy Date: Wed, 4 Feb 2026 22:52:10 +0300 Subject: [PATCH 11/11] feat: add cant follow yourself error --- .gitignore | 1 + itd/client.py | 19 ++++++++++--------- itd/exceptions.py | 20 +++++++++++++++++--- itd/request.py | 13 +++++++++---- 4 files changed, 37 insertions(+), 16 deletions(-) diff --git a/.gitignore b/.gitignore index ddc7b0c..0faebdf 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ test.py +like.py venv/ __pycache__/ dist diff --git a/itd/client.py b/itd/client.py index 714f5cd..3a4b4e5 100644 --- a/itd/client.py +++ b/itd/client.py @@ -2,7 +2,7 @@ from uuid import UUID from _io import BufferedReader from typing import cast -from requests.exceptions import HTTPError, ConnectionError +from requests.exceptions import ConnectionError, HTTPError from itd.routes.users import get_user, update_profile, follow, unfollow, get_followers, get_following, update_privacy from itd.routes.etc import get_top_clans, get_who_to_follow, get_platform_status @@ -26,20 +26,18 @@ from itd.models.pagination import Pagination from itd.models.verification import Verification, VerificationStatus from itd.request import set_cookies -from itd.exceptions import NoCookie, NoAuthData, SamePassword, InvalidOldPassword, NotFound, ValidationError, UserBanned, PendingRequestExists, Forbidden, UsernameTaken +from itd.exceptions import NoCookie, NoAuthData, SamePassword, InvalidOldPassword, NotFound, ValidationError, UserBanned, PendingRequestExists, Forbidden, UsernameTaken, CantFollowYourself, Unauthorized def refresh_on_error(func): def wrapper(self, *args, **kwargs): - try: - return func(self, *args, **kwargs) - except HTTPError as e: - if '401' in str(e): + if self.cookies: + try: + return func(self, *args, **kwargs) + except (Unauthorized, ConnectionError, HTTPError): self.refresh_auth() return func(self, *args, **kwargs) - raise e - except ConnectionError: - self.refresh_auth() + else: return func(self, *args, **kwargs) return wrapper @@ -203,6 +201,7 @@ class Client: Raises: NotFound: Пользователь не найден + CantFollowYourself: Невозможно подписаться на самого себе Returns: int: Число подписчиков после подписки @@ -210,6 +209,8 @@ class Client: res = follow(self.token, username) if res.json().get('error', {}).get('code') == 'NOT_FOUND': raise NotFound('User') + if res.json().get('error', {}).get('code') == 'VALIDATION_ERROR' and res.status_code == 400: + raise CantFollowYourself() res.raise_for_status() return res.json()['followersCount'] diff --git a/itd/exceptions.py b/itd/exceptions.py index f1cc39f..1963ed9 100644 --- a/itd/exceptions.py +++ b/itd/exceptions.py @@ -7,14 +7,20 @@ class NoAuthData(Exception): return 'No auth data. Provide token or cookies' class InvalidCookie(Exception): + def __init__(self, code: str): + self.code = code def __str__(self): - return f'Invalid cookie data' + if self.code == 'SESSION_NOT_FOUND': + return f'Invalid cookie data: Session not found (incorrect refresh token)' + elif self.code == 'REFRESH_TOKEN_MISSING': + return f'Invalid cookie data: No refresh token' + # SESSION_REVOKED + return f'Invalid cookie data: Session revoked (logged out)' class InvalidToken(Exception): def __str__(self): return f'Invalid access token' - class SamePassword(Exception): def __str__(self): return 'Old and new password must not equals' @@ -58,4 +64,12 @@ class Forbidden(Exception): class UsernameTaken(Exception): def __str__(self): - return 'Username is already taken' \ No newline at end of file + return 'Username is already taken' + +class CantFollowYourself(Exception): + def __str__(self): + return 'Cannot follow yourself' + +class Unauthorized(Exception): + def __str__(self) -> str: + return 'Auth required - refresh token' \ No newline at end of file diff --git a/itd/request.py b/itd/request.py index 909ed31..ac4a2d7 100644 --- a/itd/request.py +++ b/itd/request.py @@ -3,7 +3,7 @@ from _io import BufferedReader from requests import Session from requests.exceptions import JSONDecodeError -from itd.exceptions import InvalidToken, InvalidCookie, RateLimitExceeded +from itd.exceptions import InvalidToken, InvalidCookie, RateLimitExceeded, Unauthorized s = Session() @@ -35,10 +35,13 @@ def fetch(token: str, method: str, url: str, params: dict = {}, files: dict[str, try: if res.json().get('error', {}).get('code') == 'RATE_LIMIT_EXCEEDED': raise RateLimitExceeded(res.json()['error'].get('retryAfter', 0)) + if res.json().get('error', {}).get('code') == 'UNAUTHORIZED': + raise Unauthorized() except JSONDecodeError: pass - print(res.text) + if not res.ok: + print(res.text) return res @@ -82,8 +85,10 @@ def auth_fetch(cookies: str, method: str, url: str, params: dict = {}, token: st try: if res.json().get('error', {}).get('code') == 'RATE_LIMIT_EXCEEDED': raise RateLimitExceeded(res.json()['error'].get('retryAfter', 0)) - if res.json().get('error', {}).get('code') in ('SESSION_NOT_FOUND', 'REFRESH_TOKEN_MISSING'): - raise InvalidCookie() + if res.json().get('error', {}).get('code') in ('SESSION_NOT_FOUND', 'REFRESH_TOKEN_MISSING', 'SESSION_REVOKED'): + raise InvalidCookie(res.json()['error']['code']) + if res.json().get('error', {}).get('code') == 'UNAUTHORIZED': + raise Unauthorized() except JSONDecodeError: pass