pustakakoran

Convert Koran SWF 1600 Langsung JPG_fix

Feb 6th, 2019
80
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/bash
  2. #BPS eBook downloader
  3. #modified from Republika ePaper downloader written by Ardianto Satriawan
  4. #and modified by Susanto
  5.  
  6. #need gs, pdftk and swftools
  7.  
  8. export TZ=Asia/Jakarta
  9. TODAY=$(date --date='0 days' '+%Y%m%d')
  10. TAHUNBULAN=$(date --date='0 days' '+%Y%m')
  11.  
  12. #get each page
  13. PAGE=1
  14. until [ $PAGE -gt 44 ]; do
  15. wget "http://page.isu.pub/150530025021-d86252755902d8bd1932c725f624079a/swf/page_"$PAGE".swf"
  16. let PAGE+=1
  17. done
  18.  
  19. echo "selesai ambil file koran..."
  20.  
  21. #convert COVER
  22. echo "konversi halaman 1 sampai 9..."
  23. PAGE=1
  24. until [ $PAGE -gt 1 ]; do
  25. swfrender -X 1600 -Y 2790 page_$PAGE.swf -o riaupos20150530.jpg
  26. let PAGE+=1
  27. done
  28.  
  29. cp riaupos20150530.jpg /home/koran/public_html/HASIL/
  30. rm -f riaupos20150530.jpg
  31.  
  32. #convert to pdf
  33. echo "konversi halaman 1 sampai 9..."
  34. PAGE=1
  35. until [ $PAGE -gt 9 ]; do
  36. swfrender -X 1600 -Y 2790 page_$PAGE.swf -o page_$PAGE.jpg
  37. convert -verbose -density 300 -trim page_$PAGE.jpg -flatten -sharpen 0x1.0 page_$PAGE.jpg
  38. convert page_$PAGE.jpg page_0$PAGE.pdf
  39. mv page_$PAGE.jpg riaupos20150530_0$PAGE.jpg
  40. rm -f page_$PAGE.swf
  41. let PAGE+=1
  42. done
  43.  
  44. #convert to pdf
  45. echo "konversi halaman 10 sampai selesai..."
  46. PAGE=10
  47. until [ $PAGE -gt 44 ]; do
  48. swfrender -X 1600 -Y 2790 page_$PAGE.swf -o page_$PAGE.jpg
  49. convert -verbose -density 300 -trim page_$PAGE.jpg -flatten -sharpen 0x1.0 page_$PAGE.jpg
  50. convert page_$PAGE.jpg page_$PAGE.pdf
  51. mv page_$PAGE.jpg riaupos20150530_$PAGE.jpg
  52. rm -f page_$PAGE.swf
  53. let PAGE+=1
  54. done
  55.  
  56. #merge the PDFs pakai pdftk - edited by aris
  57. echo "sedang menggabungkan file menjadi satu file PDF..."
  58. #pdftk *.pdf output riaupos-$TODAY.pdf
  59. gs -dNOPAUSE -sDEVICE=pdfwrite -sOUTPUTFILE=riaupos20150530.pdf -dBATCH *.pdf
  60.  
  61. #membuat folder
  62. mkdir riaupos20150530
  63.  
  64. #moving into todays directory
  65. mv ./*.jpg ./riaupos20150530
  66.  
  67. #remove GIFs
  68. echo "sedang menghapus file JPG..."
  69. rm -f *.jpg
  70.  
  71. #remove PDFs
  72. echo "sedang menghapus file PDF..."
  73. rm -f page_*.pdf
  74.  
  75. #PDF Metadata Koran
  76. exiftool -Title="riaupos20150530" -Author="pustakakoran.com" -Publisher="riaupos" -Subject="riaupos"$TAHUNBULAN"" riaupos20150530.pdf
  77. rm -f "riaupos20150530.pdf_original"
  78.  
  79. #Kompress Folder JPG
  80. zip -r riaupos20150530jpg.zip riaupos20150530
  81. rm -f -r riaupos20150530
  82.  
  83. #Copy ke BANKSOAL
  84. cp *20150530.pdf /home/koran/public_html/HASIL/
  85. cp *20150530jpg.zip /home/koran/public_html/HASIL/
  86.  
  87. #remove rest files
  88. rm -f *.swf
  89. rm -f *.jpg
  90. rm -f *.jpg
  91. rm -f *20150530.pdf
  92. rm -f *20150530jpg.zip
  93.  
  94. #Finished
  95. echo "Epaper dari riaupos20150530 sudah jadi silakan periksa..."
  96.  
  97. #bash issuu-riaupos.sh
RAW Paste Data