Skip to main content

Асинхронный клиент для итд.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:

  1. Войди в аккаунт на итд.com
  2. Откройть devtools
  3. Среди табов выбрать network (сеть)
  4. Перезагрузить страницу
  5. Найти запрос refresh
  6. В куки запроса скопировать refresh_token

Или:

  1. Войти в аккаунт на итд.com
  2. Откройть devtools
  3. Среди табов выбрать application (приложение)
  4. Перезагрузить страницу
  5. Выбрать куки и найти куку 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aioitd-0.3.5.tar.gz (63.5 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

aioitd-0.3.5-py3-none-any.whl (45.9 kB view details)

Uploaded Python 3

File details

Details for the file aioitd-0.3.5.tar.gz.

File metadata

  • Download URL: aioitd-0.3.5.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

Hashes for aioitd-0.3.5.tar.gz
Algorithm Hash digest
SHA256 1b26cc43eff242814ceb5ead0925d1e521e016b423ea579b6161d4a53be3a2cc
MD5 eee4de5be1356b6eb1f1f8ae69601b64
BLAKE2b-256 2b77d5b90c9996f15886744b931bbe8b0daf10aed197d32bee7171909e06012d

See more details on using hashes here.

Provenance

The following attestation bundles were made for aioitd-0.3.5.tar.gz:

Publisher: publish.yml on EpsilonRationes/aioitd

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file aioitd-0.3.5-py3-none-any.whl.

File metadata

  • Download URL: aioitd-0.3.5-py3-none-any.whl
  • Upload date:
  • Size: 45.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for aioitd-0.3.5-py3-none-any.whl
Algorithm Hash digest
SHA256 64edbc6caef231e7680a3d5ecca80a50b4b07ffde0ca4a14a9ee4482ec79c303
MD5 1ead2c968eb8724a41603a0a2b5941e8
BLAKE2b-256 1d58c8ab0eee1bd6a055dfd62b89138121b2cc7f5b8d5e4be4a1630788461a11

See more details on using hashes here.

Provenance

The following attestation bundles were made for aioitd-0.3.5-py3-none-any.whl:

Publisher: publish.yml on EpsilonRationes/aioitd

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page