Асинхронный клиент для итд.com
Project description
aioitd
Асинхронный Python клиент для итд.com
документация: https://EpsilonRationes.github.io/aioitd/
Установка
pip install aioitd
Без авторизации
Апи хештегов доступно без авторизации.
from aioitd import AsyncITDClient
import asyncio
async def main():
async with AsyncITDClient() as client:
hashtags = await client.search_hashtags('a')
for hashtag in hashtags:
print(f"#{hashtag.name}: {hashtag.posts_count}")
asyncio.run(main())
Авторизация
Для остальных функций необходим refresh_token
Чтобы получить refresh_token:
- Войди в аккаунт на итд.com
- Откройть devtools
- Среди табов выбрать network (сеть)
- Перезагрузить страницу
- Найти запрос
refresh - В куки запроса скопировать
refresh_token
Или:
- Войти в аккаунт на итд.com
- Откройть devtools
- Среди табов выбрать application (приложение)
- Перезагрузить страницу
- Выбрать куки и найти куку
refersh_token
После передайте refresh_token в AsyncITDClient:
from aioitd import AsyncITDClient
import asyncio
refresh_token = "ca1291a4a990b985a57b880ed3fb863eef80ac3990acc68e8f106a783e3af402"
async def main():
async with AsyncITDClient(refresh_token) as client:
user = await client.get_user("nowkie")
print(
f"id: {user.id}\n"
f"username: {user.username}\n"
f"follower_count: {user.followers_count}"
)
asyncio.run(main())
Создание поста
from aioitd import AsyncITDClient, File, Post
import asyncio
from uuid import UUID
refresh_token = "ВАШ ТОКЕН"
async def main():
async with AsyncITDClient(refresh_token) as client:
images_path = ["sun.png", "снег.gif", "python.jpg"]
files_ids: list[UUID] = []
for path in images_path:
with open(path, 'rb') as f:
file: File = await client.upload_file(f)
files_ids.append(file.id)
post: Post = await client.create_post("ТЕКСТ ПОСТА", attachment_ids=files_ids)
asyncio.run(main())
Поменять баннер
async def main():
async with AsyncITDClient(refresh_token) as client:
with open(r"file.gif", 'rb') as file:
image = await client.upload_file(file)
await client.update_profile(banner_id=image.id)
Уведомления по SSE
from aioitd import NotificationEvent, ConnectedEvent
async def main():
async with AsyncITDClient(refresh_token) as client:
async with client.connect_notifications() as events:
async for event in events:
if isinstance(event, ConnectedEvent):
print("Прослушка начата")
elif isinstance(event, NotificationEvent):
print(event.actor)
asyncio.run(main())
RateLimitError
RateLimitError ограничение по количеству запросов.
retray_after — через сколько можно повторить запрос.
while True:
try:
await client.post("content")
except RateLimitError as ex:
await asyncio.sleep(ex.retry_after)
Автор в итд @FIRST_TM
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file aioitd-0.3.2.tar.gz.
File metadata
- Download URL: aioitd-0.3.2.tar.gz
- Upload date:
- Size: 63.5 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2d599d2bbca9a37a6ac20b8a1822c87f0bf7f33319caa2e96a4bed0af25b6b5f
|
|
| MD5 |
db27f3e423074319b1039f205d7c62b3
|
|
| BLAKE2b-256 |
e78545aed63463151b2d8bbaf33f1fb2eb814be8fa1f7091f48fd97171218a0c
|
Provenance
The following attestation bundles were made for aioitd-0.3.2.tar.gz:
Publisher:
publish.yml on EpsilonRationes/aioitd
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
aioitd-0.3.2.tar.gz -
Subject digest:
2d599d2bbca9a37a6ac20b8a1822c87f0bf7f33319caa2e96a4bed0af25b6b5f - Sigstore transparency entry: 1097414438
- Sigstore integration time:
-
Permalink:
EpsilonRationes/aioitd@c1fa9ca00b8a07139c6636e37aff457feafa3774 -
Branch / Tag:
refs/tags/v0.3.2 - Owner: https://github.com/EpsilonRationes
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@c1fa9ca00b8a07139c6636e37aff457feafa3774 -
Trigger Event:
release
-
Statement type:
File details
Details for the file aioitd-0.3.2-py3-none-any.whl.
File metadata
- Download URL: aioitd-0.3.2-py3-none-any.whl
- Upload date:
- Size: 44.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
65868418c7854b419cf9ad306fb0542aca4a8b80f84251d18f9e35045acad83c
|
|
| MD5 |
650c5345c69108f12ed4adad73dde417
|
|
| BLAKE2b-256 |
203fff868abfe2f87fc696159e745981b48f707c9bfe11f35737ccce91aa8618
|
Provenance
The following attestation bundles were made for aioitd-0.3.2-py3-none-any.whl:
Publisher:
publish.yml on EpsilonRationes/aioitd
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
aioitd-0.3.2-py3-none-any.whl -
Subject digest:
65868418c7854b419cf9ad306fb0542aca4a8b80f84251d18f9e35045acad83c - Sigstore transparency entry: 1097414443
- Sigstore integration time:
-
Permalink:
EpsilonRationes/aioitd@c1fa9ca00b8a07139c6636e37aff457feafa3774 -
Branch / Tag:
refs/tags/v0.3.2 - Owner: https://github.com/EpsilonRationes
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@c1fa9ca00b8a07139c6636e37aff457feafa3774 -
Trigger Event:
release
-
Statement type: