How do I create a Torrent Magnet URI from a directory?

I am working on building a file sharing platform for open source software in Python.

The problem I'm running into is how do I create a magnet link (to be stored in a database) from a directory? For example, I want to share dir / home / SHAREME. I know libtorrent has bindings for Python, but doesn't mention creating Magnet URIs directly.

Also, is it possible to "encode" the web seeds into a magnet URI? ( http://www.rasterbar.com/products/libtorrent/manual.html#http-seeding )

I can explain it wrong, but the use case: 1. Call a function to create a Torrent Magnet URI for a folder 2. Paste the Magnet URI into the database 3. Clients GET from the DB and use the Magnet URI to start the download using Web Seed

+3


source to share


2 answers


There is no way to create a magnetic URI directly, because such a link would be unusable !

Magnet links are hash identifiers that allow clients to retrieve a torrent file from the BitTorrent DHT network. However, they can only do this if there is at least one other client on the network (and with DHT enabled) that is downloading or uploading that torrent. If you created a torrent in your app and created a magnet link right away, no one will ever get that torrent file, so it won't download.



In short: magnet links really only work for torrents that are created and sown based on a peer-to-peer network. If you want to use web seed, you will need to provide the full torrent file for users to download.

+2


source


There is an approach for python3:

pip install magneturi



import magneturi
magneturi.from_torrent_file('xx.torrent')

      

-1


source







All Articles