Skip to main content

libtorrent python api

Project description

LibtorrentX

A python wrapper for libtorrent, makes it easy to manage torrents. Built in support for state management and state recovery after restart.

  • Easily pause and resume your torrent streams.
  • Optimized settings for faster download speeds.

Install via pip

pip install libtorrentx

Simple demo app

from libtorrentx import LibTorrentSession
import time

magnet = "magnet:?xt=urn:btih:4C9B41D664D7B6B23F0BF39AE185858CBADDA3FF"
output_dir = "./downloads"
session = LibTorrentSession()
handle = session.add_torrent(magnet, output_dir)

if handle:
    while True:
        status, props = handle.read()
        if not status:
            time.sleep(1)
            continue

        print(f"{props['name']}, {props['download_speed_human']}, {props['progress']}%")
        if props['is_finished']: break

        time.sleep(1)

or use CLI python -m libtorrentx -m magnet:?xt=urn:btih:4C9B41D664D7B6B23F0BF39AE185858CBADDA3FF

Output

Spider-Man.No.Way.Home.2022.1080p.BluRay.1600MB.DD5.1.x264-GalaxyRG[TGx], 1.20 MB/s, 19%
Spider-Man.No.Way.Home.2022.1080p.BluRay.1600MB.DD5.1.x264-GalaxyRG[TGx], 12.00 MB/s, 19%
Spider-Man.No.Way.Home.2022.1080p.BluRay.1600MB.DD5.1.x264-GalaxyRG[TGx], 28.11 MB/s, 77%
Spider-Man.No.Way.Home.2022.1080p.BluRay.1600MB.DD5.1.x264-GalaxyRG[TGx], 29.00 MB/s, 100%

You can stop the execution and restart again, the download will resume from previous state.

Install via Docker

docker build . -t libtorrentx
docker run --rm -it -v $(pwd)/downloads:/app/downloads libtorrentx -m magnet:?xt=urn:btih:4C9B41D664D7B6B23F0BF39AE185858CBADDA3FF

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

libtorrentx-0.0.6.linux-x86_64.tar.gz (9.4 kB view details)

Uploaded Source

File details

Details for the file libtorrentx-0.0.6.linux-x86_64.tar.gz.

File metadata

File hashes

Hashes for libtorrentx-0.0.6.linux-x86_64.tar.gz
Algorithm Hash digest
SHA256 ef6a1a2af0210be6bc8b0007c20035d8962252eb9de78a2503997a94e3c2f62a
MD5 37169510345cf8016cf0d82f21235ccb
BLAKE2b-256 2f7cb2caf3c0332f9077c0aac6492d1c4915abf11bdf79600a728e04dbb004d8

See more details on using hashes here.

Supported by

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