I am learning about bittorrent protocols and have a question I'm not too sure about.
According to BEP009,
magnet URI format
The magnet URI format is:
v1: magnet:?xt=urn:btih:info-hash&dn=name&tr=tracker-url
v2: magnet:?xt=urn:btmh:tagged-info-hash&dn=name&tr=tracker-url
info-hash Is the info-hash hex encoded, for a total of 40 characters. For compatability with existing links in the wild, clients should also support the 32 character base32 encoded info-hash.
tagged-info-hash Is the multihash formatted, hex encoded full infohash for torrents in the new metadata format. 'btmh' and 'btih' exact topics may exist in the same magnet if they describe the same hybrid torrent.
example magnet link: magnet:?xt=urn:btih:407AEA6F3D7DC846879449B24CA3F57DB280DE5C&dn=ubuntu-educationpack_14+04_all&tr=udp%3A%2F%2Ftracker.opentrackr.org%3A1337%2Fannounce&tr=udp%3A%2F%2Fexplodie.org%3A6969
Correct me if i'm wrong, but urn:btih:407AEA6F3D7DC846879449B24CA3F57DB280DE5C is the info-hash from the magnet link, and i will need to decode it to be able to obtain a bencoded metadata such as listed in BEP015. Things such as: downloaded, left, uploaded, event, etc.
My question is, how do I decode this in python?
The info-hash in Magnet Link is the same as the info-hash required for a UDP Tracker (20-bytes SHA-1 hash of bencoded "info" dictionary of a torrent).
Additionally, a UDP Tracker doesn't use bencoded data at all, just bytes! Bencoded format is used by HTTP/HTTPs trackers though.