ZapTorrent is a high-performance, command-line BitTorrent client written in Python. It allows users to:
- Parse
.torrentmetadata - Retrieve peer lists from trackers (HTTP tracker support only)
- Download files piece-by-piece using the BitTorrent protocol
ZapTorrent is designed for efficiency and includes features to optimize peer selection and download throughput.
Performance Optimization Used (in main.py)
- Parallel download workers choose a peer and piece to download.
- If a peer responds successfully, it’s moved to the front of the queue (preferred).
- If a peer fails, it's sent to the back of the queue (penalized).
- Failed downloads are retried by a dedicated Failed Piece Worker Pool using an end-game strategy — request from all peers and cancel others when one succeeds.
- If a piece still fails, it's added back for future retry.
Ensure you have Python installed (preferably Python 3.8+).
Install required dependencies:
pip install -r requirements.txtRun the following command to see available options:
python src/main.py --helpTo parse and display metadata of a .torrent file, including file details and tracker URLs:
python src/main.py --parse <path_to_torrent_file>Example:
python src/main.py --parse ubuntu.torrentTo start downloading the file(s) from a torrent:
python src/main.py --download <path_to_torrent_file> [--output <download_directory>] [--verbose]-
--output(optional): Specify the directory where the files should be saved. Defaults toDownloadsat the project root. -
--verbose(optional): Enables detailed logging for debugging and tracking download progress.
Example:
python src/main.py --download ubuntu.torrent --output /home/user/Downloads --verboseThis project is open-source and available under the MIT License.
