【发布时间】:2016-02-15 09:22:45
【问题描述】:
如何获取 Youtube 视频的时长?我正在尝试这个...
import gdata.youtube
import gdata.youtube.service
yt_service = gdata.youtube.service.YouTubeService()
entry = yt_service.GetYouTubeVideoEntry(video_id='the0KZLEacs')
print 'Video title: %s' % entry.media.title.text
print 'Video duration: %s' % entry.media.duration.seconds
控制台响应
Traceback (most recent call last):
File "/Users/LearningAnalytics/Dropbox/testing/youtube.py", line 8, in <module>
entry = yt_service.GetYouTubeVideoEntry(video_id='the0KZLEacs')
File "/Library/Python/2.7/site-packages/gdata/youtube/service.py", line 210, in GetYouTubeVideoEntry
return self.Get(uri, converter=gdata.youtube.YouTubeVideoEntryFromString)
File "/Library/Python/2.7/site-packages/gdata/service.py", line 1107, in Get
'reason': server_response.reason, 'body': result_body}
gdata.service.RequestError: {'status': 410, 'body': 'No longer available', 'reason': 'Gone'}
【问题讨论】:
-
您是否尝试过使用其他视频 ID?
-
410 错误意味着 youtube 端出了问题,而不是你的
-
是的,我尝试使用不同的 id 并且不起作用
-
知道@BansalUtkarsh 吗?
-
试图在我的机器上复制错误
标签: python video youtube youtube-api youtube-data-api