-
-
Save z448/cf87d18f804f9e859c8a102eb04268d3 to your computer and use it in GitHub Desktop.
search torrents from CLI
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use 5.010; | |
use strict; | |
use warnings; | |
use Data::Dumper; | |
use HTTP::Tiny; | |
use JSON::PP; | |
use Term::ANSIColor; | |
my $help = <<'EOT'; | |
USAGE: | |
trrr key1 key2 -N | |
trrr big lebowski | |
trrr big lebowski -10 | |
EOT | |
say $help unless @ARGV; | |
#my $term = tput cols; | |
my $seeds = 1; | |
$seeds = $ARGV[$#ARGV] if $ARGV[$#ARGV] =~ /^-/; | |
$seeds =~ s/-//; | |
my $url = 'http://extratorrent.cc/json/?cid=4&search=' . join '+', @ARGV; | |
my $response = HTTP::Tiny->new->get($url); | |
my $results = decode_json $response->{content}; | |
my @filter = grep { $_->{seeds} > $seeds } @{$results->{list}}; | |
my $i = 0; | |
say colored(['white on_blue'],"Seeds\t") . colored(['white on_yellow'],"Title\t"); | |
for(@filter){ | |
say $i . "\t" . colored(['blue'],$_->{seeds}) . "\t" . colored(['yellow'], $_->{title}) . "\t" . int($_->{size}/1000/1000) . 'M'; | |
$i++; | |
} | |
__DATA__ | |
OSX /Applications/WebTorrent.app/Contents//MacOS/WebTorrent | |
$VAR1 = { 'link' => 'http://extratorrent.cc', 'description' => 'Extratorrent Search: big lebowski', 'title' => 'Extratorrent Search: big lebowski', 'list' => [ { 'files' => 17, 'torrentLink' => 'http://extratorrent.cc/download/2277121/', 'leechs' => -1, 'link' => 'http://extratorrent.cc/torrent/2277121/', 'hash' => 'b7cbd4a6be50403f17df469f3759d17a82ee6c28', 'category' => 'Movies', 'subcategory' => 'Comedy', 'seeds' => -1, ], 'total_results' => 73 }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment