Skip to content

andrei-shtanakov/minitorrent

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MiniTorrent

A minimalist command-line torrent client.

Philosophy

  • Only essential settings — each option has a clear purpose
  • Reasonable defaults — works out of the box without configuration
  • Extensibility — add new features as needed

Installation

# Dependency: libtorrent
# Ubuntu/Debian
sudo apt install python3-libtorrent

# Arch
sudo pacman -S libtorrent-rasterbar

# Fedora
sudo dnf install rb_libtorrent-python3

# Install the client
cd minitorrent
uv pip install -e .

Usage

# Start background daemon (recommended)
mt daemon start
mt daemon status
mt daemon stop

# Add torrent
mt add "magnet:?xt=urn:btih:..."
mt add /path/to/file.torrent
mt add --select "magnet:?xt=..."  # Interactively select files after adding

# List torrents
mt list

# Detailed status
mt status 1

# Control
mt pause 1
mt resume 1
mt remove 1
mt remove 1 --delete-files

# File management
mt files 1              # List files in torrent
mt select 1             # Interactively select/deselect files

# Interactive TUI dashboard
mt tui

# Real-time monitoring (non-interactive)
mt watch

# Configuration
mt config
mt config --download-dir ~/Torrents
mt config --max-download 1000  # KB/s

Configuration

File: ~/.config/minitorrent/config.toml

# Where to save files
download_dir = "/home/user/Downloads"

# Port for incoming connections
port = 6881

# Speed limits in KB/s (0 = unlimited)
max_download_rate = 0
max_upload_rate = 0

Only 4 settings. Each is clear and has a reasonable default value.

Extending

Want to add a new feature? Examples:

Add a setting

# In config.py, add field to dataclass:
@dataclass
class Config:
    ...
    # Maximum simultaneous downloads
    max_active_downloads: int = 3

Add a command

# In cli.py, add command:
@main.command()
@click.argument("torrent_id", type=int)
@click.pass_context
def files(ctx, torrent_id: int):
    """Show files in torrent."""
    # ...

Add a hook after download

# In client.py, in wait_for_alerts() method:
for alert in alerts:
    if isinstance(alert, lt.torrent_finished_alert):
        # Run script, send notification, etc.
        pass

Project Structure

minitorrent/
├── pyproject.toml      # Dependencies and metadata
├── README.md
└── minitorrent/
    ├── __init__.py
    ├── config.py       # 4 settings, clear format
    ├── client.py       # libtorrent wrapper (torrents + file operations)
    ├── daemon.py       # Background daemon with Unix socket IPC
    ├── cli.py          # Commands: add, list, pause, remove, files, select, tui, daemon...
    └── tui.py          # Textual TUI: dashboard + file selector

TODO (add as needed)

  • File selection for download
  • RSS feeds
  • Web UI
  • Completion notifications
  • Scheduler (download only at night)

Why not rtorrent/transmission-cli/etc?

Because you understand every line of your own code.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages