https://github.com/idlesign/torrentool
The tool to work with torrent files.
https://github.com/idlesign/torrentool
bencode python torrent
Last synced: 11 months ago
JSON representation
The tool to work with torrent files.
- Host: GitHub
- URL: https://github.com/idlesign/torrentool
- Owner: idlesign
- License: bsd-3-clause
- Created: 2015-10-21T17:53:29.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2023-06-08T13:39:33.000Z (almost 3 years ago)
- Last Synced: 2025-03-29T20:07:19.273Z (12 months ago)
- Topics: bencode, python, torrent
- Language: Python
- Homepage: https://github.com/idlesign/torrentool
- Size: 258 KB
- Stars: 154
- Watchers: 10
- Forks: 30
- Open Issues: 8
-
Metadata Files:
- Readme: README.rst
- Changelog: CHANGELOG
- License: LICENSE
Awesome Lists containing this project
README
torrentool
==========
https://github.com/idlesign/torrentool
.. image:: https://img.shields.io/pypi/v/torrentool.svg
:target: https://pypi.python.org/pypi/torrentool
.. image:: https://img.shields.io/pypi/l/torrentool.svg
:target: https://pypi.python.org/pypi/torrentool
.. image:: https://img.shields.io/coveralls/idlesign/torrentool/master.svg
:target: https://coveralls.io/r/idlesign/torrentool
Description
-----------
*The tool to work with torrent files.*
Works on Python 3.7+.
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
~~~~~~~~~
.. code-block:: bash
; 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
~~~~~~~~~~~~~~~~~~~~~
.. code-block:: 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')