Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GetMagnetLink gives magnets with different urn #62

Open
xanatos opened this issue Aug 25, 2023 · 1 comment
Open

GetMagnetLink gives magnets with different urn #62

xanatos opened this issue Aug 25, 2023 · 1 comment

Comments

@xanatos
Copy link

xanatos commented Aug 25, 2023

The GetMagnetLink recalculates the InfoHash, but the recalculated InfoHash is different from the OriginalInfoHash that was calculated on initial loading of the file, and so the magnet has a different urn.

The torrent is from https://archive.org/details/equestriagirlsdashforthecrown and is https://archive.org/download/equestriagirlsdashforthecrown/equestriagirlsdashforthecrown_archive.torrent (but I have the same problem with other torrents).

I'm using .NET Core 7.0

var parser = new BencodeParser();
Torrent torrent = parser.Parse<Torrent>("equestriagirlsdashforthecrown_archive.torrent");
string magnetLink1 = torrent.GetMagnetLink();

The result I obtain:

magnet:?xt=urn:btih:d02d19163df7ab5c835d84f0a0b1f9bd4c32d239&dn=equestriagirlsdashforthecrown&tr=http%3A%2F%2Fbt1.archive.org%3A6969%2Fannounce&tr=http%3A%2F%2Fbt2.archive.org%3A6969%2Fannounce

The expected result:

magnet:?xt=urn:btih:91d66f363d2f603e336b34493d10fe63f7740251&dn=equestriagirlsdashforthecrown&tr=http%3a%2f%2fbt1.archive.org%3a6969%2fannounce&tr=http%3a%2f%2fbt2.archive.org%3a6969%2fannounce&ws=http%3a%2f%2fia802702.us.archive.org%2f18%2fitems%2f&ws=http%3a%2f%2fia902702.us.archive.org%2f18%2fitems%2f&ws=https%3a%2f%2farchive.org%2fdownload%2f

OriginalInfoHash is (correctly) 91d66f363d2f603e336b34493d10fe63f7740251

(or something similar, BencodeNET doesn't support url-lists/ws= , but it isn't a problem. It is a feature used only by very few servers like archive.org)

@Krusen
Copy link
Owner

Krusen commented Oct 29, 2023

This is because the Torrent class is just a quick solution originally made mainly for help with creating torrents. Some limited parsing of torrent files was added as well, but it doesn't load in all original fields from the torrent, so some can be missing when then info hash is then recalculated - in this instance specifically fields crc32, md5, sha1 and mtime on every entry in info.files dictinoary.

I'm unlikely to be updating the torrent parsing functionality any time soon. Ideally the Torrent class would just work on top of a BDictionary directly, that way all fields would be there from the original torrent file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants