问题描述
我尝试使用 oEmbed 将视频网址转换为嵌入网址,但是:
当我 print(video_url_api_data)
它不断返回 <Response [404]>
我在 google 中使用 url 进行了检查:https://vimeo.com/api/oembed.json?url=https://vimeo.com/570924262
我在代码中做错了什么?我必须在状态部分输入什么?
这个状态部分:
vimeo_authorization_url = v.auth_url(
['private'],'http://127.0.0.1:8000/',1 #status
)
我将 1 设为随机,它有效。
import json,vimeo,requests
class article_upload(View):
def post(self,request,*args,**kwargs):
v = vimeo.VimeoClient(
token='****',key='****',secret='****'
)
file_data = request.FILES["file_data"]
path = file_data.temporary_file_path()
try:
vimeo_authorization_url = v.auth_url(
['private'],1 #status
)
video_uri = v.upload(path,data={'name': '비디오 제목','description': '설명'})
video_data = v.get(video_uri + '?fields=link').json()
video_url = video_data['link']
params={"url": video_url}
video_url_api_data = requests.get('https://vimeo.com/apI/Oembed.json',params=params)
return render(request,'account/myvideopage.html',{context(I made it)})
except vimeo.exceptions.VideoUploadFailure as e:
print("ohohohohohoh...vimeo error")
finally:
file_data.close() # Theoretically this should remove the file
if os.path.exists(path):
os.unlink(path) # But this will do it,barring permissions
解决方法
我之前解决了!问题是……延迟时间!
这里...我上传视频...大小至少为 10MB
video_uri = v.upload(path,data={'name': '비디오 제목','descriptio...
在我完成上传之前,我使用 api 请求信息...
video_url_api_data = requests.get('https://vimeo.com/api/oem...