/
makequotes.sh
executable file
·67 lines (51 loc) · 1.6 KB
/
makequotes.sh
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
#!/usr/bin/env bash
#
# __author__ = 'Lilian BESSON'
# __email__ = 'Lilian.BESSON[AT]ens-cachan[DOT]fr'
# __date__ = '31-08-2013'
#
# A first try to automatically create a quotes.txt with all Kaamelott citations
# from https://fr.wikiquote.org/wiki/*
#
# Find the more recent version here
# http://perso.crans.org/besson/bin/quotes.sh
#
version='0.1'
# en -> https://en.wikiquote.org/wiki/
# LANG='en'
# fr -> https://fr.wikiquote.org/wiki/
LANG='fr'
# If possible, use .color.sh (http://perso.crans.org/besson/bin/.color.sh)
[ -f ~/.color.sh ] && . ~/.color.sh
#
# Starting....
#
echo -e "${yellow}.: Lilian Besson presents :.$white$reset"
echo -e "Automatic quotes.txt generator, v${version}.$white$reset"
output="quotes.txt"
[ -f "$output" ] && ( echo -e "File $output already there, moving to /tmp/"; mv "$output" "/tmp/quotes_`date \"+%d_%M__%H_%m_%S\"`.txt" )
# One target
target="$1"
tg="/tmp/$target.html"
wget "https://fr.wikiquote.org/wiki/$target" -O "$tg"
# All sub targets
subtargets=`grep recueil "$tg" | grep -o "$target"[^\ ]*\" | uniq | sed s/\"//`
echo -e "The target $target gave these sub targets:"
echo -e "$subtargets"
echo pause
read
#for l in Kaamelott Kaamelott/Arthur Kaamelott/Loth Kaamelott/Gauvain Kaamelott/Kadoc
for l in "$target" $subtargets
do
echo -e "For file $l..."
# for i in `seq 1 1000`; do
# out="/tmp/quote_${l//'/'/'_'}_${i}.txt"
out="/tmp/quote_${l//'/'/_}_${i}.txt"
quotes.sh -o "$out" -q -a "$l"
# quotes.sh -o /tmp/quote_$l_$i.txt -q -n $i "$l" >/dev/null \
# || break
cat "$out" | sed s/@/\n/ >> "$output"
cat "$out" >> "$output"
wc "$output"
# done
done