How do i create Magnet Links in the command line?
#1
Hello!

I'm looking for a tool or script that let's me create a magnet link from a .torrent file.
I'm using a Linux system. Ideally it would be command line only.

How does TPB do that?
Any tips?

Thanks for your help.
Reply
#2
The core of a magnet link is the torrent hash, which is the SHA1 value of a torrent's info dictionary.

If you have a particular language you like, you can probably find existing scripts for working with torrents. If not, the torrenteditor API is a good place to start: https://torrenteditor.com/api.php

That takes care of 99% of what you need. Read in the torrent file and call getHash() on it. Add any of the optional parameters to the URI that you like.

PHP Code:
require_once 'torrent.php';

$torr = new Torrent;

$torr->load(file_get_contents('/path/to/torrent/file'))

$hash $torr->getHash();
$name $torr->getName();
$trackers $torr->getTrackers();

$magnet_link 'magnet:?xt=urn:btih:' $hash ' &dn=' rawurlencode($name);

foreach (
$trackers as $t$magnet_link .= '&tr=' rawurlencode($t);

exit(
"$magnet_link\n"); 
Reply
#3
(Mar 25, 2014, 14:09 pm)kjf Wrote: The core of a magnet link is the torrent hash, which is the SHA1 value of a torrent's info dictionary.

If you have a particular language you like, you can probably find existing scripts for working with torrents. If not, the torrenteditor API is a good place to start: https://torrenteditor.com/api.php

That takes care of 99% of what you need. Read in the torrent file and call getHash() on it. Add any of the optional parameters to the URI that you like.

PHP Code:
require_once 'torrent.php';

$torr = new Torrent;

$torr->load(file_get_contents('/path/to/torrent/file'))

$hash $torr->getHash();
$name $torr->getName();
$trackers $torr->getTrackers();

$magnet_link 'magnet:?xt=urn:btih:' $hash ' &dn=' rawurlencode($name);

foreach (
$trackers as $t$magnet_link .= '&tr=' rawurlencode($t);

exit(
"$magnet_link\n"); 


Thanks kjf!
I'll give it a shot.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  looking to create onion site lancerackslol 0 10,274 Aug 02, 2022, 11:32 am
Last Post: lancerackslol
  Need to create a e-shop on darkweb destructor 2 25,195 Jan 13, 2022, 00:32 am
Last Post: thealmighty580
  how do I convert data in tpb dump to a magnet? polychoate 4 25,415 Sep 30, 2018, 17:46 pm
Last Post: dueda
  Trying to create php pages automatically ? Uplaoder 2 19,329 Aug 04, 2016, 02:54 am
Last Post: Uplaoder
  How to/Code for: insert clickable magnet link into picture ? DeGun 10 39,668 Jul 22, 2016, 16:56 pm
Last Post: 5c4lLY349



Users browsing this thread: 1 Guest(s)