Files
repos_scripts/tor-cli
2024-06-02 20:06:46 +05:30

13 lines
591 B
Bash
Executable File

#!/bin/sh
os="linux"
uname -o | grep -q "ndroid" && os="droid"
# shellcheck disable=SC1091,SC1090
. "$(dirname "$0")"/.functions
[ -z "$*" ] && search_$os "Search Torrent: " || query=$*
[ -z "$query" ] && exit 0
query=$(printf "%s" "$query" | tr ' ' '+')
magnet=$(curl -s "https://thepiratebay0.org/s/?page=0&orderby=0&q=$query" | tr '\n' ' ' | sed -e 's_<div_\n_g;s_</tr>_\n_g;s_&nbsp\;__g' | sed -nE 's_.*title.*">([^<]*).*a href="(magnet[^"]*)".*Size ([^,]*).*">([^<]*)<.*<.*_\[size:\3,se:\4\]\t\1\t\2_p' | fzf -d'\t' --with-nth ..2 | cut -f3)
[ -z "$magnet" ] || torrent_$os "$magnet"