summaryrefslogtreecommitdiff
path: root/share/tsh/1337x.sh
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/tsh/1337x.sh
parent18d5762e0d89af0aff03945c691cbd16fd231ee1 (diff)
checkpoint
Diffstat (limited to 'share/tsh/1337x.sh')
-rwxr-xr-xshare/tsh/1337x.sh41
1 files changed, 41 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"
+}