add new script tor-bay

This commit is contained in:
CoolnsX
2022-05-10 20:25:46 +05:30
parent b44828f158
commit 2227568da1
2 changed files with 28 additions and 13 deletions

16
rss
View File

@@ -1,19 +1,9 @@
#!/bin/sh #!/bin/sh
#script for downloading latest anime episode via torrent using rss provided by website named "subsplease.org" tmp=$(notify-send -t 2000 "Parsing SubsPlease RSS... Please Wait..." -p)
#parsing rss file
notify-send -t 2000 "Parsing SubsPlease RSS... Please Wait..."
data=$(curl -s "https://subsplease.org/rss/?r=1080" | tr "<|>" "\n") data=$(curl -s "https://subsplease.org/rss/?r=1080" | tr "<|>" "\n")
#extracting names and providing the menu for selecting particular title
name=$(printf "%s" "$data" | sed -nE 's/^\[.*Please\] (.*)/\1/p' | dmenu -l 25 -p "Search anime:") name=$(printf "%s" "$data" | sed -nE 's/^\[.*Please\] (.*)/\1/p' | dmenu -l 25 -p "Search anime:")
[ -z "$name" ] && notify-send -u critical "Err.. Query empty" && exit 0 [ -z "$name" ] && notify-send -u critical "Err.. Query empty" -r $tmp && exit 0
#extracting id from anime_name_[id].mkv
id=$(printf "$name" | sed -n -e 's/.*\[\(.*\)\].*/\1/p') id=$(printf "$name" | sed -n -e 's/.*\[\(.*\)\].*/\1/p')
#finding the magnet link containing the exact pattern
magnet=$(printf "%s" "$data" | grep "$id%" | sed 's/amp;//g') magnet=$(printf "%s" "$data" | grep "$id%" | sed 's/amp;//g')
setsid -f st -e $HOME/repos_scripts/torrent "$magnet"
#custom script for downloading torrent using aria2c.. you can use your own bittorrent client here
st -e $HOME/repos_scripts/torrent "$magnet" &

25
tor-bay Executable file
View File

@@ -0,0 +1,25 @@
#!/bin/sh
#this script uses the piratesbay api to search for torrents
cal_size() {
printf "%.03f\n" "$(($1/1000))e-6"
}
display() {
for i in $(seq $(printf "%s\nlol" "$2" | wc -l));do
printf "[%s GB;S:%s\n" "$(cal_size "$(printf "%s" "$1" | sed -n "${i}p")")" "$(printf "%s" "$2" | sed -n "${i}p")" & done
wait
}
[ -z "$*" ] && printf "Search torrent:" && query=$(printf "" | dmenu -p "Search torrent: ") || query=$*
[ -z "$query" ] && exit 0
tmp=$(notify-send "Searching query" -p)
query=$(printf "%s" "$query" | tr " " "+")
data=$(curl -s "https://apibay.org/q.php?q=$query" | sed 's/},/}\n/g' | tr -d "[|]")
notify-send "tidying up data" -r $tmp
size=$(printf "%s" "$data" | sed -nE 's/.*name.*size":"(.*)",.*user.*/\1/p')
name_seed=$(printf "%s" "$data" | sed -nE 's/.*name":"(.*)","info_hash.*seeders":"(.*)",.*num.*/\2] \1/p')
sel=$(display "$size" "$name_seed" | dmenu -l 25 -p "select torrent >" | cut -d" " -f3-)
[ -z "$sel" ] && notify-send -u critical "No Torrent Selected" -r $tmp && exit 0 || notify-send "Selected $sel" -r $tmp
magnet="magnet:?xt=urn:btih:$(printf "%s" "$data" | sed -nE 's/.*name":"(.*)","info_hash":"(.*)",.*leech.*/\2\t\1/p' | sed -n "s/\t$sel//p")"
setsid -f st -e $HOME/repos_scripts/torrent "$magnet"