env/bin/nyaasearch.pl

33 lines
815 B
Perl

#!/usr/bin/env perl
# nyaasearch
# Written in 2021 by Lucas
# CC0 1.0 Universal/Public domain - No rights reserved
#
# To the extent possible under law, the author(s) have dedicated all
# copyright and related and neighboring rights to this software to the
# public domain worldwide. This software is distributed without any
# warranty. You should have received a copy of the CC0 Public Domain
# Dedication along with this software. If not, see
# <http://creativecommons.org/publicdomain/zero/1.0/>.
use v5.14;
use strict;
use warnings;
my $progname = $0;
$progname =~ s@^.*/@@;
sub usage
{
say STDERR "Usage: $progname QUERY";
exit 1;
}
usage if @ARGV == 0;
my $s = join(" ", @ARGV);
$s =~ s/[^A-Za-z0-9\-\._~]/sprintf("%%%02X", ord($&))/eg;
$s =~ s/%20/+/g;
exec "w3m", "https://nyaa.si/?q=$s&f=0&c=0_0";