-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwin_aniscraping
125 lines (92 loc) · 2.8 KB
/
win_aniscraping
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
#!/bin/bash
# aniscraping
# script created by IamJony.
# My github https://github.com/IamJony
# Set color
#
White='\e[0;37m'
Black='\e[0;30m'
Green='\e[0;32m'
Yellow='\e[0;33m'
Blue='\e[0;34m'
Red='\e[0;31m'
Purple='\e[0;35m'
Cyan='\e[0;36m'
BBlack='\e[1;30m' # Black
BRed='\e[1;31m' # Red
BGreen='\e[1;32m' # Green
BYellow='\e[1;33m' # Yellow
BBlue='\e[1;34m' # Blue
BPurple='\e[1;35m' # Purple
BCyan='\e[1;36m' # Cyan
BWhite='\e[1;37m' # White
# Web page
nyaa='https://nyaa.si/?q='
frozen='https://www.frozen-layer.com/buscar/descargas/'
# Player
player='dlna'
# Directory
dir="$HOME/.anime"
mkdir $dir/ 2>/dev/null &
rm $dir/.html* 2>/dev/null &
# function scraping nyya
scraping() {
# nyaa
title_anime_nyaa=$(cat $dir/.html_anime | sed -n '/comment/!{/<a[^>]*href="[^"]*\/view\/[^"]*"[^>]*>/s/.*title="\([^"]*\)".*/\1/p;}' > $dir/.title_anime)
link_anime=$(cat $dir/.html_anime | sed -n 's/.*\(\/download\/[0-9]*\.torrent\).*/https:\/\/nyaa.si\1/p' > $dir/.link_anime)
# frozen
title_anime_frozen=$(cat $dir/.html_anime_frozen | sed -n '/<td class='"'"'tit'"'"'>/{:start /<\/td>/!{N;b start};/<a/{s/.*<a[^>]*>\([^<]*\)<\/a>.*/\1/;p}}' >> $dir/.title_anime)
link_anime_frozen=$(cat $dir/.html_anime_frozen | sed -n "s/.*<a data-skip-pjax='true' href='\(\/descargas\/[^']*\)' title='descargar torrent'>/https:\/\/www.frozen-layer.com\1/p" >> $dir/.link_anime)
file1="$dir/.title_anime"
file2="$dir/.link_anime"
#Contador
line_num=1
# Leer el archivo y guardar cada línea en un array
if [ ! -s $dir/.title_anime ]; then
echo -e $BRed'no se encontraron resultados'
sleep 2
clear
start
fi
readarray -t LINES < $dir/.title_anime
# Imprimir el menú
echo -e $White''
for i in "${!LINES[@]}"; do
printf "%02d. %s\n" "$i" "${LINES[$i]}"
echo -e ''
done
# Leer la selección del usuario
echo -e ""
echo -e $BRed 's = search || q = exit'
echo -e ""
echo -e $BYellow'Plase, choose an option'
read -p "Opción: " OPTION
# Validar la selección del usuario
if [[ "$OPTION" =~ ^[0-9]+$ && "$OPTION" -ge 0 && "$OPTION" -lt "${#LINES[@]}" ]]; then
rm $dir/*.torrent
echo "Ha seleccionado la opción $OPTION: ${LINES[$OPTION]}"
ANOTHER_FILE_LINE=$(sed -n "$((OPTION+1))p" $dir/.link_anime)
wget -P $dir $ANOTHER_FILE_LINE
webtorrent $dir/*.torrent --$player
elif [[ $OPTION == "q" || $OPTION == "Q" ]]; then
exit 0
elif [[ $OPTION == "s" || $OPTION == "S" ]]; then
clear
rm $dir/.html* 2>/dev/null &
start
else
echo -e $BRed'Selecion invalida'
sleep 2
scraping
fi
}
start() {
echo -e $BYellow''
read -p "Please , insert name of anime: " input &&
echo -e $White''
input=${input// /+}
curl -s "$nyaa""$input" >> $dir/.html_anime
curl -s "$frozen""$input" >> $dir/.html_anime_frozen
scraping
}
start