Advertisement
metalx1000

Book Grabber with Smart stopper

Mar 21st, 2019
918
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.32 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. delay="1"
  4.  
  5. echo -n "Book Title:"
  6. read title
  7.  
  8. title="${title// /-}"
  9. mkdir "$title" || exit 1
  10.  
  11.  
  12. if [ "$1" = "collier" ]
  13. then
  14.   #collier County Lib
  15.   echo "Working with Collier County"
  16.   p1="664x900+296+144"
  17.   p2="664x900+960+144"
  18. else
  19.   #Amazon Kindle
  20.   echo "Working With Kindle Cloud"
  21.   p1="750x1023+200+43"
  22.   p2="750x1023+960+43"
  23. fi
  24.  
  25. #now using Smart ender
  26. # let p=100
  27. # echo -n "Number of Pages:"
  28. # read pages
  29. #
  30. # let max="$(echo $pages+$p|bc)"
  31.  
  32. echo "5 seconds to get to book"
  33. sleep 5
  34.  
  35. #stop when end is greater then 2
  36. let end=0
  37. while [ "$end" -lt 2 ]
  38. #while [ "$p" -lt "$max" ]
  39. do
  40.   echo "Page: $(echo $p-100|bc)"
  41.   import -window root -crop $p1 -quality 90 ${title}/page_$p.jpg
  42.   let p+=1
  43.   echo "Page: $(echo $p-100|bc)"
  44.   import -window root -crop $p2 -quality 90 ${title}/page_$p.jpg
  45.  
  46.   xte "key Right"
  47.  
  48.   #after 10 pages
  49.   #compare pages to determine end of book
  50.   if [ $p -gt 110 ]
  51.   then
  52.     i1="${title}/page_$p.jpg"
  53.     let l=$(($p-2))
  54.     i2="${title}/page_$l.jpg"
  55.  
  56.     let v="$(/usr/bin/compare -verbose -metric mae "$i1" "$i2" "/tmp/bookd.png" 2>&1 >/dev/null | grep 'all:'| awk '{print $2}'|cut -d\. -f1)"
  57.     if [ $v -gt 0 ]
  58.     then
  59.       let end=0
  60.     else
  61.       let end+=1
  62.       echo "Page Match - $end"
  63.     fi
  64.  
  65.   fi
  66.  
  67.  
  68.   let p+=1
  69.   sleep $delay
  70. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement