diff --git a/.functions b/.functions index 9384fbb..3b60cb9 100644 --- a/.functions +++ b/.functions @@ -24,7 +24,7 @@ torrent_linux() { } torrent_droid() { - "$HOME/torrent" "$1" + "$HOME/.shortcuts/torrent" "$1" } info_droid() { diff --git a/tor-bay b/tor-bay index 973e624..e634ae0 100755 --- a/tor-bay +++ b/tor-bay @@ -28,7 +28,8 @@ esac [ -z "$query" ] && exit 0 [ "$os" = "linux" ] && 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 "[]") +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 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') diff --git a/torrent b/torrent index 6d3b8d7..8d672a1 100755 --- a/torrent +++ b/torrent @@ -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!!" } +magnet="$*" if [ "$(uname -o)" = "Android" ]; then os="droid" script_dir="$HOME/.shortcuts" + download_dir="/sdcard" + [ -z "$magnet" ] && magnet="$(termux-clipboard-get)" else os="linux" script_dir="$HOME/repos_scripts" + download_dir="Downloads" + [ -z "$magnet" ] && magnet="$(wl-paste)" fi +#import generic 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 -[ -z "$*" ] && magnet="$(wl-paste)" || 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_reset}\n\tenter choice:" @@ -35,7 +43,7 @@ case $ch in aria2c --dir=$HOME/.cache --bt-metadata-only=true --bt-save-metadata=true "$magnet" tput reset aria2c --show-files=true $HOME/.cache/*.torrent - printf "Enter file idx(default=all):" + info_$os "Enter file idx(default=all):" read -r ind down "$HOME/.cache/*.torrent" "$ind" rm -f $HOME/.cache/*.torrent