summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorepoch <epoch@hack.thebackupbox.net>2021-09-04 20:29:10 +0000
committerepoch <epoch@hack.thebackupbox.net>2021-09-04 20:29:10 +0000
commit2782b0f10a4bbcf2cb8dcb96bccb00d41b5673dd (patch)
tree2f2ebdf73dc30adcce54a079d8a99cc7ec3a7139
parent8f570ffd199b54c05156108d7a3bcdeb203fb890 (diff)
downloadmisc-2782b0f10a4bbcf2cb8dcb96bccb00d41b5673dd.tar.gz
misc-2782b0f10a4bbcf2cb8dcb96bccb00d41b5673dd.zip
tpb.sh now uses data from json response of q.php instead of trying to scrape from htmlHEADmaster
-rwxr-xr-xnocompile/bin/tpb.sh56
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