| 1 | #!/usr/local/bin/perl | ||
| 2 | # WWW::ImageSpool by Tyler MacDonald <tyler@yi.org> 2004-05-15 | ||
| 3 | |||
| 4 | =pod | ||
| 5 | |||
| 6 | =head1 NAME imagespoold.pl - Periodically download images from the web | ||
| 7 | |||
| 8 | |||
| 9 | |||
| 10 | =head1 SYNOPSIS | ||
| 11 | |||
| 12 | imagespoold.pl --dir=spool_directory | ||
| 13 | [--dictionary=dictionary_file] | ||
| 14 | [--verbose[=0-4]] | ||
| 15 | [--max=bytes] | ||
| 16 | [--minx=x] [--miny=y] | ||
| 17 | [--limit=limit] [--searchlimit=limit] | ||
| 18 | [--consume | --no-consume] | ||
| 19 | [--sleep=seconds] [--run=seconds] | ||
| 20 | |||
| 21 | =head1 EXAMPLE | ||
| 22 | |||
| 23 | imagespoold.pl --dir=/var/cache/imagespool | ||
| 24 | --dictionary=/home/bob/favourite_things.txt | ||
| 25 | --verbose=1 --max=104857600 | ||
| 26 | --minx=320 --miny=240 | ||
| 27 | --sleep=30 > /home/bob/imagespoold.log | ||
| 28 | 2>&1 & | ||
| 29 | |||
| 30 | =head1 DESCRIPTION | ||
| 31 | |||
| 32 | imagespoold.pl will downloaded images from the internet into the directory specified by the | ||
| 33 | --dir argument, using random words as search keywords, picked from the dictionary file | ||
| 34 | specified by --dictionary (or /usr/share/dict/words if one is not specified). | ||
| 35 | |||
| 36 | =head1 OPTIONS | ||
| 37 | |||
| 38 | Most of the options directly correspond to options to the WWW::ImageSpool perl object. | ||
| 39 | Please see it's documentation for a description of those. There are also two additional options: | ||
| 40 | |||
| 41 | =over | ||
| 42 | |||
| 43 | =item --sleep=I<seconds> | ||
| 44 | |||
| 45 | How many seconds to wait between iterations. | ||
| 46 | |||
| 47 | =item --run=I<seconds> | ||
| 48 | |||
| 49 | Terminate after this many seconds. This is useful for, among other things, rotating dictionary files periodically. | ||
| 50 | |||
| 51 | =back | ||
| 52 | |||
| 53 | =head1 NOTE | ||
| 54 | |||
| 55 | This module may violate the terms of service of some search engines or content | ||
| 56 | providers. Use at your own risk. | ||
| 57 | |||
| 58 | =head1 LICENSE | ||
| 59 | |||
| 60 | Copyright 2004, Tyler "Crackerjack" MacDonald <tyler@yi.org> | ||
| 61 | This is free software; you may redistribute it under the same terms as perl itself. | ||
| 62 | |||
| 63 | =cut | ||
| 64 | |||
| 65 | use strict; | ||
| 66 | use warnings; | ||
| 67 | |||
| 68 | use Getopt::Long qw(GetOptions); | ||
| 69 | use WWW::ImageSpool; | ||
| 70 | |||
| 71 | my %opts = (sleep => 10, run => 0); | ||
| 72 | |||
| 73 | GetOptions(\%opts, "dir=s", "minx=i", "miny=i", "limit=i", "consume!", "verbose:i", "searchlimit=i", "dictionary=s", "max=i", "sleep=i", "run=i"); | ||
| 74 | |||
| 75 | if(defined($opts{verbose}) && $opts{verbose} == 0) | ||
| 76 | { | ||
| 77 | $opts{verbose} = 1; | ||
| 78 | } | ||
| 79 | |||
| 80 | if(my $spool = WWW::ImageSpool->new(%opts)) | ||
| 81 | { | ||
| 82 | my $run = 1; | ||
| 83 | while($run) | ||
| 84 | { | ||
| 85 | $spool->run; | ||
| 86 | sleep($opts{sleep}); | ||
| 87 | if($opts{run} > 0) | ||
| 88 | { | ||
| 89 | if($spool->uptime > $opts{run}) | ||
| 90 | { | ||
| 91 | $run = 0; | ||
| 92 | } | ||
| 93 | } | ||
| 94 | } | ||
| 95 | } |