I am trying to download a file from google drive with file ID and then place the file in my local folder. Download works fine but my problem is that when I try to specify the folder and file name, I can specify the filename manually, but not automated. I mean I want the filename which is fetched from googledrive should go automatically in my specified folder without any manual input as filename. Here is my code:
#!/usr/bin/python3
from pydrive.auth import GoogleAuth
from pydrive.drive import GoogleDrive
gauth = GoogleAuth()
# Try to load saved client credentials
gauth.LoadCredentialsFile("mycreds.txt")
if gauth.credentials is None:
# Authenticate if they're not there
gauth.LocalWebserverAuth()
elif gauth.access_token_expired:
# Refresh them if expired
gauth.Refresh()
else:
# Initialize the saved creds
gauth.Authorize()
# Save the current credentials to a file
gauth.SaveCredentialsFile("mycreds.txt")
drive = GoogleDrive(gauth)
file1 = drive.CreateFile({'id':'xxx'})
file1.GetContentFile('/home/smc/sw_files/xxx.zip')