🪈 benpipe
A simple util to convert between json and bencode.
📦 install
pip install benpipe
▶️ use
cat file.json | benpipe
cat file.torrent | benpipe
benpipe --to-json < file.torrent
benpipe --to-bencode < file.json
Benpipe accepts recoverable non-canonical bencode, but always writes canonical bencode with dictionary keys sorted as raw bytes. Structurally invalid input is rejected with a non-zero exit status.
Binary data and unusual dictionaries
UTF-8 byte strings become ordinary JSON strings. Other byte strings use a tagged object:
{"__benpipe_bytes__": "/w=="}
Dictionaries with binary or duplicate keys use an ordered list of key-value pairs, preserving information that a JSON object cannot represent:
{"__benpipe_dict__": [["key", 1], ["key", 2]]}
Objects that naturally match either tag are escaped through the dictionary representation, so conversion remains lossless.
🔗 Links
Release files for benpipe 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| benpipe-0.1.0.tar.gz | 5.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| benpipe-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 12.5 kB
Release files / benpipe-0.1.0.tar.gz
| Download URL | benpipe-0.1.0.tar.gz |
|---|---|
| Size | 5.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8cbd28553e036a6151b91b2ad8e8b4e91af155ecdd7f266002c020f810be85b1
|
|
BLAKE2b-256 checksum How to use checksums |
a5fbd337cd991d0b1ea855e610817dbd158561358a4c3dcfb961d2400d680ca8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.10.21
|
Release files / benpipe-0.1.0-py3-none-any.whl
| Download URL | benpipe-0.1.0-py3-none-any.whl |
|---|---|
| Size | 7.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8b6ca2f05e24fa82bfffdb9074e283181d7ea44ea0349fa93424fa6472b66534
|
|
BLAKE2b-256 checksum How to use checksums |
95c7fa43e3be0027ed9095c044985c260a5f73684e23d338072fdfac66db930f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.10.21
|