Automatically downloading ACID 8-Packs

Here’s a little perl script I use to automatically snag those handy (& free) ACID loops each week. This will determine the name of the current 8Pack, download it, extract it, and delete the zip file–leaving you with a nice folder including the ACID project and the loops. Then, just run it each week with a cron job.

#!/usr/bin/perl

use LWP::UserAgent;
$downloaddir = '/home/username/8Packs/';

$url = 'http://www.acidplanet.com/tools/8Packs';
$ua = new LWP::UserAgent;
$req = new HTTP::Request(GET => $url);
$req->content_type('application/x-www-form-urlencoded');
$res = $ua->request($req);
$page = $res->content;

$page =~ m/href=\"http:\/\/dspcdn\.acidplanet\.com\/8packs\/([\w\d\.]*)\"/i;
$fn = $1;
die ("No filename to get") if !$fn;
$file_url = 'http://dspcdn.acidplanet.com/8packs/'.$fn;

$fua = new LWP::UserAgent;
$freq = new HTTP::Request(GET => $file_url);
$fres = $fua->request($freq, $downloaddir.$fn);

if ($fres->is_success) {
$fn =~ m/(.*)\./;
my $extractto = $downloaddir.$1;
mkdir $extractto;
my $file = $downloaddir.$fn;
my $res = `unzip -d $extractto $file`;
unlink $file;
} else {
print $fres->status_line, "\n";
}

exit;

Advertisements

3 Responses

  1. sweet script

  2. How do i run the script…do you have it as an exe file coz this is awsum

    gr8 work

  3. Scott-
    Sorry, I don’t have it as an exe. All you’ll need to run it is Perl. For a windows installer of per, visit http://www.activestate.com. Then, just save the script above as a .pl file. Windows should automatically associate it with perl.

    You will have to modify the “$downloaddir” variable so that it works with windows. The simplest thing would be:

    $downloaddir = ‘C://’

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: