python 类型错误 : unbound method UpdateVideoEntry() must be called with YouTubeService instance

标签 python youtube

我正在尝试使用 youtube api 更新条目。这是我正在努力解决的错误:

Traceback (most recent call last): File "", line 1, in updated_entry = gdata.youtube.service.YouTubeService.UpdateVideoEntry(YTVentry.id) TypeError: unbound method UpdateVideoEntry() must be called with YouTubeService instance as first argument (got NoneType instance instead)

这是我的代码:

    import gdata.youtube
    import gdata.youtube.service
    import gdata.youtube.data
client = gdata.youtube.service.YouTubeService()    
...
videos_feed = client.GetYouTubeVideoFeed(uri)
    for entry in videos_feed.entry:
    print entry.title.text
        YTentry = entry._GDataEntry__GetId
        YTVentry = gdata.youtube.YouTubeVideoEntry(YTentry)
        YTVentry.media.title = '09.11.2012 Hold me close'
        YTVentry.media.description = '09.11.2012 : Hold me close section'
        updated_entry = gdata.youtube.service.YouTubeService.UpdateVideoEntry(YTVentry.id)

根据 google gdata youtube 文档:

To update video meta-data, simply update the YouTubeVideoEntry object and then use the YouTubeService objects' UpdateVideoEntry method. This method takes as a parameter a YouTubeVideoEntry that contains updated meta-data.

提前致谢。

最佳答案

    updated_entry = gdata.youtube.service.YouTubeService.UpdateVideoEntry(YTVentry.id)

应该是

    updated_entry = client.UpdateVideoEntry(YTVentry.id)

gdata.youtube.service.YouTubeService.UpdateVideoEntry(YTVentry.id) TypeError: unbound method UpdateVideoEntry() must be called with YouTubeService instance as first argument (got NoneType instance instead)

该错误是因为您尝试从类而不是您创建的客户端对象调用 UpdateVideoEntry。您已经创建了一个 YouTubeService 对象 client,您需要使用它,而不是直接调用类的方法。

关于python 类型错误 : unbound method UpdateVideoEntry() must be called with YouTubeService instance,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12568342/

相关文章:

api - YouTube数据API v3:显示具有一定观看次数的随机视频

python - 简单的for循环解释

python - GAE : Does execution continue after hitting "Exceeded soft private memory limit"?

Python 等同于 MATLAB 的 normplot?

jquery - 延时后的模态弹出框到hide()

api - YouTube API : How can I get the date/time in which a user marked video as favorite?

Python:显示具有负值和正值的矩阵

python - re.findall() 并不像预期的那样贪婪——Python 2.7

javascript - youtube 视频结束时关闭 fancybox 弹出窗口

youtube - 从Youtube header 访问YouTube的GET参数