首页 > 解决方案 > 如何将 mp4 文件上传到谷歌驱动器?

问题描述

所以我正在尝试创建一个脚本,它将获取我最新的游戏剪辑并将其上传到我的谷歌驱动器,以便我可以在手机上访问它。现在,这个脚本将两个文件上传到我的谷歌驱动器,它们的名称相同,但我无法打开它们。这两个文件名为:“C:\Users\ethan\Videos\Radeon ReLive\Replay_2020.12.03-00.04.mp4”。我只想显示一个 mp4 文件。这是我第一次使用谷歌 API,所以我很感谢任何帮助。谢谢!

import os.path
from pydrive.drive import GoogleDrive 
from pydrive.auth import GoogleAuth 

path = r'C:\Users\ethan\Videos\Radeon ReLive'
filelist = [os.path.join(path, f) for f in os.listdir(path)]
filelist = [f for f in filelist if os.path.isfile(f)]
newest = max(filelist, key=lambda x: os.stat(x).st_mtime)
print(newest)


gauth = GoogleAuth() 
gauth.LocalWebserverAuth()        
drive = GoogleDrive(gauth) 
file1 = drive.CreateFile({'title': newest})
file1.Upload() 

标签: pythonwindowsgoogle-drive-apioperating-system

解决方案


推荐阅读