Continuing on yesterday’s work, I’ve gotten iTorrent to be functionally complete. The one thing that remains to be done is putting together the iPhone UI that it draws it’s name against. That just involves putting some templates in the iphone/ directory and (probably) writing a ton of Javascript to make the experience pleasant. Since I hate designing things, I left that till the end…
I did find a number of things worthy of being shared, though. First and foremost is how awesome rTorrent’s XMLRPC interface truly is. The system.multicall method is incredibly, incredibly, incredibly powerful:
$results = $this->rpc->multicall(array(
array('methodName' => 'get_max_uploads_global', 'params' => array(''),
. . .
));
With that, I am able to get/set all of my rTorrent client settings in one HTTP request. Tiny amounts of overhead FTW.
However, PEAR::XML_RPC2 or Curl or something don’t do the multicall so well with Lighttpd. It sends some kind of Expect header to Lighty and it freaks out and replies with an HTTP 417 code. I only noticed this when doing system.multicall.
According to InfinityB, this is going to be fixed in Lighttd 1.5.x, but in the mean time, here’s a patch you can apply to force it to send the expect header as blank:
/usr/share/php/XML/RPC2/Util/HTTPRequest.php
197c197
< curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-type: text/xml; charset='.$this->_encoding, ‘User-Agent: PEAR_XML_RCP2/0.0.x’)) &&
—
> curl_setopt($ch, CURLOPT_HTTPHEADER, array(’Content-type: text/xml; charset=’.$this->_encoding, ‘User-Agent: PEAR_XML_RCP2/0.0.x’, ‘Expect: ‘)) &&
The functionality I added to iTorrent today was:
- Adding torrents by URL
- Setting client-wide settings (max up/down rate, download/upload/seed slots, etc)
- Viewing RSS feeds and adding these torrents with one click (and having the damn nyaatorrent URLs rewritten to be direct links to the torrent instead of their fucking info page)
- RSS highlights
I also learned that PHP can’t handle strings worth shit. The TT RSS feed has very unicode-y things (funny characters in things that could be ASCII, mooninite glyphs, etc), and comparing these to titles that rTorrent reports does not work well at all. What I finally did was strip the zero-width space characters out of titles in the RSS feed, which makes it fairly reliable for any torrent/RSS item titles that do not have moon glyphs in them.
My model classes for hiding all of the nasty details of XMLRPC are all kinda like some sort of ActiveRPC implementation. They’re pretty slick. Even if somebody doesn’t want to use my UI, the classes would go a long way towards helping them write some PHP scripts to automate torrenting for them.
I’ll have a source release when I finish my iPhone UI. I’ll probably have some thoughts on web design for the iPhone in a few days.