Command-line tool for batch converting torrent files to magnet links
Project description
Magneto
A powerful and user-friendly command-line tool for batch converting torrent files (.torrent) to magnet links.
⚠️ 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
From PyPI (Recommended)
The easiest way to install Magneto is using pip:
pip install magneto-cli
Or using uv:
uv pip install magneto-cli
After installation, you can use the magneto command directly:
magneto --help
From Source
If you want to install from source for development:
Using pip
# Clone the repository
git clone https://github.com/mastaBriX/magneto.git
cd magneto
# Install in development mode
pip install -e .
# Or install dependencies directly
pip install bencode.py colorama
Using uv
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
# Clone the repository
git clone https://github.com/mastaBriX/magneto.git
cd magneto
# 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 development dependencies
uv sync --extra dev
# View project information
uv tree
🚀 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 onlyjson- 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file magneto_cli-0.1.2.tar.gz.
File metadata
- Download URL: magneto_cli-0.1.2.tar.gz
- Upload date:
- Size: 149.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
463d46d093c0d68daf75843f854827caa5f95cc7dd9f6c3cf9b3a4e7b4339580
|
|
| MD5 |
e21ef0dd60635411bf6cb70b8c385a87
|
|
| BLAKE2b-256 |
dff6d453daf633cc2057fd53a731afccd108ffbebfe313f13b6877569fecb7cf
|
File details
Details for the file magneto_cli-0.1.2-py3-none-any.whl.
File metadata
- Download URL: magneto_cli-0.1.2-py3-none-any.whl
- Upload date:
- Size: 15.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4b7a84638d0c107d198b4f1c637899fbe91ad6c4fad8863a6e3e77d91cd5c06d
|
|
| MD5 |
8689e08d6fc73eef477066b768be919f
|
|
| BLAKE2b-256 |
86386824478c9e892ed3ef0554329e26ba254def2c0fd40c06235e594d3e9276
|