LAPINPT

Google Drive Curl Download

Aug 13th, 2016
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.99 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. # How does it work?
  4. # Get cookie file and html code with curl.
  5. # Pipe html to grep and sed and search for file name
  6. # Get confirm code from cookie file with awk.
  7. # Finally download file with cookie enabled,  confirm code and filename
  8.  
  9. # gDriveDL "https://drive.google.com/uc?export=download&id=0i_rjRJFN5EmftWVySUmCRjMtHDt"
  10. # gDriveDL "https://drive.google.com/open?id=0i_rjRJFN5EmftWVySUmCRjMtHDt"
  11. # gDriveDL "https://drive.google.com/file/d/0i_rjRJFN5EmftWVySUmCRjMtHDt/view"
  12. # gDriveDL "https://drive.google.com/file/d/0i_rjRJFN5EmftWVySUmCRjMtHDt/edit?usp=sharing"
  13.  
  14. ggURL='https://drive.google.com/uc?export=download'
  15.  
  16. ggID="$(sed 's/\W/\n/g' <<<"$1" | egrep -o '\w{26,30}')"; echo -n "${ggID} "
  17.  
  18. gfNM="$(curl -sc /tmp/gcokie "${ggURL}&id=${ggID}" | grep -o '="uc-name.*</span>' | sed 's/.*">//;s/<.a> .*//')"
  19.  
  20. gKD="$(awk '/_warning_/ {print $NF}' /tmp/gcokie)"; echo -n "${gKD} "
  21.  
  22. curl -sLb /tmp/gcokie "${ggURL}&confirm=${gKD}&id=${ggID}" -o "${gfNM}" && echo "${gfNM}"
Add Comment
Please, Sign In to add comment