dotfiles

My dotfiles, nothing really interesting to see ...
git clone https://git.onna.be/dotfiles.git
Log | Files | Refs | README

commit 043a8b15d029a086104fd05bbc48f6d8e02a07bd
parent a9972a2dfe63b41519ec226e6a6c16aca6fe0049
Author: Paco Esteban <paco@onna.be>
Date:   Tue,  7 Aug 2018 12:18:19 +0200

search rarbg from the terminal

Diffstat:
bin/bin/rarbg.pl | 81+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 81 insertions(+), 0 deletions(-)

diff --git a/bin/bin/rarbg.pl b/bin/bin/rarbg.pl @@ -0,0 +1,81 @@ +#!/usr/bin/env perl + +use v5.26; +use strict; +use warnings; +use Rarbg::torrentapi; +use Getopt::Long; +use Data::Dumper; + +sub usage { + say "Usage: $0 [--list] [--search <string>] [--categories <movies|tv>]"; + say "\t--list\t\t\tlists last added torrents sorted by seeds."; + say + "\t--search <string>\tsearches for <string> and returns sorted by seeds"; + say + "\t--category [movies|tv]\tuses those categories (defaults to movies)"; + exit 1; +} + +my $tapi = Rarbg::torrentapi->new(); +my $counter = 0; +my $search = ""; +my $list; +my $result; +my $category = 'movies'; + +GetOptions( + "search=s" => \$search, + "list" => \$list, + "category=s" => \$category +) or usage(); + +if ($search) { + $result = $tapi->search( + { sort => 'seeders', + limit => 20, + category => $category, + search_string => $search + } + ); +} +elsif ($list) { + $result = $tapi->list( + { sort => 'seeders', + limit => 20, + category => $category + } + ); +} +else { + usage(); +} + +if (ref($result) eq 'ARRAY') { + foreach my $t ( @{$result} ) { + printf( + "%d -> %s (%.2f GB # %d seeds)\n", + $counter, $t->title, $t->size / 1073741824, + $t->seeders + ); + $counter++; + } +} elsif (ref($result) eq 'Rarbg::torrentapi::Error') { + die "[*] We got an error: $result->{error}"; +} else { + die "[*] Unexpected Error"; +} + +print "Which one? (Ctrl+C to quit) "; +my $selection = <STDIN>; +chomp $selection; + +if ( $selection =~ m/\d{1,2}/ ) { + say "[*] You selected: " . $result->[$selection]->title; + say " [-] sending magnet to transmission:\n" . $result->[$selection]->download; + my $magnet = $result->[$selection]->download; + `transmission-remote 10.42.10.55 --authenv -a $magnet`; +} +else { + die "selection is not a number!"; +}