use warnings;
no if $] >= 5.018, warnings => 'experimental::smartmatch';
use parent qw/WWW::Search/;
+use re '/s';
our $VERSION = '0.001002';
our $MAINTAINER = 'Marius Gavrilescu <marius@ieval.ro>';
use WWW::Search::Torrentz::Result;
+sub debug { say STDERR @_ } ## no critic (RequireCheckedSyscalls)
+
sub gui_query{ shift->native_query(@_) }
-sub _native_setup_search{
+sub _native_setup_search{ ## no critic (ProhibitUnusedPrivateSubroutines)
my ($self, $native_query, $options) = @_;
$self->agent_email('marius@ieval.ro');
$options //= {};
$self->user_agent->delay(2/60);
}
-sub fullint ($) { int (shift =~ y/0-9//cdr) }
+sub fullint ($) { int (shift =~ y/0-9//cdr) } ## no critic (ProhibitSubroutinePrototypes)
-sub _parse_tree{
+sub _parse_tree{ ## no critic (ProhibitUnusedPrivateSubroutines)
my ($self, $tree) = @_;
my $found = 0;
next unless defined $a;
my $infohash = substr $a->attr('href'), 1;
- next unless $infohash =~ m,^[a-f0-9]{40}$,;
+ next unless $infohash =~ /^[a-f0-9]{40}$/;
my $title = $a->as_text;
my ($verified, $age, $size, $seeders, $leechers);
$verified = 0;
for my $span ($node->find('span')) {
given($span->attr('class')){
- $verified = int ($span->as_text =~ m,^\d+,) when 'v';
+ $verified = int ($span->as_text =~ /^\d+/) when 'v';
$age = $span->as_text when 'a';
$size = $span->as_text when 's';
$seeders = fullint $span->as_text when 'u';
}
push @{$self->{cache}}, WWW::Search::Torrentz::Result->new(infohash => $infohash, title => $title, verified => $verified, age => $age, size => $size, seeders => $seeders, leechers => $leechers, ua => $self->user_agent);
- say STDERR "infohash => $infohash, title => $title, verified => $verified, age => $age, size => $size, seeders => $seeders, leechers => $leechers" if $self->{search_debug};
+ debug "infohash => $infohash, title => $title, verified => $verified, age => $age, size => $size, seeders => $seeders, leechers => $leechers" if $self->{search_debug};
$found++;
}
my $url = $tree->look_down(rel => 'next');
if (defined $url) {
- my $prev = $self->{_prev_url} =~ s,/[^/]+$,,r;
+ my $prev = $self->{_prev_url} =~ s{/[^/]+$}{}r;
$self->{_next_url} = $prev . $url->attr('href')
}
- say STDERR "Found: $found" if $self->{search_debug};
+ debug "Found: $found" if $self->{search_debug};
return $found;
}
--- /dev/null
+severity = 1
+
+[-CodeLayout::RequireTidyCode]
+[-ControlStructures::ProhibitPostfixControls]
+[-ControlStructures::ProhibitUnlessBlocks]
+[-Documentation::PodSpelling]
+[-Documentation::RequirePodLinksIncludeText]
+[-InputOutput::RequireBracedFileHandleWithPrint]
+[-RegularExpressions::ProhibitEnumeratedClasses]
+[-RegularExpressions::RequireLineBoundaryMatching]
+[-Subroutines::RequireFinalReturn]
+[-ValuesAndExpressions::ProhibitConstantPragma]
+[-ValuesAndExpressions::ProhibitEmptyQuotes]
+[-ValuesAndExpressions::ProhibitMagicNumbers]
+[-ValuesAndExpressions::ProhibitNoisyQuotes]
+[-Variables::ProhibitLocalVars]
+[-Variables::ProhibitPackageVars]
+[-Variables::ProhibitPunctuationVars]
+
+[RegularExpressions::RequireExtendedFormatting]
+minimum_regex_length_to_complain_about = 20
+
+[Documentation::RequirePodSections]
+lib_sections = NAME | SYNOPSIS | DESCRIPTION | AUTHOR | COPYRIGHT AND LICENSE
+script_sections = NAME | SYNOPSIS | DESCRIPTION | AUTHOR | COPYRIGHT AND LICENSE
+
+[Subroutines::RequireArgUnpacking]
+short_subroutine_statements = 5
+allow_subscripts = 1