blob: 10ab6e00bdeac1250595aade2b5bb72e58e33eaf (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
#!/usr/bin/env bash
### translated from the javascript that tpb uses
encodeURIComponent() {
uriescape "$1" | html_entities_encode
}
print_trackers() {
printf '&tr=%s' $(encodeURIComponent 'udp://tracker.coppersurfer.tk:6969/announce')
printf '&tr=%s' $(encodeURIComponent 'udp://tracker.openbittorrent.com:6969/announce')
printf '&tr=%s' $(encodeURIComponent 'udp://tracker.opentrackr.org:1337')
printf '&tr=%s' $(encodeURIComponent 'udp://tracker.leechers-paradise.org:6969/announce')
printf '&tr=%s' $(encodeURIComponent 'udp://tracker.dler.org:6969/announce')
printf '&tr=%s' $(encodeURIComponent 'udp://opentracker.i2p.rocks:6969/announce')
printf '&tr=%s' $(encodeURIComponent 'udp://47.ip-51-68-199.eu:6969/announce')
}
print_magnet() {
ih=$1
shift
name="$*"
printf 'magnet:?xt=urn:btih:%s&dn=%s%s\n' "${ih}" "$(encodeURIComponent "${name}")" "$(print_trackers)"
}
#get magnets based on search. easy. :P
if [ "_$1" = "_" ];then
printf "usage: tpb.sh query\n"
exit 1
else
if [ "_$2" = "_" ];then
cat=0
else
cat="$2"
fi
if [ "_$3" = "_" ];then
lim=5
else
lim="$3"
fi
wget -qO- "http://piratebayztemzmv.onion/q.php?q=${1}&cat=0" \
| jq -r '.[] | .info_hash, .name' | paste - - | while read line;do
print_magnet $line
done
# | tr '"' "\n" \
# | grep ^magnet \
# | html_entities_decode \
# | head -n "$lim"
fi
|