python - 如何检索我刚刚上传的视频的 URL?
问题描述
我有一个 Python 脚本,它通过 api 将视频文件推送到我们的 Vimeo 页面,效果很好。我只是无法检索我们刚刚上传的视频的链接。我在示例文档中找到了一个片段,但它似乎不起作用。
import vimeo
import sys
client = vimeo.VimeoClient(
token="xxxxx",
key="xxxxx",
secret="xxxxx"
)
# Make the request to the server for the "/me" endpoint.
about_me = client.get("/me")
# Make sure we got back a successful response.
assert about_me.status_code == 200
# Load the body"s JSON data. WORKS UP TO THIS LINE ENABLE BELOW
print (about_me.json())
#sys.exit(0)
# Path to upload file
path_to_file = r"C:\Users\mydocs\Documents\SS19xGEN.mp4"
print('Uploading: %s' % path_to_file)
# Push file with credentials
client.upload(path_to_file, data={'name': 'TEST', 'description': 'test'})
# Return the uri
print("The uri for the video is %s" % (client))
video_data = client.get(client + 'fields=link').json()
print(('"%s" has been uploaded to %s' % (path_to_file, video_data['link'])))
该脚本运行良好,直到最后两行,这是我尝试检索我刚刚在脚本中上传的视频的 URL,但这给了我错误 =“发生异常:TypeError 不支持的操作数类型 + : 'VimeoClient' 和 'str'"
我已经翻阅了文档,但找不到任何有关如何执行此操作的示例,对初学者的问题表示歉意!
解决方案
根据文档,该upload
方法应返回 uri:
# Push file with credentials
video_uri = client.upload(path_to_file, data={'name': 'TEST', 'description': 'test'})
# Return the uri
print("The uri for the video is %s" % (video_uri))
推荐阅读
- python - 用百分比提取数字
- ms-access - MS Access 重启号码序列
- bash - 检查字符串是否仅包含 bash shell 脚本中的数字的比较问题
- ssh - Windows 10 OpenSSH ssh-add“代理拒绝操作”(GitLab Windows Shared Runner)
- javascript - 如何在引导模式上使用点击事件
- nearprotocol - 您如何使锁定代币的 NEAR 帐户显示适当的解锁数量?
- kotlin - 未捕获的错误:找不到模块 Kodein-DI-kodein-di
- javascript - 在 Firestore 触发的云函数中,未更改的之前/之后属性不相等
- haskell - Haskell:多态函数抛出类型错误
- javascript - 如何使用框架集标记将下拉菜单按钮的内容置于我的 main.html 中显示的页面顶部