【发布时间】:2021-07-04 17:52:00
【问题描述】:
我尝试使用 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'],
'http://127.0.0.1:8000/',
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
【问题讨论】:
标签: django vimeo vimeo-api django-oembed