请求包含一个无效的参数位置参数YouTube API
大家好,我试图制作一个简单的python脚本,该脚本将返回一年内创建的所有视频,靠近ceratin latiude and Longiute,在半径1公里之内。但是,当我在查询中使用位置参数时,我会收到此错误,说请求包含一个无效的参数。任何人都知道如何修复此问题吗?
请求包含一个无效的参数。
import googleapiclient.discovery
api_service_name = "youtube"
api_version = "v3"
DEVELOPER_KEY = 'key'
# API client
youtube = googleapiclient.discovery.build(
api_service_name, api_version, developerKey = DEVELOPER_KEY)
request = youtube.search().list(
part="id,snippet",
type='video',
videoDuration='short',
videoDefinition='high',
publishedAfter='2012-07-05T11:10:04Z',
publishedBefore='2013-07-05T11:10:04Z',
location='37.42307,-122.08427',
locationRadius='1km'
)
response = request.execute()
for item in response['items']:
# Getting the id
vidId = item['id']['videoId']
# Getting stats of the video
print("Publish date:",item ['snippet']['publishedAt'])
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
也许Python库有一个错误,也许只是从:
https://www.googleapis.com/youtube/v3/search?part=snippet&type=video = video& videDuration = short = short&videDodeFinition&videDodefinition = high = high&amp公开EDAFTER = 2012-07-05T11:10:04Z& amp; eublistedborefore = 2013-07-05t11:10:04z& location = 37.42307,-122.08427& locationradius = 1km& key = api_key_key = api_key
适合您的需求,因为此URL至少返回正确的结果( dkyngafggrm )。
Maybe the Python library has a bug, maybe just retrieving JSON from:
https://www.googleapis.com/youtube/v3/search?part=snippet&type=video&videoDuration=short&videoDefinition=high&publishedAfter=2012-07-05T11:10:04Z&publishedBefore=2013-07-05T11:10:04Z&location=37.42307,-122.08427&locationRadius=1km&key=API_KEY
would fit your needs, as this URL returns at least a correct result (dKyngAFggRM).