Dynamic URL list
This commit is contained in:
parent
b752cd6dbf
commit
65ddbc80eb
26
generate.sh
26
generate.sh
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
COVER_URL=https://www.cl.cam.ac.uk/~rja14/Papers/SEv3-cover.jpg
|
COVER_URL=https://www.cl.cam.ac.uk/~rja14/Papers/SEv3-cover.jpg
|
||||||
FINAL_PDF=security-engineering-3rd-edition.pdf
|
FINAL_PDF=security-engineering-3rd-edition.pdf
|
||||||
|
INPUT_FILE="urls.txt"
|
||||||
|
|
||||||
function assert_installed() {
|
function assert_installed() {
|
||||||
for var in "$@"; do
|
for var in "$@"; do
|
||||||
if ! which $var &> /dev/null; then
|
if ! which $var &> /dev/null; then
|
||||||
|
@ -21,18 +23,19 @@ if [[ $@ == *'--download-cover-image'* ]]; then
|
||||||
echo "Cover Image downloaded and converted to pdf"
|
echo "Cover Image downloaded and converted to pdf"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
declare -a FILES_LIST
|
||||||
|
|
||||||
|
while IFS= read -r line
|
||||||
|
do
|
||||||
|
FILENAME=$(basename "$line")
|
||||||
|
FILES_LIST+=("$FILENAME")
|
||||||
|
done < "$INPUT_FILE"
|
||||||
|
|
||||||
echo "Starting PDF download"
|
echo "Starting PDF download"
|
||||||
wget --quiet --timestamping --input-file "urls.txt"
|
wget --quiet --timestamping --input-file "urls.txt"
|
||||||
echo "All PDFs downloaded"
|
echo "All PDFs downloaded"
|
||||||
|
|
||||||
pdftk cover.pdf SEv3-pref-May16.pdf SEv3-ch1-dec18.pdf \
|
pdftk cover.pdf ${FILES_LIST[@]} cat output temp.pdf
|
||||||
SEv3-ch2-dec18.pdf SEv3-ch3-dec18.pdf SEv3-ch4-dec18.pdf \
|
|
||||||
SEv3-ch5-dec18.pdf SEv3-ch6-dec18.pdf SEv3-ch7-dec18.pdf \
|
|
||||||
SEv3-ch8-dec18.pdf SEv3-ch9-dec18.pdf SEv3-ch10-dec18.pdf \
|
|
||||||
SEv3-ch11-jan7.pdf SEv3-ch13-dec18.pdf SEv3-ch14-dec20.pdf \
|
|
||||||
SEv3-ch15-dec18.pdf SEv3-ch16-dec18.pdf SEv3-ch17-dec20.pdf \
|
|
||||||
SEv3-ch18-dec18.pdf SEv3-ch19-dec18.pdf SEv3-ch26-dec18.pdf \
|
|
||||||
SEv3-bib-jan7.pdf cat output temp.pdf
|
|
||||||
|
|
||||||
echo "PDF files combined"
|
echo "PDF files combined"
|
||||||
|
|
||||||
|
@ -52,18 +55,19 @@ if [[ $@ == *'--generate-metadata'* ]]; then
|
||||||
echo "BookmarkLevel: 1" >> meta.txt
|
echo "BookmarkLevel: 1" >> meta.txt
|
||||||
echo "BookmarkPageNumber: 1" >> meta.txt
|
echo "BookmarkPageNumber: 1" >> meta.txt
|
||||||
|
|
||||||
input="urls.txt"
|
|
||||||
while IFS= read -r line
|
while IFS= read -r line
|
||||||
do
|
do
|
||||||
FILENAME=$(basename "$line")
|
FILENAME=$(basename "$line")
|
||||||
PAGES=$(qpdf --show-npages "$FILENAME")
|
PAGES=$(qpdf --show-npages "$FILENAME")
|
||||||
|
BOOKMARK_TITLE=$(cut -d- -f 2)
|
||||||
|
|
||||||
echo "BookmarkBegin" >> meta.txt
|
echo "BookmarkBegin" >> meta.txt
|
||||||
echo "BookmarkTitle: $FILENAME" >> meta.txt
|
echo "BookmarkTitle: $BOOKMARK_TITLE" >> meta.txt
|
||||||
echo "BookmarkLevel: 1" >> meta.txt
|
echo "BookmarkLevel: 1" >> meta.txt
|
||||||
echo "BookmarkPageNumber: $PAGE_NUM" >> meta.txt
|
echo "BookmarkPageNumber: $PAGE_NUM" >> meta.txt
|
||||||
PAGE_NUM=$((PAGE_NUM+PAGES))
|
PAGE_NUM=$((PAGE_NUM+PAGES))
|
||||||
done < "$input"
|
done < "$INPUT_FILE"
|
||||||
echo "Metadata updated"
|
echo "Metadata updated"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
2
urls.txt
2
urls.txt
|
@ -18,4 +18,4 @@ https://www.cl.cam.ac.uk/~rja14/Papers/SEv3-ch17-dec20.pdf
|
||||||
https://www.cl.cam.ac.uk/~rja14/Papers/SEv3-ch18-dec18.pdf
|
https://www.cl.cam.ac.uk/~rja14/Papers/SEv3-ch18-dec18.pdf
|
||||||
https://www.cl.cam.ac.uk/~rja14/Papers/SEv3-ch19-dec18.pdf
|
https://www.cl.cam.ac.uk/~rja14/Papers/SEv3-ch19-dec18.pdf
|
||||||
https://www.cl.cam.ac.uk/~rja14/Papers/SEv3-ch26-dec18.pdf
|
https://www.cl.cam.ac.uk/~rja14/Papers/SEv3-ch26-dec18.pdf
|
||||||
https://www.cl.cam.ac.uk/~rja14/Papers/SEv3-bib-jan7.pdf
|
https://www.cl.cam.ac.uk/~rja14/Papers/SEv3-bib-jan7.pdf
|
||||||
|
|
Loading…
Reference in New Issue