使用youtube API时获取requestError状态410

2024-05-14 08:05:19 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在使用python进行API调用,根据某人的频道ID检索Youtube播放列表。下面是指示我输入的代码:

import gdata.youtube
import gdata.youtube.service

youtube_service = gdata.youtube.service.YouTubeService()
playlist = raw_input("Please enter the user ID: ")
url = "http://gdata.youtube.com/feeds/api/users/"
playlist_url = url + playlist + "/playlists"

video_feed = youtube_service.GetYouTubePlaylistVideoFeed(playlist_url)

print "\nPlaylists for " + str.format(playlist) + ":\n"
for p in video_feed.entry:
  print p.title.text

运行代码后,我得到一个如下所示的响应错误。 gdata.service.RequestError: {'status': 410, 'body': 'No longer available', 'reason': 'Gone'}

在深入研究这个问题之后,这是由于使用了一个被弃用的API(v2)。这段代码的目的是根据提示给用户的youtube频道ID列出播放列表。如何将其转换为能够根据v3api工作的代码?在

编辑:没关系,这是不被维护的,这是旧版本!在


Tags: 代码importapiidurlforyoutubevideo

热门问题