Skip to main content
docs/tree.jpeg

Libtorrent made easy

This is pythonic high-level libtorrent API, inspired on the for-humans trend set by Kenneth Reitz (https://github.com/not-kennethreitz).

TorrentStream is centered around the principle of streaming a torrent (sequential download, buffering and playing).

pypi release downloads python_versions pypi_versions

TorrentStream exposes a CLI command, intended as an example usage.

docs/torrentstream_usage.png

Torrent objects are context managers that can clean up torrent content after you finish using them.

add_torrent method of a TorrentSession returns a Torrent object, thus can be used directly as a context manager.

async def stream_torrent(hash_torrent):
    session = TorrentSession()

    # By default this will cleanup torrent contents after playing
    with session.add_torrent(magnet_link=hash_torrent, remove_after=True) as torrent:
        # Force sequential mode
        torrent.sequential(True)

        # Wait for torrent to be started
        await torrent.wait_for('started')

        # Get first match of a media file
        try:
            media = next(a for a in torrent
                         if a.is_media and not 'sample' in a.path.lower())
        except StopIteration:
            raise Exception('Could not find a playable source')

        with timeout(5 * 60):  # Abort if we can't fill 5% in 5 minutes
            await media.wait_for_completion(5)

        return await asyncio.gather(media.wait_for_completion(100),
                                    media.launch())

Metadata

Release files for torrentstream 0.3.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 torrentstream 0.3.0
File Size Uploaded
torrentstream-0.3.0.tar.gz 5.7 kB Details

Built distribution (wheel)

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

Total release size: 12.1 kB

Release files / torrentstream-0.3.0.tar.gz

Download URL torrentstream-0.3.0.tar.gz
Size 5.7 kB
Tags Source
SHA-256 checksum
How to use checksums
30ee94dda38f913788b4def5a8e6c0391fca6f3022fd64ffd4fb4a0655504f39
BLAKE2b-256 checksum
How to use checksums
e49fdaeb225edfe182a36c2ccda8a32f02de8e8c50442d87524b7421566f1e4e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.4 CPython/3.9.5 Linux/5.12.11-arch1-1

Release files / torrentstream-0.3.0-py3-none-any.whl

Download URL torrentstream-0.3.0-py3-none-any.whl
Size 6.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d4f2fc3820bea1a6ab48522afae7261eecdffa20e3cab8c9aef737779613a093
BLAKE2b-256 checksum
How to use checksums
ba41a7a656100549bfcabf9c2e39ff01dd75c92f390559bfc78aa2e01f8cec36
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.4 CPython/3.9.5 Linux/5.12.11-arch1-1

Release history Release notifications | RSS feed

0.3.1

2 release files

This release

0.3.0 This release

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.5

1 release file

0.1.2

1 release file

0.1.1

1 release file

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