Skip to content

Commit

Permalink
-X option for non colored and non wait_key results
Browse files Browse the repository at this point in the history
  • Loading branch information
z448 committed Jan 23, 2024
1 parent aec961b commit 1932937
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 12 deletions.
1 change: 0 additions & 1 deletion lib/App/trrr/RBG.pm
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ sub results {
$t{domain} = $domain;
$t{link} = $1;
$t{link} = 'https://' . $domain . $t{link};
print "$t{link}\n";
$t{title} = $2;
}

Expand Down
32 changes: 21 additions & 11 deletions trrr
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ our $VERSION = '0.23';


my @keyword = ();
if( scalar @ARGV == 0 or (scalar @ARGV == 1 and $ARGV[0] =~ /^-(p|r|y|k|e|x|l|[A-O])$/) ){
if( scalar @ARGV == 0 or (scalar @ARGV == 1 and $ARGV[0] =~ /^-(p|r|y|k|e|x|l|[A-O]|X)$/) ){
my $clipboard = clipboard();
$clipboard =~ s/\n/ /g;
$clipboard =~ s/^ //;
Expand All @@ -45,7 +45,7 @@ if( -f "$ENV{HOME}/.trrr" ){
if($field eq 'api'){
print "unrecognized source '$value'\n" and exit unless $value =~ /^(tpb|rbg|yts|kat|ext|x137|lme)$/;
}
$opt->{$field} = $value if $field =~ /^(seeds|api)$/;
$opt->{$field} = $value if $field =~ /^(seeds|api|color)$/;
}
close $conf;
}
Expand All @@ -58,11 +58,13 @@ else {


for(@ARGV){
if(/^\-(h|-help|help|[A-O]|v|p|r|y|k|e|x|l)$/){
if(/^\-(h|-help|help|[A-O]|X|v|p|r|y|k|e|x|l)$/){
s/\-//;
if(/^(h|-help|help)$/){ help() and exit }
if(/^(v)$/){ print "$VERSION\n" and exit }
if(/^[A-O]$/){ $opt->{key} = $_ }
if(/^[A-O]|X$/){ $opt->{key} = $_ }
if(/^X$/){ $opt->{color} = 0 }
#if(/^[A-O]$/){ $opt->{key} = $_ }
if(/^p$/){ $opt->{api} = "tpb" }
if(/^r$/){ $opt->{api} = "rbg" }
if(/^y$/){ $opt->{api} = "yts" }
Expand Down Expand Up @@ -146,7 +148,7 @@ sub show {

unless(@result){ print colored(['yellow'], 'no results') . "\n" and exit }

print colored(['white on_white'], ' ') . colored(['black on_white'], $result[0]->{source}) . colored(['white on_white'], ' ') ."\n";
print colored(['white on_white'], ' ') . colored(['black on_white'], $result[0]->{source}) . colored(['white on_white'], ' ') ."\n" if $opt->{color};

my $key = 'A';
my( $key_color ) = ();
Expand All @@ -165,9 +167,17 @@ sub show {
}

if($_->{api} eq 'yts'){
print colored([$key_color], $key) . ' ' . colored( ['yellow'], $_->{title} ) . ' ' . colored(['yellow'], "($_->{year})") . ' ' . colored(['grey8'], $_->{category}) . "\n";
if( $opt->{color} ){
print colored([$key_color], $key) . ' ' . colored( ['yellow'], $_->{title} ) . ' ' . colored(['yellow'], "($_->{year})") . ' ' . colored(['grey8'], $_->{category}) . "\n";
} else {
print $key . ' ' . $_->{title} . ' ' . $_->{year} . ' ' . $_->{category} . "\n";
}
} else {
print colored([$key_color], $key) . ' ' . colored(['grey7'], $_->{seeds}) . ' ' . colored(['yellow'], $_->{title} ) . ' ' . colored(['grey7'], $_->{category}) . ' ' . colored(['bold'], $_->{size}) . "\n";
if( $opt->{color} ){
print colored([$key_color], $key) . ' ' . colored(['grey7'], $_->{seeds}) . ' ' . colored(['yellow'], $_->{title} ) . ' ' . colored(['grey7'], $_->{category}) . ' ' . colored(['bold'], $_->{size}) . "\n";
} else {
print $key . ' ' . $_->{seeds} . ' ' . $_->{title} . ' ' . $_->{category} . ' ' . $_->{size} . "\n";
}
}
$key++; $i++;
}
Expand All @@ -178,17 +188,15 @@ sub wait_key {
my $result = shift;

if( $opt->{key} ){
exit if $opt->{key} eq 'X';
get_torrent($result) and exit;
} else {
if( $^O eq 'MSWin32' or $^O eq 'msys' ){
print "To pick from results repeat search and add -[key] (e.g. -a)\n" and exit;
}

# print colored(['white on_grey3'],'P') . colored(['grey5 on_white'],'RESS') . colored(['white on_grey3'],'K') . colored(['grey5 on_white'],'EY') . "\n";

print ' ' . colored(['grey5 on_white'],'P') . colored(['white on_grey3'],'RESS') . colored(['grey5 on_white'],'K') . colored(['white on_grey3'],'EY') . "\n";

#require App::trrr::HotKey;
#App::trrr::HotKey->import( 'readkey' ) ;
use App::trrr::HotKey qw< readkey >;
$opt->{key} = uc readkey();
get_torrent($result);
Expand Down Expand Up @@ -298,6 +306,8 @@ C<trrr>
- To automaticaly open some magnet link from results add its key -[A-O] as an option.
E.g: to open first (A) magnet link use following command.
- To just list results without picking any use -X option.
=over 10
C<trrr keyword1 keyword2 keywordN -A>
Expand Down

0 comments on commit 1932937

Please sign in to comment.