How to create torrent file from magnet link using

2019-02-11 09:23发布

So I wanted to work on a new Java project that converts magnet URIs into .torrent files, however I can't find a way to do that, basically I broke a magnet URI into pieces :

The used URI :

magnet:?xt=urn:btih:d2474e86c95b19b8bcfdb92bc12c9d44667cfa36&dn=Leaves+of+Grass+by+Walt+Whitman.epub&tr=udp%3A%2F%2Ftracker.example4.com%3A80&tr=udp%3A%2F%2Ftracker.example5.com%3A80&tr=udp%3A%2F%2Ftracker.example3.com%3A6969&tr=udp%3A%2F%2Ftracker.example2.com%3A80&tr=udp%3A%2F%2Ftracker.example1.com%3A1337

The breaking down :

magnet:?

xt=urn:btih:d2474e86c95b19b8bcfdb92bc12c9d44667cfa36

dn=Leaves+of+Grass+by+Walt+Whitman.epub

tr=udp%3A%2F%2Ftracker.example4.com%3A80

tr=udp%3A%2F%2Ftracker.example5.com%3A80

tr=udp%3A%2F%2Ftracker.example3.com%3A6969

tr=udp%3A%2F%2Ftracker.example2.com%3A80

tr=udp%3A%2F%2Ftracker.example1.com%3A1337

from what I gathered using this link, The torrent file contains the files , lengths and paths of the required files but I can't seem to get that from the magnet URI.

Thanks in advance.

2条回答
我命由我不由天
2楼-- · 2019-02-11 10:08

It's impossible to recreate the .torrent file from the magnet link alone.

The way torrent clients gets the .torrent file from a magnet link is:

查看更多
不美不萌又怎样
3楼-- · 2019-02-11 10:16

not really clean but..

Runtime.getRuntime().exec(new String[]{"cmd", "/c","start firefox " + mag});

// needs firefox and a default torrent handler. // mag = magnet string

查看更多
登录 后发表回答