🐍 Python Library

Stream torrent videos instantly

A powerful Python library for sequential torrent downloading with MOOV atom detection and built-in HTTP streaming.

Python
from pyflix.torrent import DownloadManager
# Initialize with magnet link
manager = DownloadManager(magnet, port=8888)
# Start streaming!
manager.start()
# Serving video on http://localhost:8888

Quick Install

pip install pyflix
pip install git+https://github.com/animeshkundu/pyflix.git

Requires Python 3.9+ and libtorrent. Full installation guide →

Why choose pyflix

Built for streaming, designed for simplicity

🎯

Smart Sequential Download

Intelligently prioritizes video pieces for immediate playback while downloading the rest in the background.

🎬

MOOV Atom Detection

Automatically detects and handles MP4 MOOV atoms, ensuring videos can be streamed before fully downloaded.

🌐

Built-in HTTP Server

Includes a threaded HTTP server with range request support, ready for VLC or any media player.

⚙️

Configurable Strategy

Customize download strategies, priorities, and chunk sizes to match your network and storage.

📺

Player Integration

Direct VLC integration out of the box, with support for custom player configurations.

🔧

YAML Configuration

Simple YAML-based configuration for settings, paths, limits, and player preferences.

How it works

Clean architecture for reliable streaming

🧲
Magnet Link
📦
Download Manager
🎯
Strategy Engine
🌐
HTTP Server
📺
Media Player

Download Manager

Coordinates all torrent operations, manages session lifecycle, and exposes streaming APIs.

torrent/__init__.py

Strategy Engine

Implements DefaultStrategy for intelligent piece prioritization based on playback position.

torrent/strategy.py

MOOV Handler

Detects MP4 atom positions using qtfaststart to ensure streamability.

torrent/moov.py

HTTP Streamer

Threaded HTTP server with range request support for seamless video playback.

utils/streamer.py

Simple API

Get streaming in minutes

Basic Usage

from pyflix.torrent import DownloadManager

# Create manager with magnet link
magnet = "magnet:?xt=urn:btih:..."
manager = DownloadManager(
    magnet,
    port=8888,
    serve=True
)

# Start downloading and serving
manager.start()
# Video available at http://localhost:8888

Custom Configuration

# ~/.pyflix/settings.yaml
save_path: "/downloads/torrents"

strategy:
  piece_st: 4
  last_piece_st: 4
  chunks_strat: 10
  always_sequential: false

limits:
  upload: 0  # KB/s, 0 = unlimited
  download: 0

players:
  default: "vlc"

Installation Guide

Get up and running in minutes

1

Install Dependencies

pyflix requires libtorrent with Python bindings:

# Ubuntu/Debian sudo apt install python3-libtorrent # macOS (Homebrew) brew install libtorrent-rasterbar
2

Install pyflix

Install via pip or from source:

# From PyPI pip install pyflix # From GitHub pip install git+https://github.com/animeshkundu/pyflix.git
3

Verify Installation

Test that everything works:

python -c "from pyflix.torrent import DownloadManager; print('✓ pyflix installed')"

Ready to start streaming?

pyflix is open source and free to use