Found something useful? Don't forget to leave a comment!


Thursday, January 22, 2009

uTorrent IPFilter Updater v1.5.1 Released + Adventures with Python

UPDATE: Version 1.5.1 was released on Jan. 27, 2009. This fixes a critical bug with a link that should have been dynamic instead of hardcoded, causing an error of “Download Link Not Found”. The new application logic accounts  for this correctly.

The all-new version 1.5 of my popular uTorrent IPFilter Updater has been released! Ever since the old Bluetack site stopped providing the downloads, all the files have been served from a new site – blocklistpro.com. I’ll admit that the new interface and web design is pretty spiffy, but it’s become a major pain in the ass as everything goes through a Remository backend that discourages automated downloads. The download links change regularly and are NOT regular files – rather, files are served through a script, and the system seems to implement a download limit of 3 times a day. Naturally, this fundamentally screwed all earlier versions of my updater.

Clipboard01

Being a self-proclaimed lazy fool, I vowed to create a program/script that could deal with this unpredictable dynamicness. This sort of task was just begging for a cheat-friendly, high-level language. Thinking what I’m thinking? Python! With its excellent gzip, urllib2 and re (regular expression) modules, Python is well-suited for this type of thing. Especially with its regex capabilities, it is a very powerful language when it comes to string manipulation. I was quickly able to cobble up a Python version of the updater that does the following:

  1. Check to make sure you have uTorrent installed!
  2. Fetch the HTML source of the info page containing the blocklist download link.
  3. Use a regex search to isolate the download link. (Necessary since the link is changing)
  4. Launch wget to do the dirty download work.
  5. Uncompress the resulting .GZ file.
  6. Move the ipfilter.dat to the uTorrent AppData folder.

The seasoned Python guru might ask why I chose to use wget, an external utility, instead of the built-in urllib/urllib2 modules to do the downloading. Quite simply, I would have had to do more coding (percent bars, screen output, etc.) Besides, wget is a capable and well-known downloading tool…

As I mentioned earlier, the new download site has a download limit; the Updater does nothing to circumvent this (probably unfeasible anyway). If the Updater detects that you have reached the download limit, it will exit with an error message noting that.

***For now, version 1.5 contains no new features and does more or less the same thing as the previous versions.***

If you already have Python 2.6.x installed, you may just run the plaintext script (see readme). For you non-Pythoners out there, I’ve created an EXE version using the excellent py2exe tool. To run the EXE version, though, you will need the Visual Studio 2008 SP1 Redistributable. Download that from Microsoft here.

To-do list:

  • add an option to allow downloading of the "paranoid” ipfilter
  • smart checking of local/remote file dates to prevent unnecessary downloads

For more info and the download link, visit the program webpage at

http://sites.google.com/site/whitehat2k9/Home/my-programs/utorrent-ipfilter-updater

2 comments:

ian said...

Just wanted to let you know that the updater has been saying 'Download Link Not Found' for the last two days. Yes, I am using v1.5.1 20090127

UofC2013 said...

Thanks for the heads-up. I'm already aware of the issue. The host site added a pre-download license agreement, which is throwing off the download code. I'm currently working on a fix - you can expect an updated version 1.5.2 very soon.