summaryrefslogtreecommitdiff
path: root/share/tsh/torrentgalaxy.sh
blob: 9d13cc95257196b4077b756c085b72e887cd66b8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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"
}