如何替换 Dailymotion API 中的现有视频?

How to replace an existing video in Dailymotion API?

我正在使用 Dailymotion 构建应用程序 API https://developer.dailymotion.com/ 使用官方 python sdk https://github.com/dailymotion/dailymotion-sdk-python 并简单地编写视频 CRUD(创建、读取、更新、删除)。 创建、读取、删除已成功完成,但遇到关于 "Update" 的 API 的奇怪响应。

这是我的 Django 项目中代码的简化片段,

def update(request, video_id):
    user = request.user
    video = get_object_or_404(Video, pk=video_id)
    file_path = # define file_path from uploaded file object
    input_title = # define input_title from post request
    input_description = # define input_description from post request
    d = get_dailymotion_d(user)
    if d == 'revoked':
        # do actions of logout and delete the user
    try:
        # get url for upload with the file_path on my server
        url = d.upload(file_path)
        # update
        response = d.post('/video/' + video.dailymotion_video_id, {'url': url, 'title': input_title, 'description': input_description, 'published': 'true', 'channel': 'creation'})
        # delete the video from my sever
        video.file_field.delete()
        return redirect('/videos')

    except Exception as e:
        print(e.args)
        print('update failed..!')
        # delete the video from my server
        video.file_field.delete()
        return redirect('/videos')


def get_dailymotion_d(user):
    d = dailymotion.Dailymotion()
    d.set_grant_type('token', api_key=settings.DAILYMOTION_API_KEY, api_secret=settings.DAILYMOTION_API_SECRET, scope=['email', 'userinfo', 'manage_videos'], info={'redirect_uri': settings.DAILYMOTION_REDIRECT_URI})
    # get credentiaols from database
    access_token = user.dailymotionuser.access_token
    expires = user.dailymotionuser.expires
    refresh_token = user.dailymotionuser.refresh_token
    session_params = {'access_token': access_token, 'expires': expires, 'refresh_token': refresh_token}
    # set the credentials
    d._session_store.set(session_params)
    # check if the user revoked or not
    try:
        force_refreshed_access_token = d.get_access_token(force_refresh=True)
    except dailymotion.DailymotionAuthError as e:
        print(e.args[0])
        return 'revoked'
    # get valid access token
    valid_access_token = d.get_access_token()
    # update database with the valid access token
    DailymotionUser.objects.filter(user=user).update(access_token=valid_access_token, expires=expires, refresh_token=refresh_token)
    # prepare dic of the valid access token
    valid_access_token_dic = {'access_token': valid_access_token}
    # set the valid access token
    d._session_store.set(valid_access_token_dic)

    return d

但更新失败,但 title 字段显示以下消息, 'access_forbidden: You are not allowed to change existing video source.'

来自文档,

access_forbidden: Thrown when the user doesn't have the permission to access the data (e.g. missing a required scope to access certain fields).

但我确定该权限具有 manage_videos 范围,该范围足以更新现有视频源,因为文档说,

manage_videos: Allows to modify or delete the user's uploaded videos and to publish new ones.

如上所述, 仅视频的 title 字段使用 input_title 正确更新。

感谢阅读,我仔细研究了他们的文档,但仍然不明白这个回复。

只有合作伙伴用户可以更新视频源 url。

最佳,