Skip to content

Instantly share code, notes, and snippets.

@fuzzmonkey
Created October 1, 2017 14:30
Show Gist options
  • Save fuzzmonkey/88a3311e989bd396e2a2f53ce72f2a87 to your computer and use it in GitHub Desktop.
Save fuzzmonkey/88a3311e989bd396e2a2f53ce72f2a87 to your computer and use it in GitHub Desktop.
Ruby script for downloading a file from google drive given a public file id
# usuage ruby download_google_drive.rb <FILE ID>
fileid = ARGV[0]
confirm_code = `wget --save-cookies cookies.txt --keep-session-cookies --no-check-certificate 'https://docs.google.com/uc?export=download&id=#{fileid}' -O- | sed -rn 's/.*confirm=([0-9A-Za-z_]+).*/\\1\/p'`
`wget --load-cookies cookies.txt 'https://docs.google.com/uc?export=download&confirm=#{confirm_code}&id=#{fileid}'`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment