Metadata-Version: 2.5
Name: torrentool
Version: 1.3.0
Summary: The tool to work with torrent files
Project-URL: Homepage, https://github.com/idlesign/torrentool
Author-email: Igor Starikov <idlesign@yandex.ru>
License-Expression: BSD-3-Clause
License-File: LICENSE
Keywords: bencode,torrent
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: BSD License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Requires-Python: >=3.10
Provides-Extra: cli
Requires-Dist: click; extra == 'cli'
Requires-Dist: requests; extra == 'cli'
Description-Content-Type: text/markdown

# torrentool

<https://github.com/idlesign/torrentool>

[![release](https://img.shields.io/pypi/v/torrentool.svg)](https://pypi.python.org/pypi/torrentool)
[![lic](https://img.shields.io/pypi/l/torrentool.svg)](https://pypi.python.org/pypi/torrentool)
[![coverage](https://img.shields.io/coveralls/idlesign/torrentool/master.svg)](https://coveralls.io/r/idlesign/torrentool)

## Description

*The tool to work with torrent files.*

Works on Python 3.10+.

Includes:

* Command line interface. Requires `click` package to be installed.

  Use `pip install torrentool[cli]` to install this dependency automatically.
* Torrent utils (file creation, read and modification).
* Bencoding utils (decoder, encoder).

## Using CLI

```shell
# Make .torrent out of `video.mkv`
$ torrentool torrent create /home/my/files_here/video.mkv

# Make .torrent out of entire `/home/my/files_here` dir,
# and put some open trackers announce URLs into it,
# and publish file on torrent caching service, so it is ready to share.
$ torrentool torrent create /home/my/files_here --open_trackers --cache

# Print out existing file info.
$ torrentool torrent info /home/my/some.torrent
```

Use command line `--help` switch to know more.

!!! note

    Some commands require `requests` package to be installed.

## From your Python code

```python
from torrentool.api import Torrent

# Reading and modifying an existing file.
my_torrent = Torrent.from_file('/home/idle/some.torrent')
my_torrent.total_size  # Total files size in bytes.
my_torrent.magnet_link  # Magnet link for you.
my_torrent.comment = 'Your torrents are mine.'  # Set a comment.
my_torrent.to_file()  # Save changes.

# Or we can create a new torrent from a directory.
new_torrent = Torrent.create_from('/home/idle/my_stuff/')  # or it could have been a single file
new_torrent.announce_urls = 'udp://tracker.openbittorrent.com:80'
new_torrent.to_file('/home/idle/another.torrent')

# Basic data (info hash, name, trackers) can also be read from a magnet link:
another_torrent = Torrent.from_magnet('magnet:?xt=urn:btih=0123456789abcdef0123456789abcdef01234567&dn=Stuff')
```
