Go to file
7sDream ee3128b32b Many changes, see bellow:
- Added
  - BEncoder
  - BDecoder
  - encode
  - decode
  - errors argument for TorrentFileParser and parse_torrent_file (#4)
- Changed
  - TorrentFileCreator rename to BEncoder
  - TorrentFileParser, BEncoder don't need outmost level is dict
- Updated
  - README
  - CHANGELOG
  - LICENSE

and tests for above changes.
2018-06-23 01:44:10 +08:00
tests Many changes, see bellow: 2018-06-23 01:44:10 +08:00
.gitignore init 2017-05-23 13:35:40 +08:00
CHANGELOG.md Many changes, see bellow: 2018-06-23 01:44:10 +08:00
LICENSE Many changes, see bellow: 2018-06-23 01:44:10 +08:00
MANIFEST.in Removed: unused test files in MANIFEST.in 2018-04-29 00:20:08 +08:00
README.md Many changes, see bellow: 2018-06-23 01:44:10 +08:00
setup.cfg init 2017-05-23 13:35:40 +08:00
setup.py update to v0.1.5rc1 2018-04-29 00:14:54 +08:00
torrent_parser.py Many changes, see bellow: 2018-06-23 01:44:10 +08:00

README.md

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.

Features

  • 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
  • Uniform exception type
  • CLI provided, with JSON output

Install

pip install torrent_parser

Usage:

CLI

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

As a module

>>> import torrent_parser as tp
>>> data = tp.parse_torrent_file('test.torrent')
>>> data['announce']
http://tracker.trackerfix.com:80/announce
>>> data['announce'] = 'http://127.0.0.1:12345'
>>> 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']
-1
>>> tp.encode(data)
b'd3:negi-1ee'

Test

python -m unittest tests

Changelog

See Changelog.

LICENSE

See License.