download to dir, add webtorrent as default
This commit is contained in:
parent
124e1f7328
commit
0b25e074e3
22
nyaa
22
nyaa
@ -3,14 +3,17 @@
|
|||||||
mkdir -p "${XDG_CACHE_HOME:-'$HOME/.cache'}/nyaa"
|
mkdir -p "${XDG_CACHE_HOME:-'$HOME/.cache'}/nyaa"
|
||||||
temp="${XDG_CACHE_HOME:-'$HOME/.cache'}/nyaa"
|
temp="${XDG_CACHE_HOME:-'$HOME/.cache'}/nyaa"
|
||||||
url="https://nyaa.si"
|
url="https://nyaa.si"
|
||||||
|
dir=${NYAA_DIR:-"$HOME/Downloads"}
|
||||||
|
filter=1
|
||||||
|
|
||||||
trap "rm -rf $temp" SIGINT SIGTERM ERR EXIT
|
trap "rm -rf $temp" SIGINT SIGTERM ERR EXIT
|
||||||
filter=2
|
|
||||||
|
|
||||||
while getopts q:ad flag; do
|
while getopts axd:q: flag; do
|
||||||
case "${flag}" in
|
case "${flag}" in
|
||||||
q) query=${OPTARG};;
|
|
||||||
a) filter=0;;
|
a) filter=0;;
|
||||||
|
x) url="https://sukebei.nyaa.si";;
|
||||||
|
d) dir=${OPTARG};;
|
||||||
|
q) query=${OPTARG};;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
@ -22,7 +25,7 @@ if [ -z "$query" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
query="$(echo $query | sed 's/ /+/g')"
|
query="$(echo $query | sed 's/ /+/g')"
|
||||||
curl -s "$url/?f=$filter&q=$query" > $temp/html
|
curl -s "$url/?s=seeders&f=$filter&q=$query" > $temp/html
|
||||||
|
|
||||||
grep -o '<a href="/view/.*</a>' $temp/html | sed 's/<[^>]*>//g' > $temp/titles
|
grep -o '<a href="/view/.*</a>' $temp/html | sed 's/<[^>]*>//g' > $temp/titles
|
||||||
|
|
||||||
@ -40,7 +43,14 @@ if [ -z "$magnet" ]; then
|
|||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
mkdir -p $HOME/Downloads
|
mkdir -p $dir
|
||||||
aria2c "$magnet" --seed-time 0 -d $HOME/Downloads
|
|
||||||
|
if command -v webtorrent 2> /dev/null
|
||||||
|
then
|
||||||
|
webtorrent "$magnet" -o $dir
|
||||||
|
else
|
||||||
|
aria2c "$magnet" --seed-time 0 -d $dir
|
||||||
|
fi
|
||||||
|
|
||||||
echo Enjoy watching!
|
echo Enjoy watching!
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user