#!/usr/bin/perl -w
use strict;
use HTML::TreeBuilder;
use LWP::Simple;
my ($url, $matchrx) = @ARGV;
my $tree = HTML::TreeBuilder->new->parse(get($url) || die "get($url): $!");
my @thumbs = $tree->look_down(qw(_tag img class jsVideoThumb)) or die 'no thumbs';
my $title = $tree->look_down(qw(_tag title))->as_text or die 'no title';
for (@thumbs) {
my ($alt, $src) = ($_->attr('alt'), $_->attr('src'));
if (index($title, $alt) < 0) {
next unless $matchrx and $alt =~ $matchrx;
}
$src =~ s/_\d\.jpg.*// or warn, next;
$src =~ s/jpeg/flash/ or warn, next;
print qq{mirror("$src.flv", "$alt.flv")\n};
mirror("$src.flv", "$alt.flv");
}