{"id":21383100,"url":"https://github.com/bashkirtsevich-llc/py3bencode","last_synced_at":"2025-07-27T09:37:40.361Z","repository":{"id":62578440,"uuid":"103769639","full_name":"bashkirtsevich-llc/py3bencode","owner":"bashkirtsevich-llc","description":"Python 3.7 bencoding library","archived":false,"fork":false,"pushed_at":"2019-06-04T10:41:07.000Z","size":33,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-10-05T06:55:35.224Z","etag":null,"topics":["bencode","bencode-parser","bittorrent"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/py3-bencode/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bashkirtsevich-llc.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-09-16T17:11:15.000Z","updated_at":"2021-12-31T10:24:03.000Z","dependencies_parsed_at":"2022-11-03T19:15:46.149Z","dependency_job_id":null,"html_url":"https://github.com/bashkirtsevich-llc/py3bencode","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bashkirtsevich-llc%2Fpy3bencode","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bashkirtsevich-llc%2Fpy3bencode/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bashkirtsevich-llc%2Fpy3bencode/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bashkirtsevich-llc%2Fpy3bencode/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bashkirtsevich-llc","download_url":"https://codeload.github.com/bashkirtsevich-llc/py3bencode/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225886753,"owners_count":17539857,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bencode","bencode-parser","bittorrent"],"created_at":"2024-11-22T11:19:57.349Z","updated_at":"2024-11-22T11:19:57.829Z","avatar_url":"https://github.com/bashkirtsevich-llc.png","language":"Python","readme":"# Python 3 bencoding library\n[![Build Status](https://travis-ci.org/bashkirtsevich-llc/py3bencode.svg?branch=master)](https://travis-ci.org/bashkirtsevich-llc/py3bencode)\n\nPython 3 bytearray bencoding library.\n\nEncode all data into `byte`. Useful for networking.\n\n\n## Example\n\n```python\n\u003e\u003e\u003e from bencode import bencode, bdecode\n\n\n\u003e\u003e\u003e foo = bencode({\"foo\": [0, -1, 2, \"3\", {\"4\": 5}], \"bar\": {\"baz\": 1}})\n\u003e\u003e\u003e print(foo)\nb'd3:bard3:bazi1ee3:fooli0ei-1ei2e1:3d1:4i5eeee'\n\n\u003e\u003e\u003e bar = bdecode(foo)\n\u003e\u003e\u003e print(bar)\n{b'bar': {b'baz': 1}, b'foo': [0, -1, 2, b'3', {b'4': 5}]}\n\n```\n\n## `decoder` for `bdecode`\n\nOptional argument in `bdecode` function, provide decode bytes to another types. It can be helpful for decode dict key into strings.\n\n`decoder` is a callback function with arguments: `field_type`, `value`\n* `field_type` **str**, possible values: `\"key\"`, `\"value\"`;\n* `value` **bytes**.\n\n\n```python\n\u003e\u003e\u003e def custom_decoder(field_type, value):\n...     if field_type == \"key\":\n...         return str(value, \"ascii\")\n...     elif field_type == \"value\":\n...         return str(value, \"utf-8\")\n...     else:\n...         raise Exception(\"'field_type' can pass only 'key' and 'value' values\")\n...     \n\n\u003e\u003e\u003e bar = bdecode(foo, decoder=custom_decoder)\n\u003e\u003e\u003e print(bar)\n{'bar': {'baz': 1}, 'foo': [0, -1, 2, '3', {'4': 5}]}\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbashkirtsevich-llc%2Fpy3bencode","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbashkirtsevich-llc%2Fpy3bencode","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbashkirtsevich-llc%2Fpy3bencode/lists"}