ucli
Ucli is a simple commandline interface against uTorrent's WebUI.
Requirements
- curl
- trollop >= 1.10 (gem)
- json (gem)
Getting started
Ucli uses a yaml file to store your configuration. An examplefile will be generated at first run.
~% ucli
No config file found.
Check out ~/.ucli_config.yml.example
Now edit this configuration file with your information and rename it to .ucli_config.yml
.
You are now ready to use the commands.
Usage
List all torrents
Running the command ucli --list
or ucli -l
will give you a list of all the torrents in utorrent.
The output will look like this:
+-----------------------------------------------------------+----------+-------+
| Torrentname | Uploaded | Ratio |
+-----------------------------------------------------------+----------+-------+
| ubuntu-8.10-desktop-i386.iso | 1.24 GB| 1.82|
| (34%) ubuntu-8.10-server-i386.iso | 0.00 KB| 0.00|
+-----------------------------------------------------------+----------+-------+
The percent in front the last torrent indicates how much is downloaded so far.
Uploading torrents
You can upload torrents from your local machine to the webui the ucli -u
command.
A label/category is required for all torrents.
ucli -u *.torrent -c "MISC"
The command above will upload all torrent files in your current working directory and add the label "MISC" all of them.
Remove torrents
You can remove torrents with the ucli -r
or ucli --remove
command.
You can specify a name or regex to match.
It will show you all the matches along with their shareratio and will not delete anything before you have confirmed it.
~% ucli -r server
Found the following torrents
============================
ubuntu-8.10-server-i386.iso (0.06)
Are you sure you want to remove these torrents? (y or n):
In this case there was only on matching torrent, but you can remove large amount of torrents using regexes.
Remove torrents and downloaded data
This action removes the specified torrent job(s) from the torrent jobs list and removes the corresponding torrent contents (data) from disk.
You can remove torrents and the downloaded data with the ucli -e
or ucli --removedata
command. You can specify a name or regex to match.
It will show you all the matches along with their shareratio and will not delete anything before you have confirmed it.
% ucli -e server
Found the following torrents
============================
ubuntu-8.10-server-i386.iso (0.06)
THIS ACTION WILL REMOVE ALL THE DOWNLOADED DATA!
Are you sure you want to remove these torrents? (y or n):
Removing old tv episodes
ucli --oldepisodes
looks for torrents of the same tv show. If you have two episode of the same show, it will suggest remove the oldest.
Let's say you have these episodes in uTorrent:
Tvshow.S01E01.HDTV-XviD-GROUP
Tvshow.S01E02.HDTV-XviD-GROUP
Another.show.S02E04.HDTV-XviD-GROUP
Another.show.S02E12.HDTV-XviD-GROUP
Now we try to run the command.
~% ucli --oldepisodes
Found the following old episodes
================================
Tvshow.S01E01.HDTV-XviD-GROUP (1.49)
Another.show.S02E04.HDTV-XviD-GROUP (1.20)
Do you want to remove them? (y or n):
Removing torrents based on ratio
ucli --ratioremove
will let you remove all torrents with a higher ratio than the value you specify.
~% ucli --ratioremove 13.4
Found the following torrents with ratio above 13.4
==================================================
ubuntu-8.10-desktop-i386.iso (16.64)
ubuntu-8.10-server-i386.iso (19.16)
Are you sure you want to remove these torrents? (y or n):
Listing files in torrents
ucli --ls
command will show you all the files with filesizes in the torrents matching you input.
~% ucli --ls server
ubuntu-8.10-server-i386.iso
===========================
ubuntu-8.10-server-i386.iso (637.32 MB)
Notes
I have not tried this script on Windows, and I don't think uploading torrents will work. This is due to the difference in the way windows passes arguments to programs as opposed to unix/linux. The other functionality shouldn't be a problem though.
This application was made to work with uTorrent WebUI 0.361. It will not work with earlier version, but probably will work with later versions.
You can actually use a regex for all the options that requires input to match a torrent.
ucli -r "\d\d"
will remove all torrents containing two digits.
More information about the Web UI API
LICENSE:
(The MIT License)
Copyright (c) 2009 Georg Alexander Bøe
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.