diff options
author | Raymaekers Luca <raymaekers.luca@gmail.com> | 2024-07-11 21:48:56 +0200 |
---|---|---|
committer | Raymaekers Luca <raymaekers.luca@gmail.com> | 2024-07-11 21:48:56 +0200 |
commit | a857f247d9a71b88a4f0dbcfa95e3679e8456e70 (patch) | |
tree | 846ddcd8117be1505a970e3638fc65d0ec954a2e /share/tsh/1337x.sh | |
parent | 75196520b3d6a0e60db1d03a64aaa0655cc4f202 (diff) | |
parent | 6251d6ba1054cd79387f0f88ce25d2f4bc8b78c4 (diff) |
Merge branch 'main' of debuc.com:dotfiles
Diffstat (limited to 'share/tsh/1337x.sh')
-rwxr-xr-x | share/tsh/1337x.sh | 41 |
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" +} |