Archived

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

twistedfall

uTorrent WebUI command line utility and library for Python 3

Recommended Posts

I have written cross-platform command line client utility to access µTorrent WebUI. It is now increasingly useful as Linux µTorrent server is out, though it supports both server and desktop WebUIs. So I thought to share it with the community.

Homepage: http://github.com/twistedfall/utorrentctl

Utility itself: http://github.com/twistedfall/utorrentctl/raw/master/utorrentctl.py

README: http://github.com/twistedfall/utorrentctl/blob/master/README

You will want to also get http://github.com/twistedfall/utorrentctl/raw/master/config.py to have your connection parameters pre-set to your own values.

It is written in Python 3.1, so you will need an interpreter for it. Any modern Linux distro already has it (or it is installable from repo), Windows and Mac OS X users cat get it at: http://www.python.org/download/. I would like to get some non-Linux testing.

The API coverage it not yet complete, meaning you won't be able to do everything WebUI can, but I will try to improve it. But there are things you can do with utorrentctl that WebUI can't. For example removing torrent with data and torrent file and choosing download location for a single torrent.

Please feel free to ask any questions should they arise.

Share this post


Link to post
Share on other sites

Very nice! I just came here to share some shell scripts I'd written to handle simple tasks like adding a magnet link and pausing all the torrents without having to fire up webui (not that the Linux webui handles add URL yet!), but this is much more complete and polished. Very handy to associate the Linux command with the magnet protocol in Firefox and automatically load any magnet link you click :)

I haven't gone through all your API yet, but does it have commands to report basic stats like the current download rate?

Share this post


Link to post
Share on other sites

Well, maybe, but definitely not before it covers 100% of API — porting full version is easier than developing both simultaneously. What distribution are you running? Maybe I can help you with installing Python 3.

Share this post


Link to post
Share on other sites

Another bump. Optimized network usage (info about several torrents is now fetched in a single request, had to hack json a little to achieve this) added --all option to perform operation on all torrents at once, added ability to display torrent job info (upload/download limits, trackers, etc.), verbose is now enabled by default (use -V to reverse), library API and cli options are changed in several places, be aware, see --help for a list of actual options

Share this post


Link to post
Share on other sites

Again, cheers. Any idea on when you'll be adding tags to the client? If it's something you've already gotten started on or plan to do in the next few days, great. If not I may see about adding it to the latest version this week and post the patch up here.

Share this post


Link to post
Share on other sites

Do you mean labels? Library already supports them: each torrent has label field and you can receive label list with torrent_list( labels ), but cli utility doesn't yet show any labels. I will try to implement them the following week (the one that starts on 18 of October :) ). But patches are always welcome!

Share this post


Link to post
Share on other sites

Yeah, Labels. I was talking more about setting them than retrieving them but both are handy.

Looks like you haven't used the setprops call in the library so far, so I'll see about following your coding style and getting at the very least labels implemented tomorrow or Tuseday. I might just go through the entire list of possibilities for setprops while I'm at it though.

Share this post


Link to post
Share on other sites

Huh, easier than I thought for never having touched python before. Definitely never going to be my favorite language but I've seen worse. Labels are working, I'll go through the rest of setprops as I get time/the desire.

Link: patch

Oh, have a look at torrent_set_label if you would? It's currently making a request for each hash supplied because done like torrent_[start|stop|pause|etc...] it only changes the label of the last hash supplied. It's almost certainly something exceedingly simple but I've exhausted my patience for the night.

Share this post


Link to post
Share on other sites

Great! I have committed your patch. Though I will implement more generalized torrent properties change in near future so will probably rework it in some way.

Also I have added torrent sorting via -s, --sort and again made some minor adjustments in cli arguments

Share this post


Link to post
Share on other sites

Added ability to download files from the uTorrent server and generate magnet links from available torrents. Also beware, some command line switches changed to improve experience. For example login info switches are all uppercase now, -F is synonym to --force and can be used in place of --data --torrent when removing torrents, -f and -I is merged into -i

Share this post


Link to post
Share on other sites

Another update, added ability to set torrent properties (labels, upload/download speed), list filtering by label, batch file priority setting, torrent list caching (so that two consecutive requests to torrent_list() will use less traffic), ability to see complete torrent info with --dump

Share this post


Link to post
Share on other sites

Im having issues getting this to work. Do you need specific version of utorrent and webui??

I am running WebUI 3.71, utorrent 2.2 beta and win7 64bit.

I keep getting an error in line 434.

"resp = self.getresponse()"

Share this post


Link to post
Share on other sites

I keep getting an invalid syntax:

mortis% python utorrentctl.py --help
File "utorrentctl.py", line 267
return { k : str( getattr( self, k ) ) for k in self.get_sortable_attrs() }
^
SyntaxError: invalid syntax

Running Ubuntu Server 10.10 with python 3.1

Share this post


Link to post
Share on other sites
I keep getting an invalid syntax:

mortis% python utorrentctl.py --help

You should run it either like:

python3 utorrentctl.py --help

or make it executable:

chmod +x utorrentctl.py

and then run just like any executable file:

./utorrentctl.py --help

All above supposes that python3 in Ubuntu is installed with python3 binary name. Please let me know if it helps.

Share this post


Link to post
Share on other sites

Yup, that worked. python is pretty much the only language I'm not familiar with, so I just assumed having only python 3.1 installed would default to that binary. Thanks!

Share this post


Link to post
Share on other sites

Update with fixed bug showing infohash of added torrent with unicode file paths, also relative dir with --add now works as expected intuitively. So to get the old behavior you now need to specify '../movie' instead of just 'movie'

Share this post


Link to post
Share on other sites