2

I'm wanting to include some bittorrent features in my Scala app. I want to use magnet links exclusively if I can for their ease of use. The issue is I'd like to use a prebuilt library like ttorrent. But, I found these libs don't use magnet links, they use the metainfo or the torrent file itself.

So I figure my first step is to take the magnet link and build a metainfo object myself. I understand the makeup of the magnet link pretty well and can parse it into the parameters. I'm just not quite sure how to use the magnet parameters. I don't know what to do with them.

Here's just a test magnet link I found on PB to work with:

magnet:?xt=urn:btih:ad11eb1a0aeed57116225fb341dc61883c22aeba&dn=Rise.of.the.Guardians.2012.TS.NEW.SOURCE.x264.AAC-UNiQUE&tr=udp%3A%2F%2Ftracker.openbittorrent.com%3A80&tr=udp%3A%2F%2Ftracker.publicbt.com%3A80&tr=udp%3A%2F%2Ftracker.istole.it%3A6969&tr=udp%3A%2F%2Ftracker.ccc.de%3A80

After parsing it I get:

xt=urn:btih:ad11eb1a0aeed57116225fb341dc61883c22aeba
dn=Rise.of.the.Guardians.2012.TS.NEW.SOURCE.x264.AAC-UNiQUE
tr=udp://tracker.openbittorrent.com:80
tr=udp://tracker.publicbt.com:80
tr=udp://tracker.istole.it:6969
tr=udp://tracker.ccc.de:80

Simple enough. Now I haven't used hashes too much, but I'm pretty sure I can't get any info from it directly. My only guess is that I may have to contact one of the trackers to get the metainfo. I'm not sure though.

[fyi] The torrenting will only be used for legal sharing, to share app data and app files between users of the app.

G1i1ch
  • 251
  • 3
  • 9

1 Answers1

1

To retrieve metadata based on an infohash a client needs

  1. be able to find peers, in this case via UDP trackers (BEP 15)*
  2. support the extension protocol (BEP 10)
  3. support metadata exchange (BEP 9) over the extension protocol

Since, according to its readme, ttorrent does not implement BEPs 9 and 10 it can't use magnet links.

[*] HTTP trackers and DHT are other sources and require their own protocols but are not relevant to this example

the8472
  • 40,999
  • 5
  • 70
  • 122