-- Leo's gemini proxy

-- Connecting to git.thebackupbox.net:1965...

-- Connected

-- Sending request

-- Meta line: 20 text/gemini

repo: misc
action: commit
revision:
path_from:
revision_from: 2782b0f10a4bbcf2cb8dcb96bccb00d41b5673dd:
path_to:
revision_to:

git.thebackupbox.net

misc

git://git.thebackupbox.net/misc

commit 2782b0f10a4bbcf2cb8dcb96bccb00d41b5673dd
Author: epoch <epoch@hack.thebackupbox.net>
Date:   Sat Sep 4 20:29:10 2021 +0000

    tpb.sh now uses data from json response of q.php instead of trying to scrape from html

diff --git a/nocompile/bin/tpb.sh b/nocompile/bin/tpb.sh

index 7162b21aacb291c29d21f1a598b157f184378010..

index ..10ab6e00bdeac1250595aade2b5bb72e58e33eaf 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

-----END OF PAGE-----

-- Response ended

-- Page fetched on Sun Jun 2 14:36:01 2024