pay no attention to the man behind the curtain

This commit is contained in:
coolnsx
2023-12-19 22:00:54 +05:30
parent aef9524202
commit c5d862a75b
3 changed files with 13 additions and 4 deletions

View File

@@ -24,7 +24,7 @@ torrent_linux() {
} }
torrent_droid() { torrent_droid() {
"$HOME/torrent" "$1" "$HOME/.shortcuts/torrent" "$1"
} }
info_droid() { info_droid() {

View File

@@ -28,7 +28,8 @@ esac
[ -z "$query" ] && exit 0 [ -z "$query" ] && exit 0
[ "$os" = "linux" ] && tmp=$(notify-send "Searching query" -p) [ "$os" = "linux" ] && tmp=$(notify-send "Searching query" -p)
query=$(printf "%s" "$query" | tr " " "+") query=$(printf "%s" "$query" | tr " " "+")
data=$(curl -s "https://apibay.org/q.php?q=$query" | sed 's/},/}\n/g' | tr -d "[]") data=$(curl -s "https://apibay.org/q.php?q=$query" | tee data | sed 's/},/}\n/g' | tr -d "[]")
[ "$os" = "linux" ] && notify-send "tidying up data" -r $tmp [ "$os" = "linux" ] && notify-send "tidying up data" -r $tmp
size=$(printf "%s" "$data" | sed -nE 's/.*name.*size":"(.*)",.*user.*/\1/p') 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') name_seed=$(printf "%s" "$data" | sed -nE 's/.*name":"(.*)","info_hash.*seeders":"(.*)",.*num.*/\2] \1/p')

12
torrent
View File

@@ -12,17 +12,25 @@ down() {
aria2c --file-allocation=trunc -d Softwares --select-file=$2 --seed-time=0 $1 && info_$os "Torrent: Download complete" && rm -f $file || error_$os "Torrent: Error!!" aria2c --file-allocation=trunc -d Softwares --select-file=$2 --seed-time=0 $1 && info_$os "Torrent: Download complete" && rm -f $file || error_$os "Torrent: Error!!"
} }
magnet="$*"
if [ "$(uname -o)" = "Android" ]; then if [ "$(uname -o)" = "Android" ]; then
os="droid" os="droid"
script_dir="$HOME/.shortcuts" script_dir="$HOME/.shortcuts"
download_dir="/sdcard"
[ -z "$magnet" ] && magnet="$(termux-clipboard-get)"
else else
os="linux" os="linux"
script_dir="$HOME/repos_scripts" script_dir="$HOME/repos_scripts"
download_dir="Downloads"
[ -z "$magnet" ] && magnet="$(wl-paste)"
fi fi
#import generic functions
. $script_dir/.functions . $script_dir/.functions
#check if the url is magnet
! printf "%s" "$magnet" | grep -q "magnet:" && error_$os "Not a valid magnet link!" && exit 0
trap "rm -f $HOME/.cache/*.torrent;exit 0" INT HUP trap "rm -f $HOME/.cache/*.torrent;exit 0" INT HUP
[ -z "$*" ] && magnet="$(wl-paste)" || magnet="$*"
echo "$magnet" echo "$magnet"
printf "${c_yellow}Download>>\n${c_green}[f]ull torrent\n${c_cyan}[p]artial torrent \n${c_red}[q]uit" printf "${c_yellow}Download>>\n${c_green}[f]ull torrent\n${c_cyan}[p]artial torrent \n${c_red}[q]uit"
printf "${c_reset}\n\tenter choice:" printf "${c_reset}\n\tenter choice:"
@@ -35,7 +43,7 @@ case $ch in
aria2c --dir=$HOME/.cache --bt-metadata-only=true --bt-save-metadata=true "$magnet" aria2c --dir=$HOME/.cache --bt-metadata-only=true --bt-save-metadata=true "$magnet"
tput reset tput reset
aria2c --show-files=true $HOME/.cache/*.torrent aria2c --show-files=true $HOME/.cache/*.torrent
printf "Enter file idx(default=all):" info_$os "Enter file idx(default=all):"
read -r ind read -r ind
down "$HOME/.cache/*.torrent" "$ind" down "$HOME/.cache/*.torrent" "$ind"
rm -f $HOME/.cache/*.torrent rm -f $HOME/.cache/*.torrent