首页 > 解决方案 > 如何检索我刚刚上传的视频的 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'"

我已经翻阅了文档,但找不到任何有关如何执行此操作的示例,对初学者的问题表示歉意!

标签: pythonapivimeovimeo-api

解决方案


根据文档,该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))

推荐阅读