-
Notifications
You must be signed in to change notification settings - Fork 0
/
redscraper.sh
66 lines (54 loc) · 1.36 KB
/
redscraper.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
#!/usr/bin/env bash
#
# Start Script
#
# @contributors: Simone Lampacrescia [PamposDev] <simo.lampac@gmail.com> (https://pamposdev.com)
#
# @license: This code and contributions have 'MIT License'
#
# include config
. config.sh
main(){
# print base info
printf "${redscaper_start}\n"
# print user info
printUserInfo
# get redbubble items defined in user_config
for item in "${redbubble_items[@]}"
do
init_scraping $item
done
# delete cache folder if enable in config
[[ $delete_cache_dir = true ]] && rm -r $cache_dir || sleep 2s
# finish
printf "${red}DONE${default_color}"
}
init_scraping(){
local item=$1
echo -e "${l_magenta}Item: $item${default_color}"
# init item scraping
bash ./scraper.sh $item
# init item parsing
init_parsing $item
echo -e "${l_yellow}Delay: ${delay}s${default_color}"
sleep ${delay}s
echo ""
}
init_parsing(){
# scraped file name located in cache folder
scraping_file_name="${cache_dir}${scraper_file_prefix}${1}"
if [ -f $scraping_file_name ]
then
echo "$scraping_file_name ready for parsing"
bash ./parser.sh $scraping_file_name
else
echo "$scraping_file_name not exist"
fi
}
printUserInfo(){
printf "${l_magenta}RedBubble Author: ${redbubble_author}${default_color}\n"
printf "${l_magenta}RedBubble items:${default_color}\n"
printf "${l_magenta} - %s${default_color}\n" ${redbubble_items[@]}
printf "\n"
}
main