-
Notifications
You must be signed in to change notification settings - Fork 0
/
test
154 lines (133 loc) · 4.12 KB
/
test
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
142
143
144
145
146
147
148
149
150
151
152
153
154
#!/bin/bash
# This file is part of Sintel.
#
# Sintel is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Sintel is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Sintel. If not, see <https://www.gnu.org/licenses/>.
#
#
#Funciones de prueba
function testDetectar() {
local ubicacion="$1"
}
function test.detectar() {
local folder="/home/mhyst/Extra/Peliculas"
#local re='[0-9]{1,2}x[0-9]{1,3}'
local te=""
local temporada=""
local episodio=""
local titulo=""
local fichero=""
local torrent=""
local aux=""
local id=""
local epid=""
if [ ! -d "$folder" ]; then
echo "El directorio >$folder< no existe"
exit
fi
cd "$folder"
find * -name '*.avi' -o -name '*.mp4' -o -name '*.mkv' -type f | sort > /tmp/films.txt
readarray -t datosa < /tmp/films.txt
for medio in "${datosa[@]}"; do
#aux=`sed "s/'/\'/g" <<< $medio`
fichero="$folder$medio"
te=$(medios.extractTe "$medio")
if [[ "$te" != "" ]]; then
titulo=$(medios.getTituloSerie "$medio")
echo "Serie: $titulo"
#Es una serie tenemos que crear la serie si no existe y crear el episodio correspondiente
#Extraemos el episodio y la temporada que es
IFS='x' read -a aux <<< "$te"; IFS=" "
temporada="${aux[0]}"
episodio="${aux[1]}"
if [[ "$temporada" == "" ]] || [[ "$episodio" == "" ]]; then
echo "ERROR: No se pudo obtener te2 en >$medio<"; continue;
else
echo "Temporada: $temporada, Episodio: $episodio"
fi
#id=$(series.getIdByTitulo "$titulo")
# if [[ "$id" == "" ]]; then
# #No existe, la creamos
# series.add "$titulo" "null" "-1"
# id="$ROWID"
# fi
$DEBUG && echo "Comprobando si el episodio existe"
#epid=$(series.getEpisodioId "$id" "$temporada" "$episodio")
$DEBUG && echo "Comprobado $epid"
# if [[ "$epid" == "" ]]; then
# $DEBUG && echo "Intentando insertar episodio..."
# #Puesto que ya existe, añadimos el episodio
# series.addEpisodio "$id" "$temporada" "$episodio" "$fichero" "-1"
# $DEBUG && echo "Intentado!"
# else
# echo "Ep episodio ya está en la base de datos."
# fi
else
#Si es una película, simplemente añadimos la película
titulo=$(medios.getTituloPelicula "$medio")
echo "Pelicula: $titulo"
# id=$(film.getByTitulo "$titulo")
# if [[ "$id" == "" ]]; then
# #No existe, la creamos
# film.add "$titulo" "$fichero" "-1"
# id="$ROWID"
# else
# echo "La película ya existe en la base de datos"
# fi
fi
done
}
function test.getTituloSerie() {
local medio="La casa de la pradera 1of01 [www.DiVXTotal.net] (dvdscreener) DIVX [HdTV] XViD xViD"
#echo "$(medios.fixTitulo $medio)"
echo "$(medios.getTituloSerie "$medio")"
#echo $(medios.extractTe "$medio")
}
function test.extractTe() {
local medio="La casa de la pradera 1x01 [www.DiVXTotal.net] (dvdscreener) DIVX [HdTV] XViD xViD"
#echo "$(medios.fixTitulo $medio)"
#echo "$(medios.getTituloSerie "$medio")"
echo $(medios.extractTe "$medio")
}
function testCheckArgs() {
#local res=$(checkArgs 2 $@)
checkArgs 2 $@
[[ $? != 0 ]] && exit 1
if $res; then
echo "Los argumentos son correctos"
echo "Args: $@"
else
echo "Error: Los argumentos no son correctos"
fi
}
function args() {
echo "N. Args: $#"
if [[ $# != 4 ]]; then
echo "Error: el número de argumentos deberían ser 4" > /dev/tty
echo "Stack trace:"
for func in "${FUNCNAME[@]}"; do
echo " $func"
done
fi
}
function testAnimeAdd() {
anime.add "titulo"
}
function testMakeArray() {
local busqueda="$@"
local datos=$(db.executeQuery "select * from medio where esserie=0 and esvisto = 0 and titulo like \"%$busqueda%\"")
echo "$datos"
IFS=$'\n'
readarray -t datosa <<< "$datos"
echo "${datosa[0]}"
}