folz / bento Goto Github PK
View Code? Open in Web Editor NEW:bento: A fast, correct, pure-Elixir library for reading and writing Bencoded metainfo (.torrent) files.
License: Mozilla Public License 2.0
:bento: A fast, correct, pure-Elixir library for reading and writing Bencoded metainfo (.torrent) files.
License: Mozilla Public License 2.0
Hi! I'm already using Bento to parse torrent files, and I would like to know if you'd accept a PR that implements magnet link generation from a torrent file.
Happy holidays :)
When Bento.encode/1
encounters a Tuple, an error will be reported.
iex(1)> Bento.encode {:does, :not, :work}
** (Protocol.UndefinedError) protocol Bento.Encoder not implemented for {:does, :not, :work} of type Tuple
(bento 1.0.0-dev) lib/bento/encoder.ex:35: Bento.Encoder.impl_for!/1
(bento 1.0.0-dev) lib/bento/encoder.ex:56: Bento.Encoder.encode/1
(bento 1.0.0-dev) lib/bento.ex:36: Bento.encode!/2
(bento 1.0.0-dev) lib/bento.ex:22: Bento.encode/2
iex:1: (file)
This is due to :erlang.binary_to_existing_atom not being able to turn "name.utf-8" into an atom (the period is what causes it to trip up).
Stacktrace
** (exit) an exception was raised:
** (ArgumentError) errors were found at the given arguments:
1st argument: invalid UTF8 encoding
:erlang.binary_to_existing_atom("name.utf-8", :utf8)
(bento 0.9.2) lib/bento/metainfo.ex:48: anonymous fn/1 in Bento.Metainfo.transform/1
(elixir 1.12.0) lib/enum.ex:1553: Enum."-map/2-lists^map/1-0-"/2
(elixir 1.12.0) lib/enum.ex:1553: Enum."-map/2-lists^map/1-0-"/2
(bento 0.9.2) lib/bento/metainfo.ex:30: Bento.Metainfo.info/1
(bento 0.9.2) lib/bento/metainfo.ex:41: Bento.Metainfo.info!/1
(bento 0.9.2) lib/bento.ex:92: Bento.torrent!/1
"name.utf-8" appears to be from clients such as Vuze/Azeurus for handling old torrents that did not write the name/path's in utf-8 (see here).
I am not sure how to "properly" handle this, but for now I will just have it filter out any keys with .utf-8 in the data metainfo before parsing. Id be happy to merge those changes in, or any different change you would suggest.
Thanks for the useful library!
This reconstruction is based on three considerations:
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.