forked from fluks/issuu-dl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathissuu-dl_jpg.sh
60 lines (39 loc) · 1.78 KB
/
issuu-dl_jpg.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
#!/usr/bin/env bash
# updated 04FEB2024
if (curl -s ifconfig.co > /dev/null;) then
html=$(wget --quiet --retry-connrefused --waitretry=1 --read-timeout=20 --tries=0 --output-document=- "$1")
html0=$(echo "$html" | echo $html | grep -oE "pageCount.*more" | sed -re "s/\".//g" )
echo $html0
else
echo "1"; sleep 10
fi
page_count=$(echo "$html0" |\
grep --only-matching --perl-regexp 'pageCount:\K\d+')
[[ $page_count > 0 ]] || { echo 'no pages' && exit 1; }
echo $page_count
publication_id=$(echo "$html0" |\
grep --only-matching --perl-regexp 'publicationId:\K[a-z0-9]+(?=)')
[[ -n $publication_id ]] || { echo 'no publication_id' && exit 1; }
echo $publication_id
revision_id=$(echo "$html0" |\
grep --only-matching --perl-regexp 'revisionId:\K[a-z0-9]+(?=)')
[[ -n $revision_id ]] || { echo 'no revision_id' && exit 1; }
echo $revision_id
# whatever hack works for title
title0=$(echo "$html" |\
grep --only-matching --perl-regexp 'title":"\K.*?(?=")')
[[ -z $title ]] && title=issuu
title1=$(echo $html | grep -ohE ".{0}title>.{230}" | grep -oh ">.*by.*Issuu" | sed "s/>//" | sed "s/\//-/g" | sed "s/amp;//g");
[[ -z $title ]] && title=issuu
echo $title1
mkdir "${title1}"
for ((i = 1; i <= page_count; i++)); do
foo=$(printf "%04d" ${i});
wget --limit-rate=800k --retry-connrefused --waitretry=1 --read-timeout=20 --tries=0 --output-document="$title1/"${foo}".jpg" \
"https://image.issuu.com/${revision_id}-${publication_id}/jpg/page_${i}.jpg"
done
echo "--------------------------------------------------------------------------";
numb_files="$(ls "${title1}" | wc -l)";
echo "title: $title1";
echo "the number of jpg files that were downloaded are: $numb_files";
echo "while it was counted that online exists: $page_count";