torstaina, heinäkuuta 26, 2007

AppleScripted downloads

I find I'm missing a download manager application. As I am a cheap bastard who is not certain he will be running Mac OS X in a few months, I don't want to spend money on the commercial or shareware download managers and I did not find any free ones.

I have a fairly standardized set of files I need to download every now and then and the files are large. It would be nice if the download had a progress indicator. Also, because the files are large and my network connection is kind of flakey, it would be a bonus if the broken downloads could be continued.

One more thing: I noticed that Safari does not allow one to download files to a specified folder, it downloads everything into the download folder and sometimes it fails to name the file with the basename of the URL and uses the host part of the URL instead. (Yes, FireFox does not have these problems. It has other problems, but let's not go into that.)

As I have played around with AppleScript during the last few weeks, I thought I would see if I can get finer-grade control over Safari downloads using AppleScript. It turns out Safari has a fairly small AppleScript dictionary and it does not allow script control over downloads.

Then I discovered there is a standard scripting component called "URL Scripting Access" that can download and upload using HTTP and FTP. The documentation even says it can display an optional progress bar.

This approach was a failure too.

There is no progress bar even when it is requested and the large downloads fail because the script times out. It would seem the download script is talking to another process called "URL Scripting Access", which does the actual downloading. Apparently there is some fixed timeout, a couple of minutes, after which the download script says a timeout has happened and exits with an error. The URL Scripting Access process is still running and still downloading (the file on the disk keeps growing and the System Monitor shows there is activity in the network.)

But I don't want to use this approach because there is no progress bar and no control over the download and it would seem there is no way to continue a broken download.

At the moment I'm considering other alternatives but they all would require more programming, especially UI programming, which I'm not familiar with. The time available for this project is getting short, next Moday my vacation is over.

I think I will use lftp for my downloads. It is available in MacPorts.

1 kommentti:

Rasmus S kirjoitti...

At least Safari 2.0 can resume downloads. While the download is in progress, it is downloaded to a .progress bundle. If you double-click on that (and the icon even has a tiny progress bar embedded) it will resume the download. Perhaps these are newfangled 2.0 features, though. And you can still only download to the designated download folde.