相信已解决:Python API 仅支持 v1,而 watch later 是在 v2 中添加的。源
解决方案:使用“实验”API v3
我正在尝试使用 Youtube API 访问我的稍后观看播放列表。下面是我正在使用的代码。
import gdata.youtube
import gdata.youtube.service
yt_service = gdata.youtube.service.YouTubeService()
yt_service.ssl = True
yt_service.developer_key = 'REDACTED'
yt_service.email = 'REDACTED'
yt_service.password = 'REDACTED'
yt_service.ProgrammaticLogin()
playlist_uri = 'https://gdata.youtube.com/feeds/api/users/default/watch_later?v=2'
playlist_video_feed = yt_service.GetYouTubePlaylistVideoFeed(uri=playlist_uri)
for playlist_video_entry in playlist_video_feed.entry:
print playlist_video_entry.title.text
我收到以下错误。
Traceback (most recent call last):
File "Youtube.py", line 21, in <module>
playlist_video_feed = yt_service.GetYouTubePlaylistVideoFeed(uri=playlist_uri)
File "/Library/Python/2.6/site-packages/gdata/youtube/service.py", line 393, in GetYouTubePlaylistVideoFeed
uri, converter=gdata.youtube.YouTubePlaylistVideoFeedFromString)
File "/Library/Python/2.6/site-packages/gdata/service.py", line 1108, in Get
'reason': server_response.reason, 'body': result_body}
gdata.service.RequestError: {'status': 400, 'body': 'Invalid request URI', 'reason': 'Bad Request'}
似乎 URI https://gdata.youtube.com/feeds/api/users/default/watch_later?v=2无效。然而,这是在谷歌文档中使用的。是我用错了,还是这里有其他问题?
此外,如果我将 URI 更改为http://gdata.youtube.com/feeds/api/playlists/63F0C78739B09958
它按预期工作。