POE-Component-IRC-Plugin-RTorrentStatus
view release on metacpan or search on metacpan
bin/irctor-queue view on Meta::CPAN
#!/usr/bin/env perl
use strict;
use warnings FATAL => 'all';
use utf8;
use Capture::Tiny 'capture';
use File::Find;
use File::Spec::Functions qw(catdir catfile splitdir splitpath);
use File::stat;
use List::Util 'first';
use POSIX 'strftime';
my ($LOG_FILE, $ACTION, $NAME, @args) = @ARGV;
die "Log file argument is missing" if !defined $LOG_FILE;
die "Action argument is missing" if !defined $ACTION;
die 'Name argument missing' if !defined $NAME;
my $sub = "_${ACTION}_torrent";
__PACKAGE__->$sub(@args) if $NAME !~ /^[0-9A-F]+\.meta$/;
sub _inserted_new_torrent {
shift @_;
my ($size, $torrent_file) = @_;
for ($size, $torrent_file) {
die "An argument is missing for 'inserted_new'" if !defined $_;
}
my $user = getpwuid(stat($torrent_file)->uid);
_torrentlog($ACTION, $NAME, $user, $size);
return;
}
sub _erased_torrent {
shift @_;
my ($size, $down, $up, $ratio) = @_;
for ($size, $down, $up, $ratio) {
die "An argument is missing for 'erased'" if !defined $_;
}
_torrentlog($ACTION, $NAME, $size, $down, $up, $ratio);
return;
}
sub _hash_queued_torrent {
shift @_;
my ($size, $done_size, $torrent_file, $complete) = @_;
for ($size, $done_size, $torrent_file, $complete) {
die "An argument is missing for 'erased'" if !defined $_;
}
return if $complete || $size != $done_size;
my $enqueued = stat($torrent_file)->ctime;
my $finished = time;
_torrentlog($ACTION, $NAME, $enqueued, $finished, $size);
return;
}
sub _finished_torrent {
shift @_;
my ($content, $top_dir, $unrar) = @_;
chdir $top_dir or die "Can't chdir to $top_dir\n";
my $hash_done = time;
my $hash_started = 0;
if (-f $content) {
$hash_started = stat($content)->mtime;
}
else {
find(
sub {
return if -d $_;
my $mtime = stat($_)->mtime;
$hash_started = $mtime if $mtime > $hash_started;
},
$content,
);
}
my @rars;
my $rar_count = -1;
if ($unrar) {
if (-d $content) {
( run in 1.702 second using v1.01-cache-2.11-cpan-6aa56a78535 )