python - 如何将 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()
解决方案
推荐阅读
- javascript - 我们可以在另一台服务器的频道中检查成员权限吗?(discord.js v12)
- sql - 通过删除大括号中的文本来更新列
- angular - 如何在 Spring Boot 中正确实现 put 请求?
- c++ - 如何使用 boost 的 XML Parser 将数据从一个 xml 文件添加到另一个文件
- visual-studio - 如何安装不是一个项目而是解决方案
- vb.net - 使用布尔值 False 时,VB.NET“值不能为空参数名称:源”
- r - 如何逐行比较两个数据帧?
- javascript - 创建一个接受对象字面量的函数并从该对象的成员创建一个类
- graphql - 如何在 GraphQL 模式中定义一个空的对象类型?
- jestjs - 在 Jest 配置中包含“项目”会导致每个测试的多次冗余运行