{"id":15038605,"url":"https://github.com/danieltmbr/bencode","last_synced_at":"2025-04-10T01:23:11.304Z","repository":{"id":56903613,"uuid":"103413569","full_name":"danieltmbr/Bencode","owner":"danieltmbr","description":"Swift bencode decoder \u0026 encoder","archived":false,"fork":false,"pushed_at":"2023-12-17T17:45:18.000Z","size":221,"stargazers_count":14,"open_issues_count":3,"forks_count":12,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-03T21:28:27.210Z","etag":null,"topics":["bencode","ios","macos","swift","torrent"],"latest_commit_sha":null,"homepage":null,"language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/danieltmbr.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-09-13T14:57:23.000Z","updated_at":"2024-12-23T18:25:54.000Z","dependencies_parsed_at":"2024-09-29T00:31:39.672Z","dependency_job_id":null,"html_url":"https://github.com/danieltmbr/Bencode","commit_stats":{"total_commits":28,"total_committers":2,"mean_commits":14.0,"dds":0.1428571428571429,"last_synced_commit":"e43a85dd005f72bbb448ebc6534e1ab0277f72a1"},"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danieltmbr%2FBencode","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danieltmbr%2FBencode/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danieltmbr%2FBencode/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danieltmbr%2FBencode/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/danieltmbr","download_url":"https://codeload.github.com/danieltmbr/Bencode/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248138543,"owners_count":21053870,"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","ios","macos","swift","torrent"],"created_at":"2024-09-24T20:39:10.398Z","updated_at":"2025-04-10T01:23:11.276Z","avatar_url":"https://github.com/danieltmbr.png","language":"Swift","readme":"# Bencode\n\nBencode is a general purpose bencode encoder \u0026 decoder written in Swift 5.\n\nInspired by [VFK SwiftyBencode][vfk] \u0026 [arvidsigvardsson/Bencode][abc]\n\n## Installation\n\n**⚠️ Xcode 9 is required ⚠️**\n\n### Swift Package Manager\n\nJust add a new package on your project, and point to this repository.\n\n### CocoaPods\n\nBencode is available through [CocoaPods](http://cocoapods.org).\nTo install it, simply add the following line to your Podfile:\n\n```ruby\npod 'Bencode'\n```\n\n## Usage\n\n**Initialize with URL:**\n\n```swift\nlet bencode: Bencode? = Bencode(file: torrentUrl)\n```\n\n**Initialize with bencoded string:**\n\n```swift\nlet bencode: Bencode? = Bencode(bencodedString: content)\n```\n\n**Would you like to know more of the parsing failures, use the decoder:**\n\n```swift\ndo {\n    let bencode = Bencoder().decode(from: fileURL)\n} catch let error {\n    print(error)\n}\n```\n\n**Accessing properties:**\n\nAccessing properties is very handy with subscripts \u0026 accessors.\nValue accessors `.int`, `.string`, `.list` \u0026 `.dict` are optional.\nSubscripts produces **BencodeOptional** enums, by doing so you can chain optional subscripts without having to write `?` or `!` behind every one of them.\nBencode also comfort to Sequence protocol, so you can use `map`, `filter`, `foreach` etc. on them. :)\n\n```swift\nlet bencode = Bencode(file: torrentUrl)\n\nlet info = bencode[\"info\"]\nlet files = info[\"files\"]\n\n// You can use them as a sequence\n// .values is a shorthand for .map{ $0.value }\nfiles.values.forEach {\n    print($0[\"path\"][0].string!)\n}\n\n// Easy optional chaning without unwapping every stage:\nlet filePath: String? = info[\"files\"][0][\"path\"][0].string\nlet fileLength: Int? = bencode[\"info\"][\"files\"][\"length\"].int\n```\n\n## Help\n\n* Post any issues you find\n* Post new feature requests\n* Pull requests are welcome\n\n## Author\n\ndanieltmbr, daniel@tmbr.me\n\n## License\n\nBencode is available under the MIT license. See the LICENSE file for more info.\n\n\n[vfk]: https://github.com/VFK/SwiftyBencode\n[abc]: https://github.com/arvidsigvardsson/Bencode\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanieltmbr%2Fbencode","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdanieltmbr%2Fbencode","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanieltmbr%2Fbencode/lists"}