#!/bin/bash #Pikiran Rakyat e-paper downloader #by: Ardianto Satriawan #ditambahkan oleh Andrian Dion P. #need wget and imagemagick #sudo apt-get install wget imagemagick 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 #to get today's newspaper: TODAY=$(date +%d-%b-%Y) YEAR=$(date +%Y) TODAYURL=$(date +%d%m%y) MONTH=$(date +%B) #if you want to get past newspaper, just uncomment #these lines and specify the date #TODAY="03-Jun-2010" #YEAR="2010" #TODAYURL="030610" #MONTH="Juni" #English to Indonesian month translation if [ $MONTH = "January" ]; then BULAN="Januari" else if [ $MONTH = "February" ]; then BULAN="Februari" else if [ $MONTH = "March" ]; then BULAN="Maret" else if [ $MONTH = "April" ]; then BULAN="April" else if [ $MONTH = "May" ]; then BULAN="Mei" else if [ $MONTH = "June" ]; then BULAN="Juni" else if [ $MONTH = "July" ]; then BULAN="Juli" else if [ $MONTH = "August" ]; then BULAN="Agustus" else if [ $MONTH = "September" ]; then BULAN="September" else if [ $MONTH = "October" ]; then BULAN="Oktober" else if [ $MONTH = "November" ]; then BULAN="November" else BULAN="Desember" fi fi fi fi fi fi fi fi fi fi fi #echo $BULAN #create directory mkdir ./$TODAY #getting JPEGs PAGE=1 until [ $PAGE -gt 9 ]; do wget "http://epaper.pikiran-rakyat.com/images/flippingbook/PR/"$YEAR"/"$BULAN"/"$TODAYURL"/"$TODAYURL"_zoom_0"$PAGE".jpg" let PAGE+=1 done PAGE=10 until [ $PAGE -gt 40 ]; do wget "http://epaper.pikiran-rakyat.com/images/flippingbook/PR/"$YEAR"/"$BULAN"/"$TODAYURL"/"$TODAYURL"_zoom_"$PAGE".jpg" let PAGE+=1 done #moving into today's directory mv ./*.jpg ./$TODAY #converting JPEGs into PDFs convert ./$TODAY/*.jpg ./$TODAY/PikiranRakyat-$TODAY.pdf #remove JPEGs rm ./$TODAY/*.jpg #done echo "done!"