-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtermux_aniscraping
118 lines (84 loc) · 2.75 KB
/
termux_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
#!/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'
# webtorrent directory
directory_webtorrent=$(whereis webtorrent | cut -d' ' -f2)
# Directory
dir="$HOME/.anime"
mkdir $dir/ 2>/dev/null &
rm $dir/.html* 2>/dev/null &
start() {
clear
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
}
# 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
# FZF
export FZF_DEFAULT_OPTS="--bind='ctrl-x:execute(exit 0)+abort'"
# 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
OPTIONS=()
for i in "${!LINES[@]}"; do
OPTIONS+=("$i ${LINES[$i]}")
done
# Ejecutar FZF y obtener la selección del usuario
OPTION=$(printf '%s\n' "${OPTIONS[@]}" | fzf | awk '{print $1}')
# 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 && "$directory_webtorrent" $HOME/.anime/*.torrent --$player
scraping
else
rm $dir/.html* 2>/dev/null &
start && scraping
fi
}
start
scraping