Youtube Data API V3 - 使用 google.youtube.videos.list() 获取视频时出错
我在尝试通过 Id 获取 YouTube 视频时遇到一个神秘错误:
I am getting a cryptic error when trying to fetch a youtube video by it's Id:
TypeError: 无法读取未定义的属性0"
我之前使用 google-api-nodejs-client
的 (16.1.0) 进行了这项工作,但在更新包后,它似乎不再起作用.
I previously had this working using (16.1.0) of google-api-nodejs-client
, but after updating the package it no longer seems to work.
这是我使用的代码:
const { google } = require('googleapis');
const youtube = google.youtube({ version: 'v3', auth: process.env.YOUTUBE_KEY });
youtube.videos.list({
id: 'Txlk7PiHaGk',
part: 'snippet, contentDetails'
}, (err, video) => {
if (err) {
console.error(`Error fetching Youtube Video: ${err}`);
}
// success..
});
出于某种原因,我的请求每次都出错.
For some reason my request errors every time.
任何帮助将不胜感激
最近有消息说最近的 googleapis for node.js 出现了一些错误.我已经为 Gmail API、Drive API 和 Sheets API 确认了它们.同样在 Youtube API,我发现了同样的情况.我确认对于 Youtube API,您的脚本不适用于 v27.0.0、v26.0.0 和 v25.0.0.
Recently, it has been reported that the recent googleapis for node.js has some errors. I had confirmed them for Gmail API, Drive API and Sheets API. Also at Youtube API, I found the same situation. I confirmed that for Youtube API, your script didn't work for v27.0.0, v26.0.0 and v25.0.0.
当我使用 v24.0.0 时,它运行良好.
When I used v24.0.0, it worked fine.
那么,您可以降级到 v24.0.0 再试一次吗?到时候请把 const { google } = require('googleapis');
修改为 const google = require('googleapis');
我相信这些错误会被未来的更新删除.
So, can you downgrade to v24.0.0 and try it again? At that time, please modify from const { google } = require('googleapis');
to const google = require('googleapis');
I believe that these errors will be removed by the future update.
- 如何更新我的 Google 表格在 v4 中?
- 使用 Gmail API nodejs 创建 Gmail 过滤器,错误:过滤器没有任何条件
- 尝试通过 API(v3) 在 Google Drive 上创建文件夹时权限不足
如果这些信息对您没有帮助,我很抱歉.
If this information is not useful for you, I'm sorry.