-
Notifications
You must be signed in to change notification settings - Fork 0
/
_curlpkgsorg
141 lines (121 loc) · 2.98 KB
/
_curlpkgsorg
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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
#!/bin/sh
mostrar_n(){
if [[ "$2" == "ev" ]];then
eval "$1"
else
printf "$1" && printf "\012"
fi
}
mostrar(){
printf "$1"
}
cantidad_lineas(){
if [[ "$(printf "%s" "$1" | wc -w)" == "0" ]];then
devuelve="0"
else
devuelve="$(($(printf "%s" "$1" | wc -l)+1))"
fi
mostrar "$devuelve"
}
seleccionar(){
mostrar "$1" | head -n "$2" | tail -n 1
}
subcaracter(){
mostrar "$1" | cut -c "$2"
}
cambiar_numero_por_letra(){
[[ "$(mostrar 0123456789|grep $1)" == "" ]] &&
mostrar "$1" ||
mostrar "pqwertyuio" | cut -c "$(($1+1))"
}
cambiar_letra_por_numero(){
[[ "$(mostrar pqwertyuio|grep $1)" == "" ]] &&
mostrar "$1" ||
mostrar "$(($(mostrar "oiuytrewqp" | grep -o "$1.*" | wc -c)-2))"
}
leer_y_cambiar(){
c=""
c2=""
while [[ "$c2" != $'\n' ]];do
if [[ "$c2" != "" ]];then
if [ "$c2" == $'\177' ]; then
c="$(mostrar "$c" | sed "s/.$//")"
mostrar "\b \b"
else
c3="$(cambiar_letra_por_numero "$c2")"
c="$c$c3"
mostrar "$c3"
fi
fi
read -s -rN 1 c2
done
mostrar_n "\r$c"
}
filtrar_distros(){
mostrar_n "$1" | grep $2 $(seleccionar "$3" "$4").pkgs.org
}
priult(){
mostrar_n "$1" | $2 -n 1 | cut -d "/" -f 3
}
mostrar_n "$@"
h="User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:55.0) Gecko/20100101 \
Goanna/4.0 Firefox/55.0 Basilisk/20180202"
i="curl -L -H \"$h\" \"https://pkgs.org/search/?q=$1\""
a="$(eval "$i")"
j="$(mostrar "slackware debian" | tr " " "\n")"
if [[ "$a" == "" ]];then
mostrar_n "Error de internet"
exit
fi
err403="<title>Error 403: Forbidden</title>"
if [[ "$(mostrar_n "$a" | grep "$err403")" != "" ]];then
mostrar_n "Error 403"
exit
fi
err301="Moved Permanently"
if [[ "$(mostrar_n "$a" | grep "$err301")" != "" ]];then
mostrar_n "Error 301"
exit
fi
b="$(mostrar_n "$a" | grep -Pi "http.+html" | \
grep -Po '"http.*"' | sed 's/["]//g' \
| grep -vi arm64 | grep -vi aarch64 | grep -vi i686 | grep -vi i586
)"
b22="$(filtrar_distros "$b" "-v" "$j" 1 )"
b23="$(filtrar_distros "$b" " " "$j" 1 )"
if [[ "$2" == "no$(seleccionar "$j" 1)" && "$b22" != "" ]];then
b="$b22"
fi
if [[ "$2" == "$(seleccionar "$j" 1)" && "$b23" != "" ]];then
b="$b23"
fi
if [[ "$(priult "$b" head)" == "$(priult "$b" tail)" ]];then
b32="$(mostrar_n "$b" | grep -o "/[.a-z0-9]*")"
b4="$(seleccionar "$b32" 3)"
b5="$(seleccionar "$j" 1).pkgs.org"
b52="$(mostrar "$b" | grep "$b5")"
fi
if [[ "$b52" != "" ]];then
b="$b52"
fi
b6="$(cantidad_lineas "$b")"
if [[ "$b6" == "0" ]];then
mostrar_n "No hay para elegir."
elif [[ "$b6" == "1" ]];then
d="$b"
else
mostrar_n "$b" | grep -n ""
leer_y_cambiar # c
d="$(seleccionar "$b" "$c")"
fi
mostrar_n "URL elegida: $d"
e="$(curl -H "$h" "$d")"
f="$(echo "$e" | grep -Pi "td.*text-break.*http" | \
grep -Po 'http[^<]*' | tail -n 1)"
f2="$(mostrar_n "$f" | sed "s/^https:\/\//http:\/\//g")"
mostrar_n "Servidor oficial: "
mostrar "$f2"
g=$(basename $f)
mostrar_n "curl -L $f2 --output $g" ev
mostrar_n "$g"
mostrar_n "xdg-open $g" ev