tidy it all up, bsd license

This commit is contained in:
2022-03-14 22:11:43 +01:00
parent 7d87d656d1
commit 6752359faa
3 changed files with 10 additions and 679 deletions

10
nyaa
View File

@ -1,16 +1,14 @@
#!/bin/bash
#!/usr/bin/env bash
mkdir -p "${XDG_CACHE_HOME:-'$HOME/.cache'}/nyaa"
temp="${XDG_CACHE_HOME:-'$HOME/.cache'}/nyaa"
url="https://nyaa.si"
dir=${NYAA_DIR:-"$HOME/Downloads"}
filter=1
url="https://nyaa.si"
trap "rm -rf $temp" SIGINT SIGTERM ERR EXIT
while getopts axd:q: flag; do
case "${flag}" in
a) filter=0;;
x) url="https://sukebei.nyaa.si";;
d) dir=${OPTARG};;
q) query=${OPTARG};;
@ -25,7 +23,7 @@ if [ -z "$query" ]; then
fi
query="$(echo $query | sed 's/ /+/g')"
curl -s "$url/?s=seeders&f=$filter&q=$query" > $temp/html
curl -s "$url/?s=seeders&q=$query" > $temp/html
grep -o '<a href="/view/.*</a>' $temp/html | sed 's/<[^>]*>//g' > $temp/titles
@ -49,7 +47,7 @@ if command -v webtorrent 2> /dev/null
then
webtorrent "$magnet" -o $dir
else
aria2c "$magnet" --seed-time 0 -d $dir
aria2c "$magnet" -d $dir
fi
echo Enjoy watching!