Jump to content

How can I know which torrent was added ?


aoemaster

Recommended Posts

Hi !

First, excuse my language, i'm french. :P

I want to add torrent with the API with this methods :

http://[iP]:[PORT]/gui/?action=add-url&s=[url TORRENT]

http://[iP]:[PORT]/gui/?action=add-file

I will use PHP and Curl for doing it. No problem for that.

But when a torrent is added, I want to know the hash of the torrent I just added, because I want to "link" each torrent to a specifif user on a MySql table.

For example, I will make a PHP form with 2 fields :

The torrent url (or file)

An e-mail

A want to know which e-mail has added which torrent.

How can I do this ?

Thank you very much !

Link to comment
Share on other sites

Finnaly find some solution :

// curl request
make_request('action=add-url&s='.urlencode($_POST['url']));

// get all torrents
$all_torrents = make_request('list=1');
// the hash is the last inserted
$new_hash = $all_torrents['torrents'][ count($all_torrents['torrents'])-1 ][0];

of course, it works only if only one torrent is added at time

i fixed this problem with a home made mutex solution

function wait_for_jeton()
{
while(file_exists('jeton'))
usleep(1000);

touch('jeton');
}

function finish_jeton()
{
unlink('jeton');
}

finnaly the code become :

wait_for_jeton();

// curl request
make_request('action=add-url&s='.urlencode($_POST['url']));

// get all torrents
$all_torrents = make_request('list=1');
// the hash is the last inserted
$new_hash = $all_torrents['torrents'][ count($all_torrents['torrents'])-1 ][0];

finish_jeton();

Link to comment
Share on other sites

No. When I add a torrent, I just know his URL. I can't find the torrent with "list=1" and the url, because the URL isn't stored by utorrent (or just not accessible)

The best thing would be that adding a torrent return his hash. That would be logic for an API to return something, or just to know if the adding has worked, it's impossible Oo

This API isn't really good :/

Link to comment
Share on other sites

i have a .NET solution' date=' actually it calculates the torrent hash from the file, and when torrent is added it check it on the basis of hash![/quote']

never thought about it =D its a good idea

i found a great php solution for getting torrent info :

here (in french) :

http://atmoner.com/php-class-torrent-bdecode-et-bencode-avec-curl/

yah it was the very 1st idea that popped into my mind,

but the utorrent api must return the HASH of the added torrent!

Link to comment
Share on other sites

  • 4 weeks later...
  • 2 weeks later...
That would never work for add-url; add-url is an asynchronous request that can take an indefinite amount of time before the torrent ever shows up in µTorrent.

Otherwise, yes, something similar has been requested before.

well, in case i need add via url, i simply download the url & then add to the uTorrent!

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...