129 def download_gdrive(dst):
130 session = requests.Session()
132 URL =
"https://docs.google.com/uc?export=download"
133 response = session.get(URL, params = {
'id' : gid }, stream =
True)
135 def get_confirm_token(response):
136 for key, value
in response.cookies.items():
137 if key.startswith(
'download_warning'):
140 token = get_confirm_token(response)
143 params = {
'id' : gid,
'confirm' : token }
144 response = session.get(URL, params = params, stream =
True)
146 BUFSIZE = 1024 * 1024
147 PROGRESS_SIZE = 10 * 1024 * 1024
150 progress_sz = PROGRESS_SIZE
151 with open(dst,
"wb")
as f:
152 for chunk
in response.iter_content(BUFSIZE):
158 if sz >= progress_sz:
159 progress_sz += PROGRESS_SIZE
164 return download_gdrive