Skip to main content

btmc - bittorrent microclient

~ alpha software primarily intended for use with sciop, use at your own risk! ~

A small asyncio bittorrent client for fetching specific pieces of torrents, and the files inside zip files inside torrents (like WACZ web archives), without downloading the whole thing.

  • Pure python on asyncio (through anyio), no native client library
  • v1, v2, and hybrid torrents. Hybrids are fetched from both their v1 and v2 swarms, since a hybrid torrent's swarm can have v1-only and v2-only clients in it
  • HTTP and UDP trackers, known peers, and incoming connections
  • Fetch pieces by index, byte ranges of files, or members of zip files
  • One client for many torrents, shared between jobs, with connection limits
  • An fsspec filesystem: torrent://{infohash}/{path}, which can show zip files as directories
  • Mount a torrent as a directory with FUSE, with what's in its zip files as directories too

It doesn't do DHT, PEX, magnet links, uTP, private torrents, or uploading (yet). It's not intended to be a full-on, real-deal bittorrent client. It's a small library to fill our specific needs where we couldn't find an existing package for it: being able to pull slices of torrents, like files within zips within torrents, and experimental support for fsspec over bittorrent (which will likely get split into a separate package).

It is leech-only, at least for now, so not recommended for general use!

Usage

from pathlib import Path

from torrent_models import Torrent
from btmc import Client, Config, TorrentWACZ

async with Client(config=Config(download_dir=Path("downloads"))) as client:
    t = client.add(Torrent.read("crawl.torrent"))
    # pieces by index
    await client.fetch(t, [0, 1, 2])
    # bytes of a file in the torrent
    header = await client.read(t, "crawl.wacz", 0, 1024)
    # the pages archived in a WACZ in the torrent, a batch at a time
    wacz = TorrentWACZ(client, t, "crawl.wacz")
    async for pages in wacz.pages(extra=True):
        ...

Through fsspec, with the fsspec extra:

import fsspec

with fsspec.open(
    "zip://pages/pages.jsonl::torrent:///path/to/crawl.torrent/crawl.wacz",
    torrent={"download_dir": "downloads"},
) as f:
    pages = f.read()

From the command line, with the cli extra:

btmc fetch crawl.torrent downloads 0 1 2
btmc zip crawl.torrent downloads --file crawl.wacz
btmc zip crawl.torrent downloads --file crawl.wacz -x out pages/pages.jsonl

And mount a torrent as a directory, with the mount extra and FUSE (see the docs for installing macFUSE):

btmc mount crawl.torrent ./crawl --mount-zip crawl.wacz

Metadata

Release files for btmc 0.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for btmc 0.0.0
File Size Uploaded Provenance Actions
btmc-0.0.0.tar.gz 99.9 kB Without provenance Details for btmc-0.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for btmc 0.0.0
File Interpreter ABI Platform Actions
btmc-0.0.0-py3-none-any.whl Python 3 none any Details for btmc-0.0.0-py3-none-any.whl

Total release size: 172.3 kB

Release files / btmc-0.0.0.tar.gz

Download URL btmc-0.0.0.tar.gz
Size 99.9 kB
Tags Source
SHA-256 checksum
How to use checksums
019512ebf0bf2e611293b2c039fe3203a21b37181a6217d0e80fdd0461b867dc
BLAKE2b-256 checksum
How to use checksums
e8066c58ce0641c7377a3d9d469c11826eac9a2aa3a732f21950a6debdaf1d52
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via pdm/2.29.4 CPython/3.14.7 Darwin/25.6.0

Release files / btmc-0.0.0-py3-none-any.whl

Download URL btmc-0.0.0-py3-none-any.whl
Size 72.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
109e3f2956838bbb9a441c4b78715d5861a98fcb6f840820ec0b8bd92fbb688e
BLAKE2b-256 checksum
How to use checksums
65016641965b6711b1ba3dc1b64fc895746fe5ddac281df2cee3b005e85b399d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via pdm/2.29.4 CPython/3.14.7 Darwin/25.6.0

Security for btmc 0.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.0.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page