Skip to main content

Command-line tool for batch converting torrent files to magnet links

Project description

Magneto

Python Version License Version GitHub GitHub

A powerful and user-friendly command-line tool for batch converting torrent files (.torrent) to magnet links.

Docs | 中文文档

⚠️ Warning: This project is still in early development. Please use with caution. Features may be incomplete and APIs may change.

✨ Features

  • 🚀 Batch Processing - Support single file or entire folder batch conversion
  • 🔍 Recursive Search - Recursively search for torrent files in subdirectories
  • 🎨 Beautiful Output - Colored terminal output with clear progress display
  • 📝 Multiple Formats - Support full format, links only, and JSON format output
  • 🔗 Tracker Support - Optionally include tracker information in magnet links
  • 📊 Detailed Statistics - Display processing progress and success/failure statistics
  • 🎯 Flexible Configuration - Rich command-line argument options

📦 Installation

Using uv (Recommended)

This project uses pyproject.toml for dependency management and is fully compatible with uv.

# Install uv (if not already installed)
# Windows: powershell -c "irm https://astral.sh/uv/install.ps1 | iex"
# Linux/Mac: curl -LsSf https://astral.sh/uv/install.sh | sh

# Sync dependencies and install project (development mode)
uv sync

# Run directly (no installation needed, uv manages environment automatically)
uv run magneto file.torrent
uv run magneto folder/ -r -v

# Install to current environment
uv pip install -e .

# Install development dependencies (if configured)
uv sync --extra dev

# View project information
uv tree

Using pip

# Install from source (pip automatically reads pyproject.toml)
pip install -e .

# Or install dependencies directly
pip install bencode.py colorama

🚀 Usage

Basic Usage

# Convert a single torrent file
magneto file.torrent

# Convert all torrent files in a folder
magneto folder/

# Specify output file
magneto folder/ -o output.txt

Advanced Usage

# Recursively search subdirectories
magneto folder/ -r

# Output JSON format
magneto folder/ -f json

# Output magnet links only (no other information)
magneto folder/ -f links_only

# Include tracker information in magnet links
magneto folder/ --include-trackers

# Show detailed information
magneto folder/ -v

# Quiet mode (only show errors)
magneto folder/ -q

# Disable colored output
magneto folder/ --no-colors

# Print results to stdout instead of saving to file
magneto folder/ --stdout
magneto folder/ --stdout -f links_only  # Print only magnet links
magneto folder/ --stdout -f json        # Print JSON format

View Help

magneto --help
magneto -h

View Version

magneto --version

📋 Command-Line Arguments

Positional Arguments

  • input - Input torrent file or folder path containing torrent files

Output Options

  • -o, --output FILE - Specify output file path (default: magnet_links.txt in input directory)
  • -f, --format {full,links_only,json} - Output format (default: full)
    • full - Full format, includes file information, magnet links, Info Hash, etc.
    • links_only - Magnet link list only
    • json - JSON format output
  • --stdout - Print results to stdout instead of saving to file

Search Options

  • -r, --recursive - Recursively search for torrent files in subdirectories
  • --case-sensitive - Case-sensitive search for file extensions

Conversion Options

  • --include-trackers - Include tracker information in magnet links

Display Options

  • -v, --verbose - Show verbose output information
  • -q, --quiet - Quiet mode, only show error messages
  • --no-colors - Disable colored output

Other Options

  • -h, --help - Show help information and exit
  • --version - Show version information and exit

📁 Output Format Examples

Full Format

================================================================================
Torrent to Magnet Link Conversion Results
================================================================================

File: example.torrent
Magnet Link: magnet:?xt=urn:btih:ABC123...&dn=Example
Info Hash: ABC123...
Name: Example
Trackers: 3 found
--------------------------------------------------------------------------------

================================================================================
Magnet Link List (Links Only)
================================================================================

magnet:?xt=urn:btih:ABC123...&dn=Example

JSON Format

[
  {
    "file": "example.torrent",
    "magnet": "magnet:?xt=urn:btih:ABC123...&dn=Example",
    "info_hash": "ABC123...",
    "name": "Example",
    "trackers": ["http://tracker1.example.com", "http://tracker2.example.com"]
  }
]

🧪 Testing

The project includes comprehensive unit tests using pytest with mock torrent files.

# Run all tests
pytest

# Run tests with coverage
pytest --cov=magneto --cov-report=html

# Run specific test file
pytest tests/test_core.py

# Run tests in verbose mode
pytest -v

# Run only unit tests
pytest -m unit

# Run only integration tests
pytest -m integration

🔧 Dependencies

  • Python 3.7+
  • bencode.py >= 4.0.0
  • colorama >= 0.4.0 (optional, for Windows color support)

📝 License

MIT License

🤝 Contributing

Issues and Pull Requests are welcome!

📮 Feedback

If you have any questions or suggestions, please provide feedback through Issues.

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

magneto_cli-0.1.0.tar.gz (148.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

magneto_cli-0.1.0-py3-none-any.whl (12.6 kB view details)

Uploaded Python 3

File details

Details for the file magneto_cli-0.1.0.tar.gz.

File metadata

  • Download URL: magneto_cli-0.1.0.tar.gz
  • Upload date:
  • Size: 148.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.21 {"installer":{"name":"uv","version":"0.9.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for magneto_cli-0.1.0.tar.gz
Algorithm Hash digest
SHA256 d419b7ad914afd463eca9464f628874ba1c534992ec7ea799d7f7b95274860df
MD5 1a38fd3045f8e451d36f7ba1e1a361e5
BLAKE2b-256 58c9747a599f9532ed7bc9784ac462df108b2b95a2eda6aa8e11e2d6aed8dabc

See more details on using hashes here.

File details

Details for the file magneto_cli-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: magneto_cli-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 12.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.21 {"installer":{"name":"uv","version":"0.9.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for magneto_cli-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8463008e9a3181951b88b4050146c871be8cd02b82b01897e7de5a3558f7219d
MD5 ceef8b12e6f6ac40faac9fa4855a29fc
BLAKE2b-256 cbfd241eea896c215ab1f44576092b659873d7b940b094e9030361082a4e7fb3

See more details on using hashes here.

Supported by

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