我正在尝试一些非常简单的事情:从 youtube gdata 模块获取播放器网址列表,
def getlist():
index = 1
prev = 0
urls = []
while True:
uri = "http://gdata.youtube.com/feeds/api/playlists/E005D335B57338D1?start-index=%i&max-results=50" % index
feed = yt_service.GetYouTubeVideoFeed(uri)
for entry in feed.entry:
urls.append(entry.media.player.url)
if prev == len(urls): break
prev = len(urls)
index += 50
return urls
但是调用getlist时会出现如下错误:
>>> urls = getlist()
Traceback (most recent call last):
File "<pyshell#2>", line 1, in <module>
getlist()
File "<pyshell#1>", line 9, in getlist
urls.append(entry.media.player.url)
AttributeError: 'NoneType' object has no attribute 'url'
我不知道为什么会这样,它在几周前就起作用了……有什么想法吗?