如何将mp4文件上载到google drive?

2024-10-02 08:26:02 发布

您现在位置:Python中文网/ 问答频道 /正文

因此,我正在尝试创建一个脚本,将我最新的游戏剪辑上传到我的谷歌硬盘,这样我就可以在手机上访问它。现在,这个脚本将两个名为相同的文件上传到我的谷歌硬盘,但我无法打开它们。这两个文件名为:“C:\Users\ethan\Videos\Radeon ReLive\Replay\u 2020.12.03-00.04.mp4”。我只想显示一个mp4文件。这是我第一次使用GoogleAPI,所以我非常感谢您的帮助。谢谢

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() 

Tags: 文件pathimport脚本osdriveusersvideos

热门问题