You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Роман Бородин 65796860b8 Первая версия модуля для kodi 2 years ago
lib Первая версия модуля для kodi 2 years ago
.gitignore init 4 years ago
LICENSE Many changes, see bellow: 3 years ago hash_fields(finish #4) and hash raw: 3 years ago
addon.xml Первая версия модуля для kodi 2 years ago

Torrent file parser and creator for Python

A simple parser for .torrent file.

Can also edit and write back to torrent format after version 0.2.0.


  • Decoder and encoder for torrent files
  • Auto decode bytes field to string with used specified encoding and error handler
  • Auto detect encoding when use auto as encoding(need chardet installed)
  • Auto decode hash value filed to hash blocks, also customizable
  • CLI provided, with JSON output


pip install torrent_parser



$ pytp test.torrent
$ cat test.torrent | pytp

As a module

>>> import torrent_parser as tp
>>> data = tp.parse_torrent_file('test.torrent')
>>> data['announce']
>>> data['announce'] = ''
>>> tp.create_torrent_file('new.torrent', data)

or you don't operate with file, just raw bytes:

>>> import torrent_parser as tp
>>> data = tp.decode(b'd3:negi-1ee')
>>> data['neg']
>>> tp.encode(data)


python -m unittest tests


See Changelog.


See License.