Python 如何获取youtube频道上最新上传视频的id

Python 如何获取youtube频道上最新上传视频的id,python,youtube,youtube-api,Python,Youtube,Youtube Api,如何使用Python获取特定youtube频道中最新上传视频的id?您可以请求JSON并解析它。下面的代码为您提供第一个(最近的)结果,并将其存储在first中 import urllib, json author = 'Google' inp = urllib.urlopen(r'http://gdata.youtube.com/feeds/api/videos?max-results=1&alt=json&orderby=published&author=' + a

如何使用Python获取特定youtube频道中最新上传视频的id?

您可以请求JSON并解析它。下面的代码为您提供第一个(最近的)结果,并将其存储在
first

import urllib, json

author = 'Google'
inp = urllib.urlopen(r'http://gdata.youtube.com/feeds/api/videos?max-results=1&alt=json&orderby=published&author=' + author)
resp = json.load(inp)
inp.close()

first = resp['feed']['entry'][0]

# Title of the video
print first['title']

# URL
print first['link'][0]['href']
我只是查看了交互式Python shell中的JSON对象。你可以使用我贴的那个。请记住更改作者。这是一个较低层次的方法,@Frederik提到了一些更高层次的东西

第一个
对象如下所示

{
“作者”:[
{
“姓名”:{
“$t”:“谷歌”
}, 
“uri”:{
“$t”:”http://gdata.youtube.com/feeds/api/users/google"
}
}
], 
“类别”:[
{
“方案”:http://schemas.google.com/g/2005#kind", 
“术语”:http://gdata.youtube.com/schemas/2007#video"
}, 
{
“标签”:“科学技术”,
“方案”:http://gdata.youtube.com/schemas/2007/categories.cat", 
“术语”:“技术”
}, 
{
“方案”:http://gdata.youtube.com/schemas/2007/keywords.cat", 
“术语”:“谷歌潮流”
}, 
{
“方案”:http://gdata.youtube.com/schemas/2007/keywords.cat", 
“术语”:“谷歌”
}, 
{
“方案”:http://gdata.youtube.com/schemas/2007/keywords.cat", 
“术语”:“电流”
}, 
{
“方案”:http://gdata.youtube.com/schemas/2007/keywords.cat", 
“术语”:“杂志应用程序”
}, 
{
“方案”:http://gdata.youtube.com/schemas/2007/keywords.cat", 
“术语”:“阅读器应用程序”
}, 
{
“方案”:http://gdata.youtube.com/schemas/2007/keywords.cat", 
“术语”:“安卓”
}, 
{
“方案”:http://gdata.youtube.com/schemas/2007/keywords.cat", 
“术语”:“ios”
}, 
{
“方案”:http://gdata.youtube.com/schemas/2007/keywords.cat", 
“术语”:“安卓手机”
}, 
{
“方案”:http://gdata.youtube.com/schemas/2007/keywords.cat", 
“术语”:“安卓平板电脑”
}, 
{
“方案”:http://gdata.youtube.com/schemas/2007/keywords.cat", 
“术语”:“iphone”
}, 
{
“方案”:http://gdata.youtube.com/schemas/2007/keywords.cat", 
“术语”:“ipad”
}
], 
“内容”:{
“$t”:“Google Currents是一款新的移动应用程序,它可以让您享受免费的在线杂志和其他针对Android或苹果手机和平板电脑优化的内容。有关详细信息,请访问www.Google.com”,
“类型”:“文本”
}, 
“gd$评论”:{
“gd$feedLink”:{
“countHint”:463,
“href”:”http://gdata.youtube.com/feeds/api/videos/5LOcUkm8m9w/comments"
}
}, 
“gd$评级”:{
“平均值”:4.7557077,
“最大”:5,
"min":1,,
“numRaters”:1752年,
“rel”:http://schemas.google.com/g/2005#overall"
}, 
“id”:{
“$t”:”http://gdata.youtube.com/feeds/api/videos/5LOcUkm8m9w"
}, 
“链接”:[
{
“href”:”http://www.youtube.com/watch?v=5LOcUkm8m9w&feature=youtube_gdata", 
“rel”:“备用”,
“类型”:“文本/html”
}, 
{
“href”:”http://gdata.youtube.com/feeds/api/videos/5LOcUkm8m9w/responses", 
“rel”:http://gdata.youtube.com/schemas/2007#video.responses", 
“类型”:“应用程序/atom+xml”
}, 
{
“href”:”http://gdata.youtube.com/feeds/api/videos/5LOcUkm8m9w/related", 
“rel”:http://gdata.youtube.com/schemas/2007#video.related", 
“类型”:“应用程序/atom+xml”
}, 
{
“href”:”http://m.youtube.com/details?v=5LOcUkm8m9w", 
“rel”:http://gdata.youtube.com/schemas/2007#mobile", 
“类型”:“文本/html”
}, 
{
“href”:”http://gdata.youtube.com/feeds/api/videos/5LOcUkm8m9w", 
“rel”:“self”,
“类型”:“应用程序/atom+xml”
}
], 
“媒体$组”:{
“媒体$category”:[
{
“$t”:“技术”,
“标签”:“科学技术”,
“方案”:http://gdata.youtube.com/schemas/2007/categories.cat"
}
], 
“媒体$内容”:[
{
“期限”:94,
“表达式”:“完整”,
“isDefault”:“true”,
“媒体”:“视频”,
“类型”:“应用程序/x-shockwave-flash”,
“url”:”http://www.youtube.com/v/5LOcUkm8m9w?version=3&f=videos&app=youtube_gdata", 
“yt$格式”:5
}, 
{
“期限”:94,
“表达式”:“完整”,
“媒体”:“视频”,
“类型”:“视频/3gpp”,
“url”:”rtsp://v1.cache8.c.youtube.com/CiILENy73wIaGQncm7xJUpyz5BMYDSANFEgGUgZ2aWRlb3MM/0/0/0/video.3gp", 
“yt$格式”:1
}, 
{
“期限”:94,
“表达式”:“完整”,
“媒体”:“视频”,
“类型”:“视频/3gpp”,
“url”:”rtsp://v5.cache4.c.youtube.com/CiILENy73wIaGQncm7xJUpyz5BMYESARFEgGUgZ2aWRlb3MM/0/0/0/video.3gp", 
“yt$格式”:6
}
], 
“媒体$description”:{
“$t”:“Google Currents是一款新的移动应用程序,它可以让您享受免费的在线杂志和其他针对Android或苹果手机和平板电脑优化的内容。有关详细信息,请访问www.Google.com”,
“类型”:“普通”
}, 
“媒体$关键字”:{
“$t”:“Google Currents,Google,Currents,杂志应用程序,Rea