aoemaster Posted June 14, 2012 Report Share Posted June 14, 2012 Hi !First, excuse my language, i'm french. 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-fileI 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-mailA 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 More sharing options...
aoemaster Posted June 15, 2012 Author Report Share Posted June 15, 2012 Finnaly find some solution :// curl requestmake_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 timei fixed this problem with a home made mutex solutionfunction wait_for_jeton(){ while(file_exists('jeton')) usleep(1000); touch('jeton');}function finish_jeton(){ unlink('jeton');}finnaly the code become :wait_for_jeton();// curl requestmake_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 More sharing options...
Kitsoran Posted June 16, 2012 Report Share Posted June 16, 2012 You can't just find the torrent you just added and pull the details for it rather then relying on it being at the end? Link to comment Share on other sites More sharing options...
aoemaster Posted June 16, 2012 Author Report Share Posted June 16, 2012 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 OoThis API isn't really good :/ Link to comment Share on other sites More sharing options...
Firon Posted June 18, 2012 Report Share Posted June 18, 2012 It's an old API that was hacked together a long time ago. Link to comment Share on other sites More sharing options...
wrz.dev Posted June 20, 2012 Report Share Posted June 20, 2012 i have a .NET solution, actually it calculates the torrent hash from the file, and when torrent is added it check it on the basis of hash! Link to comment Share on other sites More sharing options...
aoemaster Posted June 21, 2012 Author Report Share Posted June 21, 2012 i have a .NET solution, actually it calculates the torrent hash from the file, and when torrent is added it check it on the basis of hash!never thought about it =D its a good ideai found a great php solution for getting torrent info :here (in french) :http://atmoner.com/php-class-torrent-bdecode-et-bencode-avec-curl/ Link to comment Share on other sites More sharing options...
wrz.dev Posted June 21, 2012 Report Share Posted June 21, 2012 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 ideai 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 More sharing options...
Ultima Posted July 14, 2012 Report Share Posted July 14, 2012 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. Link to comment Share on other sites More sharing options...
wrz.dev Posted July 29, 2012 Report Share Posted July 29, 2012 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 More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.