bento
bento copied to clipboard
Adding support for magnet link generation
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 :)
Glad to hear it's useful for you! Magnet support sounds great, I'm happy to see that as a PR.
Your comment reminded me about something you may want to address when writing this PR: the encoder alphabetically orders Map keys when encoding but the parser doesn't validate that bencoded dicts have alphabetical keys when parsing. This means the hash of a torrent file with unsorted dict keys will not equal the hash of decoding and reencoding that torrent with Bento. It's my understanding that magnet links address content by hash value, so this could cause two separate links for what is effectively the same content.
Since the bencode spec requires that dict keys be alphabetically ordered, you'll only come across this issue if you're working with noncompliant torrent files. If the files you work with are all spec-compliant, or if you don't care about the above issue, don't worry about it :)
Happy holidays!
On Sun, Dec 24, 2017, 10:19 Théophile Choutri [email protected] wrote:
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 :)
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/folz/bento/issues/11, or mute the thread https://github.com/notifications/unsubscribe-auth/AASREfyOgjMIHuVFTOOJ096I4CIdnuYsks5tDmt2gaJpZM4RL8zK .
@folz Okay, I'm almost done implementing it. Before I open a PR, do you have any opinion about the API I should provide? I understand that I should provide a !
and non-!
of my magnet
function, but should I leave the file reading to the user?
Thanks for your support. :)
Yep, like .torrent!?()
you should have one version that raises and one that returns ok/error, and the user should handle reading a file or otherwise loading the iodata that you pass to Bento.magnet!?()
, and they should also handle saving/persisting the response. You just need to accept and return some iodata.
Thanks for working on this. I'm looking forward to the PR!
Was this ever submitted?
No, it wasn't. If you want to submit a PR, or if @tchoutri is interested in finding their old work, I'd be happy to get it merged in.
Unfortunately I have lost said work. :/
No worries :) just figured I'd ask.
My plan is to use c libtorrent wrapped via Unifex to support the webtorrent protocol, however that's not this library. Thanks for all the replies.