summaryrefslogtreecommitdiff
path: root/share
diff options
context:
space:
mode:
authorRaymaekers Luca <raymaekers.luca@gmail.com>2024-07-11 20:42:56 +0200
committerRaymaekers Luca <raymaekers.luca@gmail.com>2024-07-11 20:42:56 +0200
commit2144e991b0334aac9def384e0430be20889f1b73 (patch)
treee24494dad6098a40c01532dfc59f865d7afe059b /share
parent18d5762e0d89af0aff03945c691cbd16fd231ee1 (diff)
checkpoint
Diffstat (limited to 'share')
-rwxr-xr-xshare/tsh/1337x.sh41
-rwxr-xr-xshare/tsh/nyaa.sh32
-rwxr-xr-xshare/tsh/rarbg.sh18
-rwxr-xr-xshare/tsh/rutracker.sh39
-rw-r--r--share/tsh/tgx.sh26
-rwxr-xr-xshare/tsh/torrentgalaxy.sh24
6 files changed, 180 insertions, 0 deletions
diff --git a/share/tsh/1337x.sh b/share/tsh/1337x.sh
new file mode 100755
index 0000000..630d269
--- /dev/null
+++ b/share/tsh/1337x.sh
@@ -0,0 +1,41 @@
+#!/bin/sh
+
+url="https://www.1337xx.to"
+# shellcheck disable=SC2154
+# (we expect the variables to be set)
+
+# $1: line number used to get link
+get_magnet() {
+ curl -s "$(sed -n "${1}p" "$links")" |
+ pup -p 'a attr{href}' | grep "^magnet:" | head -n 1
+}
+
+get_torrents() {
+ # Get the pages all in one html document
+ next="/search/$query/1/"
+ while [ "$next" ]; do
+ link="$url$next"
+ >&2 printf '%s\n' "$link"
+
+ # Get next link, but also append html
+ next="$(
+ curl -s "$link" |
+ tee -a "$html" |
+ pup -p 'div.pagination li:last-child a attr{href}'
+ )"
+ [ "$next" = 'javascript:void(0)' ] && break
+ done
+ # No results
+
+ # parse html pages and scrape relevant information in seperate files
+ pup -f "$html" -p 'td.seeds text{}' >"$seeds"
+ # No results
+ [ -s "$seeds" ] || return 1
+ pup -f "$html" -p 'td.size text{}' | tr -d ' ' >"$sizes"
+ pup -f "$html" -p 'td.name a:nth-child(2) text{}' >"$names"
+ pup -f "$html" -p 'td.name a:nth-child(2) attr{href}' |
+ awk "{print \"$url\" \$0}" >"$links"
+
+ # concatenating the 3 files into results file
+ paste "$sizes" "$seeds" "$names" >"$results"
+}
diff --git a/share/tsh/nyaa.sh b/share/tsh/nyaa.sh
new file mode 100755
index 0000000..259dabd
--- /dev/null
+++ b/share/tsh/nyaa.sh
@@ -0,0 +1,32 @@
+#!/bin/sh
+
+# shellcheck disable=SC2154
+# (we expect the variables to be set)
+
+# $1`: line number used to get link
+get_magnet() { sed -n "${1}p" "$links"; }
+
+get_torrents() {
+ base_url="https://nyaa.si"
+ page="/?q=$query&p=1"
+ i=0
+ while true; do
+ i=$((i + 1))
+ page="$(curl -s "$base_url$page" | tee -a "$html" | pup -p 'li.next a attr{href}')"
+ if [ -z "$page" ]; then
+ printf '%s.\n' "$i"
+ break
+ else
+ >&2 printf '%s ' "$i"
+ fi
+ done
+ # No results
+ [ "$i" -eq 0 ] && return 1
+
+ pup -f "$html" -p 'table.torrent-list tr td:nth-child(2) a:last-child attr{title}' >"$names"
+ pup -f "$html" -p 'table.torrent-list tr td:nth-child(3) a:last-child attr{href}' >"$links"
+ pup -f "$html" -p 'table.torrent-list tr td:nth-child(4) text{}' | tr -d ' ' >"$sizes"
+ pup -f "$html" -p 'table.torrent-list tr td:nth-child(6) text{}' >"$seeds"
+
+ paste "$sizes" "$seeds" "$names" >"$results"
+}
diff --git a/share/tsh/rarbg.sh b/share/tsh/rarbg.sh
new file mode 100755
index 0000000..abb58c8
--- /dev/null
+++ b/share/tsh/rarbg.sh
@@ -0,0 +1,18 @@
+#!/bin/sh
+
+url="https://www2.rarbggo.to"
+
+# $1: line number to get link
+get_magnet() { curl -s "$url/$(sed -n "${1}p" "$links")" | pup -p '#hvicwlo attr{href}'; }
+
+get_torrents() {
+ >&2 printf "$url/search/?search=$query"
+ curl -s "$url/search/?search=$query" >"$html"
+
+ row='table.tablelist2 > tbody > tr.table2ta > td.tlista'
+ pup -p "$row:nth-child(2) > a text{}" <"$html" >"$names"
+ pup -p "$row:nth-child(5) text{}" <"$html" | tr -d ' ' >"$sizes"
+ pup -p "$row:nth-child(6) > font text{}" <"$html" >"$seeds"
+ pup -p "$row:nth-child(2) > a attr{href}" <"$html" >"$links"
+ paste "$sizes" "$seeds" "$names" >"$results"
+}
diff --git a/share/tsh/rutracker.sh b/share/tsh/rutracker.sh
new file mode 100755
index 0000000..81a7663
--- /dev/null
+++ b/share/tsh/rutracker.sh
@@ -0,0 +1,39 @@
+#!/bin/sh
+# shellcheck disable=SC2154
+
+# $1: line number for link that will provide magnet link
+get_magnet() { curl -s "$(sed -n "${1}p" "$links")" | pup 'a.magnet-link attr{href}'; }
+
+get_torrents() {
+ cookies="$tmp"/cookies
+
+ username="$(pass show websites/rutracker.org | awk '/login:/ {print $2}')"
+ password="$(pass show websites/rutracker.org | head -n 1)"
+
+ curl -sL 'https://rutracker.org/forum/login.php' \
+ -X POST --data-raw "login_username=$username&login_password=$password&login=вход" \
+ -b "$cookies" --cookie-jar "$cookies" >"$html"
+
+ # Check if user was blocked by captcha
+ if pup 'img attr{src}' <"$html" | grep -q 'captcha'; then
+ cap_link="$(pup -f "$html" 'img attr{src}' | grep 'captcha')"
+ cap_code="$(pup -f "$html" 'input.reg-input attr{name}')"
+ cap_sid="$(pup -f "$html" 'input[name="cap_sid"] attr{value}')"
+
+ >&2 printf "cap_link: %s\n" "$cap_link"
+ >&2 printf 'code: '
+ code="$(head -n 1)"
+
+ curl -sL 'https://rutracker.org/forum/login.php' \
+ -X POST --data-raw "login_username=$username&login_password=$password&cap_sid=$cap_sid&$cap_code=$code&login=вход" \
+ --cookie-jar "$cookies" >/dev/null
+ fi
+
+ curl -b "$cookies" -s 'https://rutracker.org/forum/tracker.php' \
+ -X POST --data-raw "nm=$query" >"$html"
+ pup -p -f "$html" 'tr td:nth-child(4) a:first-child text{}' >"$names"
+ pup -f "$html" 'tr td:nth-child(6) a:first-child text{}' | awk '{print $1}' >"$sizes"
+ pup -f "$html" 'tr td:nth-child(7) b text{}' >"$seeds"
+ pup -f "$html" 'tr td:nth-child(4) a:first-child attr{href}' | sed 's#.*#https://rutracker.org/forum/&#' >"$links"
+ paste "$sizes" "$seeds" "$names" >"$results"
+}
diff --git a/share/tsh/tgx.sh b/share/tsh/tgx.sh
new file mode 100644
index 0000000..3b2f34f
--- /dev/null
+++ b/share/tsh/tgx.sh
@@ -0,0 +1,26 @@
+#!/bin/sh
+
+html="tmp.html"
+query="battleblock"
+
+url="https://torrentgalaxy.mx"
+
+curl "$url/galaxyfence.php?f&dropoff=%2Ftorrents.php%3Fsearch%3D$query" > "$html"
+
+captcha_url="$url/$(pup -p '#captcha attr{src}' < "$html")"
+
+if [ "$captcha_url" ]
+then
+ >&2 printf "> "
+ curl "$captcha_url" | imv -
+ captcha_value="$(head -n 1)"
+ >&2 printf "captcha_value: %s\n" "$captcha_value"
+
+ curl -v "$url/galaxyfence.php" \
+ --compressed \
+ -X POST \
+ --data-raw "dropoff=%2Ftorrents.php%3Fsearch%3D$query&captcha=$captcha_value" \
+ > result.html
+fi
+
+$BROWSER result.html
diff --git a/share/tsh/torrentgalaxy.sh b/share/tsh/torrentgalaxy.sh
new file mode 100755
index 0000000..9d13cc9
--- /dev/null
+++ b/share/tsh/torrentgalaxy.sh
@@ -0,0 +1,24 @@
+#!/bin/sh
+
+url="https://torrentgalaxy.to"
+# shellcheck disable=SC2154
+# (we expect the variables to be set)
+
+# $1: line number used to get link
+get_magnet() { sed -n "${1}p" "$links"; }
+
+get_torrents() {
+ next="/torrents.php?search=$query"
+ curl -s "$url$next" >"$html"
+
+ pup -f "$html" -p 'div.tgxtablerow > div:nth-child(11) > span > font:first-child text{}' >"$seeds"
+
+ # No results
+ [ -s "$seeds" ] || return 1
+
+ pup -f "$html" -p 'div.tgxtablerow > div:nth-child(8) > span text{}' | tr -d ' ' >"$sizes"
+ pup -f "$html" -p 'div.tgxtablerow > div:nth-child(4) > div > a attr{title}' >"$names"
+ pup -f "$html" -p 'div.tgxtablerow > div:nth-child(5) > a:nth-child(2) attr{href}' >"$links"
+
+ paste "$sizes" "$seeds" "$names" >"$results"
+}