metalx1000

Get and Search Voters Info

May 17th, 2020
1,632
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/bash
  2. ######################################################################
  3. #Copyright (C) 2020  Kris Occhipinti
  4. #https://filmsbykris.com
  5.  
  6. #get voter information
  7.  
  8. #This program is free software: you can redistribute it and/or modify
  9. #it under the terms of the GNU General Public License as published by
  10. #the Free Software Foundation, either version 3 of the License, or
  11. #(at your option) any later version.
  12.  
  13. #This program is distributed in the hope that it will be useful,
  14. #but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16. #GNU General Public License for more details.
  17.  
  18. #You should have received a copy of the GNU General Public License
  19. #along with this program.  If not, see <http://www.gnu.org/licenses/>.
  20. ######################################################################
  21.  
  22. dir="$HOME/data/voters"
  23. mkdir -p "$dir" || exit 1
  24. cd "$dir" || exit 1
  25.  
  26. function main(){
  27.   cmd="$(echo -e "Search\nUpdate"|fzf)"
  28.   $cmd
  29.   exit 0
  30. }
  31.  
  32. function Update(){
  33.   echo "Clearing old data..."
  34.   rm -r "$dir/*"
  35.  
  36.   echo "Looking for newest Voter's Info..."
  37.   url="$(wget -qO- "http://flvoters.com/downloads.html"|grep 2020|grep download|tail -n1|cut -d\" -f2)"
  38.  
  39.   echo "Downloading newest Voter's Info"
  40.   url="$(wget -qO- "$url"|grep zip|cut -d\" -f4|tail -n1)"
  41.   wget "$url" -O voter.zip
  42.   unzip voter.zip
  43.   rm voter.zip
  44.  
  45.   find -name "*.txt"|while read t;do mv "$t" . ;done
  46.  
  47.   Search
  48. }
  49.  
  50. function Search(){
  51.   collier="$(ls CLL*.txt)"
  52.   counties="$(ls *.txt)"
  53.   counties="$(echo -e "$collier\n$counties"|fzf --prompt "Select Counties: " -m|sed ':a;N;$!ba;s/\n/ /g')"
  54.   voter="$(cat $counties|fzf)"
  55.   echo "$voter"
  56.   echo "$voter"|cut -d$'\t' -f1,2
  57.   echo "$voter"|cut -d$'\t' -f3,4,5,6|sed 's/\t/ /g'
  58.   address="$(echo "$voter"|cut -d$'\t' -f8,9,10,11,12,13|sed 's/\t/ /g'|sed 's/  / /g'|sed 's/  / /g')"
  59.   echo "$address"
  60.   echo "https://google.com/maps/place/$address"|tr " " "+"
  61.  
  62.   #cat "$counties"|fzf|sed 's/\t/ /g'|sed 's/  /\n/g'|sed '/^$/d'
  63. }
  64.  
  65. main
RAW Paste Data