我有一个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””
我已经仔细阅读了文档,找不到任何执行此操作的示例,对初学者的问题表示歉意!
答案 0 :(得分:2)
根据docs,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))
答案 1 :(得分:0)
其他方法是使用参数XGetWindowProperty
和sort
接收视频列表
per_page=1
在网址末尾添加您需要的video_data = client.get('https://api.vimeo.com/me/videos?sort=date&per_page=1').json()