This repository has been archived by the owner on Sep 11, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtlt
executable file
·118 lines (110 loc) · 3.53 KB
/
tlt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#!/bin/sh
# by Dominik Stanisław Suchora <suchora.dominik7@gmail.com>
# License: GNU GPLv3
SORT='' #name
PAGE=1
SEARCH=""
DOMAIN="https://www.limetorrents.lol/"
DELIM="\t"
C_LE="31"
C_SE="32"
C_SIZE="33"
C_HEALTH="35"
C_TIME="36"
C_NAME="39"
COLOR=1
alias ucurl='curl -H "User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) QtWebEngine/5.15.2 Chrome/87.0.4280.144 Safari/537.36" -H "Accept-Encoding: gzip, deflate" --compressed'
while [ $# -gt 0 ]
do
case "$1" in
-s|--sort)
case "$2" in
name) SORT='';;
size) SORT='size';;
time) SORT='time';;
se) SORT='seeds';;
le) SORT='leechs';;
esac
shift 2;;
-h|--help)
NAME="$(basename "$0")"
printf "%s [OPTION]... [PATTERN]\nSearch for PATTERN in lt.\nExample: %s -s size -p 2 'archlinux'\n\n" "$NAME" "$NAME"
printf "Options:\n -s, --sort TYPE\t\tsort using TYPE that can be: name, size, time, se, le\n"
printf " -d, --domain DOMAIN\t\tset domain to DOMAIN\n"
printf " -D, --delimiter DELIM\tset delimiter to DELIM\n"
printf " -p, --page NUM\t\tshow page at NUM\n"
printf " -c, --color\t\t\tcolor output\n"
printf " -C, --no-color\t\tdisable coloring of output\n"
printf " -h, --help\t\t\tshow help\n"
printf "\nMagnet link will be copied via xclip.\n"
exit 0;;
-c|--color)
COLOR=1
shift;;
-C|--no-color)
COLOR=0
shift;;
-d|--domain)
DOMAIN="$2"
shift 2;;
-p|--page)
PAGE="$2"
shift 2;;
-D|--delimiter)
DELIM="$2"
shift 2;;
*)
if [ -z "$SEARCH" ]
then
SEARCH="$1"
else
SEARCH="$SEARCH $1"
fi
shift;;
esac
done
SEARCHP=$(echo "$SEARCH" | tr ' .+/_:;' '-')
t1="$(ucurl -g -L -s "$DOMAIN/search/all/$SEARCHP/$SORT/$PAGE/" | hgrep 'table +class="table2"; td')"
t2="$(echo "$t1" | hgrep 'td +class="tdnormal" @p"%i\n"')"
links="$(echo "$t1" | hgrep 'td +class="tdleft"; a +href=".*\.html" @p"'$DOMAIN'/%(href)a\n"')"
{
echo "$t1" | hgrep 'td +class="tdleft"; a +href=".*\.html" @p"%i\n"' #name
echo "$t2" | sed '/ - /!d; s/ - .*//' #time
echo "$t2" | grep -v ' - ' #size
echo "$t1" | hgrep 'td +class="tdseed" @p"%i\n"' #se
echo "$t1" | hgrep 'td +class="tdleech" @p"%i\n"' #le
echo "$t1" | hgrep 'td +class="tdright"; div @p"%(class)a\n"' #health
} | awk 'function print_fields(lines,fields,step) {
colors[0] = '"$C_NAME"'
colors[1] = '"$C_TIME"'
colors[2] = '"$C_SIZE"'
colors[3] = '"$C_SE"'
colors[4] = '"$C_LE"'
colors[5] = '"$C_HEALTH"'
ORS = ""
for (i = 0; i < step; i++) {
for (j = 0; j < fields; j++) {
if (j != 0)
print "'"$DELIM"'"
if ('"$COLOR"')
print "\033["colors[j]"m"lines[(step*j)+i]"\033[0m"
else
print lines[(step*j)+i]
}
printf "\n"
}
}
BEGIN { l=0; fields = 6 }
{ lines[l++]=$0 }
END {
if (l >= fields)
if (l%fields == 0) {
step = l/fields
print_fields(lines,fields,step)
} else
print "length of some data fields does not match the others"
}' | nl
[ -z "$links" ] && exit 1
printf 'num> '
read -r NUMBER
[ "$NUMBER" -gt 0 ] && ucurl -L -g -s "$(echo "$links" | sed "s/ /%20/g; ${NUMBER}q;d")" | grep -oE -m 1 'magnet:\?[^"]+' | tee /dev/stderr | tr -d '\n' | xclip -sel clip