#bencode #bittorrent #nushell #nu #torrent

bin+lib nu_plugin_from_bencode

A Nushell plugin to convert bencode data into Nu structured values

2 unstable releases

0.10.0 Feb 8, 2024
0.9.0 Dec 16, 2023
0.8.1 Nov 21, 2023
0.7.0 Oct 20, 2023
0.2.0 May 4, 2022

#875 in Encoding

Download history 15/week @ 2024-02-04 5/week @ 2024-02-11 58/week @ 2024-02-18 19/week @ 2024-02-25 9/week @ 2024-03-10 1/week @ 2024-03-17 57/week @ 2024-03-31

67 downloads per month

MIT/Apache and maybe CC-PDDC

21KB
129 lines

Nu Plugin From Bencode

A converter plugin from the bencode format for Nushell.

The plugin was last tested on nushell version 0.90.1.

The plugin is unstable as the interface Nu for plugins is unstable.

The plugin could be useful for inspecting a BitTorrent metainfo file (*.torrent), but it is primarily used to explore writing a Nu plugin.

Installation

cargo install nu_plugin_from_bencode

Register the plugin:

register <path to plugin>/nu_plugin_from_bencode

By default, cargo installs to $HOME/.cargo/bin on Unix systems.

Usage

The from bencode command is provided with no parameter arguments.

To use:

> open ubuntu-20.04.4-live-server-amd64.iso.torrent | from bencode
╭───────────────┬─────────────────────────────────────╮
 announce      │ https://torrent.ubuntu.com/announce │
 announce-list │ [list 2 items]
 comment       │ Ubuntu CD releases.ubuntu.com       │
 created by    │ mktorrent 1.1                       │
 creation date │ 1645734525                          │
 info          │ {record 4 fields}
╰───────────────┴─────────────────────────────────────╯
> open ubuntu-20.04.4-live-server-amd64.iso.torrent | from bencode | select announce-list.0.0
╭───────────────────┬─────────────────────────────────────╮
 announce-list.0.0 │ https://torrent.ubuntu.com/announce │
╰───────────────────┴─────────────────────────────────────╯
> open ubuntu-20.04.4-live-server-amd64.iso.torrent | from bencode | get announce-list.1.0
https://ipv6.torrent.ubuntu.com/announce
> open ubuntu-20.04.1-live-server-amd64.iso.torrent | from bencode | select info.name info.length
╭─────────────┬──────────────────────────────────────╮
 info.name   │ ubuntu-20.04.4-live-server-amd64.iso │
 info.length │ 1331691520                           │
╰─────────────┴──────────────────────────────────────╯

License

Licensed under either of Apache License, Version 2.0 or MIT License at your option.

Contributions

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Dependencies

~13–47MB
~706K SLoC