-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfetch.sh
More file actions
executable file
·55 lines (49 loc) · 1.3 KB
/
Copy pathfetch.sh
File metadata and controls
executable file
·55 lines (49 loc) · 1.3 KB
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
#!/bin/bash
. utils.sh
# find correct name for cutycapt
CUTYCAPT=`compgen -c |grep -i CutyCapt`
# check if display available
if [[ "$DISPLAY" == "" ]]; then
CUTYCAPT="xvfb-run -a -e /var/log/xvfb.log $CUTYCAPT"
fi
function simple_link {
$CUTYCAPT --url=$1 \
--out=$2 \
--delay=5000 \
--plugins=on \
--javascript=on >> cutycapt.log 2>&1 && \
echo "success" || \
{
echo "failure. ignoring..." && \
return 1;
}
}
function aliexpress {
./aliexpress screenshot $1 >> aliexpress.log 2>&1
if [[ $? -eq 0 ]]; then
echo "success."
else
echo "failure."
return;
fi
}
function fetch {
check_and_wait_for_internet 5
link=$1
screenshot_name=$2
printf "fetch new result... "
case "$link" in
*trade.aliexpress.com*)
echo "aliexpress link detected... using selenium driver."
aliexpress $screenshot_name
;;
*.17track.net* | "3")
echo "17track.net link detected... using CutyCapt."
simple_link $link $screenshot_name
;;
*)
echo "unrecognized link... using CutyCapt."
simple_link $link $screenshot_name
;;
esac
}