#!/bin/bash #Koran Tempo ePaper downloader #by: Ardianto Satriawan #ditambahkan oleh Andrian Dion P. #need gs and pdftk #sudo apt-get install gs pdftk if `dpkg -l | awk {'print $2'} | grep -q wget`; then $(exit 0) else sudo apt-get install wget fi ###checking imagemagick package if `dpkg -l | awk {'print $2'} | grep -q imagemagick`; then $(exit 0) else sudo apt-get install imagemagick fi if `dpkg -l | awk {'print $2'} | grep -q imagemagick`; then $(exit 0) else sudo apt-get install imagemagick fi ###checking gs package if `dpkg -l | awk {'print $2'} | grep -q gs`; then $(exit 0) else sudo apt-get install gs fi ###checking pdftk package if `dpkg -l | awk {'print $2'} | grep -q pdftk`; then $(exit 0) else sudo apt-get install pdftk fi #get today's date TODAYFOLDER=$(date +%Y/%m/%d) TODAYFILE=$(date +%d_%m_%Y) TODAY=$(date +%d-%b-%Y) #create today's directory mkdir $TODAY #get each page #lembar A Utama Nasional PAGE=1 until [ $PAGE -gt 9 ]; do wget "http://epaper.korantempo.com/KT/KT/"$TODAYFOLDER"/PagePrint/"$TODAYFILE"_00"$PAGE".pdf" let PAGE+=1 done PAGE=10 until [ $PAGE -gt 25 ]; do wget "http://epaper.korantempo.com/KT/KT/"$TODAYFOLDER"/PagePrint/"$TODAYFILE"_0"$PAGE".pdf" let PAGE+=1 done #lembar B Utama Bisnis PAGE=101 until [ $PAGE -gt 108 ]; do wget "http://epaper.korantempo.com/KT/KT/"$TODAYFOLDER"/PagePrint/"$TODAYFILE"_"$PAGE".pdf" let PAGE+=1 done #lembar C Metro PAGE=141 until [ $PAGE -gt 148 ]; do wget "http://epaper.korantempo.com/PUBLICATIONS/KT/KT/"$TODAYFOLDER"/PagePrint/"$TODAYFILE"_"$PAGE".pdf" let PAGE+=1 done #lembar B Jateng & Yogya PAGE=221 until [ $PAGE -gt 224 ]; do wget "http://epaper.korantempo.com/PUBLICATIONS/KT/KT/"$TODAYFOLDER"/PagePrint/"$TODAYFILE"_"$PAGE".pdf" let PAGE+=1 done #lembar B Makassar PAGE=241 until [ $PAGE -gt 254 ]; do wget "http://epaper.korantempo.com/PUBLICATIONS/KT/KT/"$TODAYFOLDER"/PagePrint/"$TODAYFILE"_"$PAGE".pdf" let PAGE+=1 done #del page 2 & move to today's directory rm ./$TODAYFILE_002.pdf mv ./*.pdf ./$TODAY #merge the PDFs gs -dNOPAUSE -sDEVICE=pdfwrite -sOUTPUTFILE=./$TODAY/KoranTempo-$TODAY.pdf -dBATCH ./$TODAY/*.pdf #remove PDFs rm ./$TODAY/$TODAYFILE*.pdf