Sunday, April 5, 2015

uTorrent API

I use uTorrent from time to time on my Linux system, but don't like too many stray seeds, so here's a nice little script to stop seeding torrents, just run it from cron at your desired frequency.

It uses the PHP API, from here:
https://github.com/tboothman/utorrent-php-api
http://forum.utorrent.com/topic/23307-php-api-for-the-webui/


#!/usr/bin/php

<?php

require_once("/var/www/webui_api.php");
$host = "your_ip";
$port = "8080";
$user = "user";
$pass = "pwd";

$utorrent = new \uTorrent\Api($host, $port, $user, $pass);
$torrents = $utorrent->getTorrents();

foreach($torrents as $torrent) {
        if ($torrent[UTORRENT_TORRENT_STATUS] == 201 && $torrent[UTORRENT_TORRENT_PROGRESS] == 1000) {
                $utorrent->torrentStop($torrent[UTORRENT_TORRENT_HASH]);
        }

}

?>



No comments:

Post a Comment