首页 > 解决方案 > 尝试从节点中的 YouTube 获取带有缩略图的播放列表

问题描述

我正在尝试从 youtube 获取播放列表。我只得到播放列表的 ID、标题和描述。这是我正在使用的代码。让我知道我还能做些什么来获取缩略图。

谢谢!

const youtubeVideoParams = `key=${apiKey}&channelId=UCEAH4aJ0QadOFn7yPEfWEHw&part=id,snippet&order=date&maxResults=20`;
app.get('/playlists', cacheMiddleware, (req, res) => {
  fetch(`${googleApiUrl}playlists?${youtubeVideoParams}`).then(response => {
    return response.json();
  }).then(response => {
    const playlists = response.items.map(({
      id,
      snippet
    }) => ({
      id: id,
      title: snippet.title,
      desc: snippet.description,
      thumbnails: snippet.thumbnails,
    })).reverse();

标签: node.jsreactjsgoogle-apiyoutube-data-apigoogle-api-nodejs-client

解决方案


推荐阅读