diff options
Diffstat (limited to 'nocompile/bin')
-rwxr-xr-x | nocompile/bin/tpb.sh | 56 |
1 files changed, 34 insertions, 22 deletions
diff --git a/nocompile/bin/tpb.sh b/nocompile/bin/tpb.sh index 7162b21..10ab6e0 100755 --- a/nocompile/bin/tpb.sh +++ b/nocompile/bin/tpb.sh @@ -1,15 +1,31 @@ -#!/bin/sh +#!/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 - echo usage: tpb.sh search_term [category] [limit] - echo "categories:" - echo "0 = any" - echo "100 = audio" - echo "200 = video" - echo "300 = applications" - echo "400 = games" - echo "500 = porn" - + printf "usage: tpb.sh query\n" + exit 1 else if [ "_$2" = "_" ];then cat=0 @@ -21,16 +37,12 @@ else else lim="$3" fi -#last number: -#0 = any -#100 = audio -#200 = video -#300 = applications -#400 = games -#500 = porn - wget -qO- 'https://thepiratebay.se/search/'"$1"'/0/99/'"$cat" \ - | tr '"' "\n" \ - | grep ^magnet \ - | decode_html_entities \ - | head -n "$lim" + 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 |