Simple Script to Download epaper from Mid-Day

Print Friendly, PDF & Email
#ishan dot karve at gmail dot com
#Script to download epaper from
#As always /// Its free to use...
#Get user to select edition
edition_choice=([0]=mumbai [1]=delhi [2]=bangalore [3]=pune)
edition_abbr=([0]=md-mn [1]=md-dn [2]=md-bn [3]=md-pn)
echo "Mid-Day epaper editions are"
echo "-------------------------------------------------"
echo "0. Mumbai"
echo "1. Delhi"
echo "2. Bangalore"
echo "3. Pune"
echo "-------------------------------------------------"
while true; do
    read -p "Enter edition you wish to selec[0-9]: " ed
    case $ed in
 echo "Thanks." 
        * ) echo "Please select the correct numeric serial.";;
ty_dir="$HOME/Desktop/mid_day_`date +%d``date +%m``date +%Y`"

#Get user to input starting page
read -p "Please enter the starting page you wish to download from?" strt_pg
#Get user to input ending page
read -p "Please enter the ending page you wish to download?" end_pg
while true; do
    read -p "Do you wish download pages $strt_pg to $end_pg? [Y/N]" yn
    case $yn in
        [Yy]* ) 
	#create ty directory
	mkdir $ty_dir
    for ((  i = $strt_pg ;  i <= end_pg;  i++  ))
      #prepend zero to single digits
      pageno=`printf "%02d" $i`  
      echo "Downloading Page $pageno"
      I_FILE="${edition_choice[ed]}/`date +%d``date +%m``date +%Y`/epaperpdf/`date +%d``date +%m``date +%Y`-${edition_abbr[ed]}-$i.pdf"
      wget -O $O_FILE $I_FILE 
        [Nn]* ) exit;;
        * ) echo "Please answer yes or no.";;
#combine multiple pdf files
gs -dNOPAUSE -sDEVICE=pdfwrite -sOUTPUTFILE=mid_day_`date +%d``date +%m``date +%Y`.pdf -dBATCH $ty_dir/*.pdf
#empty directory
rm $ty_dir/*.*
#remove directory
rmdir $ty_dir
Ishan Karve

About Ishan Karve

Ishan Karve is just an every day normal guy next door who happens to be an Electronics Engineer by profession and dabbles with PHP, Javascript, C++ and python. His interests vary as seasons change.. they change from astronomy to soul searching. This site is just a reflection of what he does to keep his mind engaged when he is not occupied by work and family. He is an extremely objective guy and is always ready for some good arguments.. of course over a glass of 40% proof alcohol.
This entry was posted in BASH, Programming and tagged . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *