I need a way to convert .torrents into magnet links. Would like a way to do so in python. Are there any libraries that already do this?
相关问题
- how to define constructor for Python's new Nam
- streaming md5sum of contents of a large remote tar
- How to get the background from multiple images by
- Evil ctypes hack in python
- Correctly parse PDF paragraphs with Python
You can do this with the bencode module, extracted from BitTorrent.
To show you an example, I downloaded a torrent ISO of Ubuntu from here:
Then, you can parse it in Python like this:
A magnet hash is calculated from only the "info" section of the torrent metadata and then encoded in base32, like this:
You can verify that this is correct by looking here and you will see the magnet link is:
If you want to fill in some extra parameters to the magnet URI: