4 # Small multithreaded pr0n uploader, based partially on dave from HTTP::DAV.
7 # pr0n-upload.pl http://pr0n.sesse.net/webdav/upload/random/ *.JPG
9 # Adjust $threads to your own liking.
19 my $running_threads :shared = 0;
20 my $queue :shared = Thread::Queue->new;
22 # Enqueue all the images.
23 my $url = shift @ARGV;
24 $queue->enqueue(@ARGV);
26 # Fetch username and password, and check that they actually work.
27 my ($user, $pass) = get_credentials();
28 my $dav = init_dav($url, $user, $pass);
30 # Fire up the worker threads, and wait for them to finish.
32 for my $i (1..$threads) {
33 push @threads, threads->create(\&upload_thread);
35 while ($running_threads > 0) {
36 printf "%d threads running, %d images queued\n", $running_threads, $queue->pending;
39 for my $thread (@threads) {
46 my $dav = init_dav($url, $user, $pass);
47 while (my $filename = $queue->dequeue_nb) {
48 $dav->put(-local => $filename, -url => $url)
49 or warn "Couldn't upload $filename: " . $dav->message . "\n";
56 my ($url, $user, $pass) = @_;
57 my $ua = HTTP::DAV::UserAgent->new();
58 $ua->agent('pr0n-uploader/v1.0 (perldav)');
59 my $dav = HTTP::DAV->new(-useragent=>$ua);
60 $dav->credentials(-user=>$user, -pass=>$pass, -url=>$url, -realm=>'pr0n.sesse.net');
61 $dav->open(-url => $url)
62 or die "Couldn't open $url: " . $dav->message . "\n";
67 print "\nEnter username for $url: ";
68 chomp (my $user = <STDIN>);
69 exit if (!defined($user));
72 chomp (my $pass = <STDIN>);
76 return ($user, $pass);