Skip to content

Clients

The client classes are the entry point. GazelleClient is the base; use the tracker-specific subclasses (OrpheusClient, RedactedClient) or their synchronous counterparts.

Async clients

pygazelle.GazelleClient

GazelleClient(transport: GazelleTransport)
Source code in src/pygazelle/client.py
def __init__(self, transport: GazelleTransport) -> None:
    self._transport: GazelleTransport = transport
    self._torrents: TorrentResource | None = None
    self._artists: ArtistResource | None = None
    self._requests: RequestResource | None = None
    self._collages: CollageResource | None = None
    self._user: UserResource | None = None
    self._inbox: InboxResource | None = None
    self._notifications: NotificationResource | None = None
    self._bookmarks: BookmarkResource | None = None
    self._subscriptions: SubscriptionResource | None = None
    self._site: SiteResource | None = None

torrents property

torrents: TorrentResource

artists property

artists: ArtistResource

requests property

requests: RequestResource

collages property

collages: CollageResource

user property

inbox property

notifications property

notifications: NotificationResource

bookmarks property

bookmarks: BookmarkResource

subscriptions property

subscriptions: SubscriptionResource

site property

monitor

monitor(
    *,
    sources: tuple[UserTorrentType, ...] = (
        "uploaded",
        "snatched",
    ),
    page_size: int = 50,
) -> TorrentMonitor

Construct a TorrentMonitor bound to this client.

Source code in src/pygazelle/client.py
def monitor(
    self,
    *,
    sources: tuple[UserTorrentType, ...] = ("uploaded", "snatched"),
    page_size: int = 50,
) -> TorrentMonitor:
    """Construct a TorrentMonitor bound to this client."""
    return TorrentMonitor(self, sources=sources, page_size=page_size)

aclose async

aclose() -> None
Source code in src/pygazelle/client.py
async def aclose(self) -> None:
    await self._transport.aclose()

pygazelle.OrpheusClient

OrpheusClient(
    *,
    username: str | None = None,
    password: str | None = None,
    api_key: str | None = None,
    **kwargs: Unpack[TransportOptions],
)

Bases: GazelleClient

Source code in src/pygazelle/client.py
def __init__(
    self,
    *,
    username: str | None = None,
    password: str | None = None,
    api_key: str | None = None,
    **kwargs: Unpack[TransportOptions],
) -> None:
    kwargs.setdefault("announce_host", ORPHEUS_ANNOUNCE_HOST)
    super().__init__(
        GazelleTransport(
            ORPHEUS_BASE_URL, username=username, password=password, api_key=api_key, **kwargs
        )
    )

pygazelle.RedactedClient

RedactedClient(
    *,
    username: str | None = None,
    password: str | None = None,
    api_key: str | None = None,
    **kwargs: Unpack[TransportOptions],
)

Bases: GazelleClient

Source code in src/pygazelle/client.py
def __init__(
    self,
    *,
    username: str | None = None,
    password: str | None = None,
    api_key: str | None = None,
    **kwargs: Unpack[TransportOptions],
) -> None:
    # RED expects the bare API key in the Authorization header (no "token " prefix).
    kwargs.setdefault("api_key_prefix", "")
    kwargs.setdefault("announce_host", REDACTED_ANNOUNCE_HOST)
    super().__init__(
        GazelleTransport(
            REDACTED_BASE_URL, username=username, password=password, api_key=api_key, **kwargs
        )
    )

Synchronous clients

pygazelle.GazelleSyncClient

GazelleSyncClient(async_client: GazelleClient)
Source code in src/pygazelle/sync.py
def __init__(self, async_client: GazelleClient) -> None:
    self._async: GazelleClient = async_client
    self._bg: _BackgroundLoop = _BackgroundLoop()

torrents property

torrents: _SyncProxy

artists property

artists: _SyncProxy

requests property

requests: _SyncProxy

collages property

collages: _SyncProxy

user property

user: _SyncProxy

inbox property

inbox: _SyncProxy

notifications property

notifications: _SyncProxy

bookmarks property

bookmarks: _SyncProxy

subscriptions property

subscriptions: _SyncProxy

site property

site: _SyncProxy

monitor

monitor(
    *,
    sources: tuple[UserTorrentType, ...] = (
        "uploaded",
        "snatched",
    ),
    page_size: int = 50,
) -> _SyncProxy

A synchronous TorrentMonitor: async poll() runs on the background loop; sync methods (dump_state/load_state) pass through.

Source code in src/pygazelle/sync.py
def monitor(
    self,
    *,
    sources: tuple[UserTorrentType, ...] = ("uploaded", "snatched"),
    page_size: int = 50,
) -> _SyncProxy:
    """A synchronous TorrentMonitor: async ``poll()`` runs on the background
    loop; sync methods (``dump_state``/``load_state``) pass through."""
    async_monitor = self._async.monitor(sources=sources, page_size=page_size)
    return _SyncProxy(async_monitor, self._bg)

close

close() -> None
Source code in src/pygazelle/sync.py
def close(self) -> None:
    self._bg.run(self._async.aclose())
    self._bg.stop()

pygazelle.OrpheusClientSync

OrpheusClientSync(
    *,
    username: str | None = None,
    password: str | None = None,
    api_key: str | None = None,
    **kwargs: Unpack[TransportOptions],
)

Bases: GazelleSyncClient

Source code in src/pygazelle/sync.py
def __init__(
    self,
    *,
    username: str | None = None,
    password: str | None = None,
    api_key: str | None = None,
    **kwargs: Unpack[TransportOptions],
) -> None:
    super().__init__(
        OrpheusClient(username=username, password=password, api_key=api_key, **kwargs)
    )

pygazelle.RedactedClientSync

RedactedClientSync(
    *,
    username: str | None = None,
    password: str | None = None,
    api_key: str | None = None,
    **kwargs: Unpack[TransportOptions],
)

Bases: GazelleSyncClient

Source code in src/pygazelle/sync.py
def __init__(
    self,
    *,
    username: str | None = None,
    password: str | None = None,
    api_key: str | None = None,
    **kwargs: Unpack[TransportOptions],
) -> None:
    super().__init__(
        RedactedClient(username=username, password=password, api_key=api_key, **kwargs)
    )