Skip to main content

An async Python client library for the Seedr API.

Project description

seedr-api-client

PyPI Python License: MIT CI

An async Python client library for the Seedr API (v0.1).

Features

  • Fully async — built on aiohttp
  • Typed — Pydantic v2 models, py.typed, mypy --strict compliant
  • Dual auth — OAuth 2.0 tokens or email/password
  • Streaming downloads — memory-efficient AsyncGenerator interface
  • Modular — resources split by domain (filesystem, tasks, media, etc.)
  • PEP standards — modern packaging with hatchling

Installation

pip install seedr-api-client

Quick Start

With an OAuth access token

import asyncio
from seedr_api import SeedrClient

async def main() -> None:
    async with SeedrClient.from_token("your-access-token") as client:
        # List root folder
        root = await client.filesystem.list_root_contents()
        print(root)

        # Add a magnet link
        task = await client.tasks.add_magnet("magnet:?xt=urn:btih:...")
        print(task)

        # Stream a file download
        async with client.downloads.stream_file(file_id=123) as stream:
            with open("output.mkv", "wb") as f:
                async for chunk in stream:
                    f.write(chunk)

asyncio.run(main())

With email & password

async with SeedrClient.from_credentials("you@example.com", "password") as client:
    user = await client.user.get()
    print(user.username, user.email)

Resources

Resource Accessor Description
OAuth client.auth Token management, device code flow
User client.user Profile, quota, settings
Filesystem client.filesystem Folders, files, batch operations
Tasks client.tasks Torrent tasks (add, pause, resume, delete)
Downloads client.downloads Stream files, get download URLs
Presentations client.presentations Streaming URLs, thumbnails, playlists
Subtitles client.subtitles List, upload, search OpenSubtitles
Search client.search Search library, scrape for magnets

Device Code Flow (CLI apps)

async with SeedrClient.from_credentials("", "") as client:
    device = await client.auth.request_device_code(client_id="your-client-id")
    print(f"Visit {device.verification_uri} and enter code: {device.user_code}")

    # Poll until user authorizes
    token = await client.auth.poll_device_token(
        client_id="your-client-id",
        device_code=device.device_code,
        interval=device.interval,
    )
    print(f"Access token: {token.access_token}")

Error Handling

from seedr_api.exceptions import NotFoundError, RateLimitError, AuthenticationError

try:
    await client.filesystem.get_file(file_id=999)
except NotFoundError:
    print("File not found")
except RateLimitError as e:
    print(f"Rate limited, retry after {e.retry_after}s")
except AuthenticationError:
    print("Invalid credentials or expired token")

License

MIT © 2024

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

seedr_api_client-0.1.1.tar.gz (20.7 kB view details)

Uploaded Source

Built Distribution

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

seedr_api_client-0.1.1-py3-none-any.whl (24.0 kB view details)

Uploaded Python 3

File details

Details for the file seedr_api_client-0.1.1.tar.gz.

File metadata

  • Download URL: seedr_api_client-0.1.1.tar.gz
  • Upload date:
  • Size: 20.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for seedr_api_client-0.1.1.tar.gz
Algorithm Hash digest
SHA256 84a6aba678a4e31f59d44889b1fe5cfad8fd5ccde62b72107b8d39037c02a76c
MD5 15f5c07a16d93e9787ed02f4392f2d65
BLAKE2b-256 7785565ed0ad09935c9f4d2599cd0988a7d3aa8982839299503f2a271f4d5ad4

See more details on using hashes here.

Provenance

The following attestation bundles were made for seedr_api_client-0.1.1.tar.gz:

Publisher: publish.yml on Ns-AnoNymouS/seedr-api-client

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

File details

Details for the file seedr_api_client-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for seedr_api_client-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ff93a5646b4fa825267904010338e29aad6f42091a5b3e5ba6890c9a547aff96
MD5 e096bf8b0221d8fe6b31c5d627d6c8bd
BLAKE2b-256 17b9a180baf2f804b2879279d9d51d6a4adec5015dc78a1e88952dbbad4e9fb1

See more details on using hashes here.

Provenance

The following attestation bundles were made for seedr_api_client-0.1.1-py3-none-any.whl:

Publisher: publish.yml on Ns-AnoNymouS/seedr-api-client

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