Youtube Data API V3 - 使用 google.youtube.videos.list() 获取视频时出错 [英] Youtube Data API V3 - Error fetching video with google.youtube.videos.list()

查看:28
本文介绍了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.

如果这些信息对您没有帮助,我很抱歉.

If this information is not useful for you, I'm sorry.

这篇关于Youtube Data API V3 - 使用 google.youtube.videos.list() 获取视频时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆