BencodeNET icon indicating copy to clipboard operation
BencodeNET copied to clipboard

GetMagnetLink gives magnets with different urn

Open xanatos opened this issue 10 months ago • 1 comments

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)

xanatos avatar Aug 25 '23 11:08 xanatos