Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
/ bencode Public

python 3 bencode, support UTF-8 and read/write BT torrent file.

License

Notifications You must be signed in to change notification settings

Celend/bencode

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

18 Commits

Repository files navigation

bencode

python3 bencode, support multiple encodings and read/write BT torrent file. this module support multiple data type, include bytes. so you can open a torrent file, if the field unable to decode, will treat as bytes, also you can insert bytes data. auto sort dictionary key when insert dict.

Support UTF-8

data type
bencode Python
int int
str str
list list
dictionary dict
unable decoding bytes
example
import bencode;
>>> f = open('bt.torrent', 'rb');
>>> bt = bencode.decode(f.read(), 'encoding; default is utf-8');
>>> f.close();
>>> bt.keys();
dict_keys(['info', 'announce-list'])
>>> for i in bt['info']['files']:
 print(i['path']);
['MTKV25.zip']
>>> bt['info']['files'][0]['path'][0] = 'modify.zip';
>>> f = open('bt1.torrent', 'wb');
>>> f.write(bencode.encode(bt));
10537
>>> f.close();

or

>>> import bencode
>>> bt = bencode.load('bt.torrent', ['gbk', 'gb2312', 'big5']);
do something
>>> bencode.save(bt, 'bt.torrent');
true

or load with bencode.load(filename) return object, save with bencode.save(object, filename) return boolean;

result

only filename has been changed, open with downloader and successfully downloaded.
so i can say this module can fully support torrent file for read/write.

Good Luck

About

python 3 bencode, support UTF-8 and read/write BT torrent file.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

Languages

AltStyle によって変換されたページ (->オリジナル) /