-
-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathamigaremix_dump
executable file
·48 lines (37 loc) · 1.14 KB
/
amigaremix_dump
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/usr/bin/perl
# abstract: rip all songs from amigaremix.com - in parallel
use strict;
use vars qw($VERSION);
$VERSION = '0.001';
use WWW::Mechanize;
use Parallel::ForkManager;
my $m = WWW::Mechanize->new(
agent_alias => 'Linux Mozilla',
);
# nasty :-) {{{
$m->get('http://www.amigaremix.com/remixes/9999');
$m->follow_link(url_regex => qr{remixes/\d+});
my($last_page) = ($m->uri =~ m{/(\d+)$});
$last_page++;
#}}}
my @files;
for my $u(1 .. $last_page) {
$m->get("http://amigaremix.com/remixes/$u");
push(@files, grep{ m/[.]mp3$/ } map{ $_->url_abs } $m->find_all_links);
}
printf("Found %d files.\n", scalar @files);
my $PROCESS_MAX = scalar @files / 2;
printf("Will spawn %d processes, is that ok? [y/N] ", $PROCESS_MAX);
chomp(my $answer = <>);
die "Aborting...\n" unless lc($answer) eq 'y';
my $pm = Parallel::ForkManager->new( $PROCESS_MAX );
printf "\e[?7t";
for my $f(@files) {
$pm->start and next;
$m->get($f);
my($dest) = $f =~ m{.+/(.+[.]mp3)$};
$dest =~ s/%20/_/g, s/_+/_/g;
print "$f => $dest\n" if $m->save_content($dest) == 0;
$pm->finish;
}
printf "\e[?7t";