【问题标题】:YouTube Info - Getting rejection errorsYouTube 信息 - 收到拒绝错误
【发布时间】:2020-10-13 17:15:09
【问题描述】:

由于我对编程很陌生,我想可以很快找到解决方案。 我尝试使用节点包youtube-info 抓取YouTube 数据。 在我的数据库中有 VideoIds 和爬取的值。

基本上我的函数可以工作,但几乎每第二个条目都是一个错误,尽管 ID 是正确的。 我怀疑这是一个计时/查询问题

const mysql = require('mysql2/promise')
const pool = mysql.createPool({
    host     : '***',
    user     : '***',
    password : '***',
    database : '***',
    waitForConnections: true,
    connectionLimit: 10,
    queueLimit: 0
})

let videos = []

async function getVideosToCrawl() {
    await pool.query('SELECT * FROM youtubeVideos', (err, rows) => {
        if (err) throw err
        for (let item of rows){
            videos.push(item.videoID)
            console.log(item.videoID)
        }
        for (let item of videos){
            fetchVideoInfo(item).then(function (videoInfo) {
                console.log(videoInfo)
            })
        }
    })
}

getVideosToCrawl()
{
  videoId: '_JpDImQn8vE',
  url: 'https://www.youtube.com/watch?v=_JpDImQn8vE',
  title: 'El Mejor DÍA y HORA Para Publicar Videos en Youtube 2020',
  description: 'Como opciones.',
  owner: 'Aletz84',
  channelId: 'UCniy9BkhRl3ld7SHTNjgiaw',
  thumbnailUrl: 'https://i.ytimg.com/vi/_JpDImQn8vE/maxresdefault.jpg',
  embedURL: undefined,
  datePublished: '2020-05-30',
  genre: 'Howto & Style',
  paid: false,
  unlisted: false,
  isFamilyFriendly: true,
  duration: 333,
  views: 1990,
  regionsAllowed: [
    'AD', 'AE', 'AF', 'AG', 'AI', 'AL', 'AM', 'AO', 'AQ', 'AR',
    'AS', 'AT', 'AU', 'AW', 'AX', 'AZ', 'BA', 'BB', 'BD', 'BE',
    'BF', 'BG', 'BH', 'BI', 'BJ', 'BL', 'BM', 'BN', 'BO', 'BQ',
    'BR', 'BS', 'BT', 'BV', 'BW', 'BY', 'BZ', 'CA', 'CC', 'CD',
    'CF', 'CG', 'CH', 'CI', 'CK', 'CL', 'CM', 'CN', 'CO', 'CR',
    'CU', 'CV', 'CW', 'CX', 'CY', 'CZ', 'DE', 'DJ', 'DK', 'DM',
    'DO', 'DZ', 'EC', 'EE', 'EG', 'EH', 'ER', 'ES', 'ET', 'FI',
    'FJ', 'FK', 'FM', 'FO', 'FR', 'GA', 'GB', 'GD', 'GE', 'GF',
    'GG', 'GH', 'GI', 'GL', 'GM', 'GN', 'GP', 'GQ', 'GR', 'GS',
    'GT', 'GU', 'GW', 'GY', 'HK', 'HM', 'HN', 'HR', 'HT', 'HU',
    ... 149 more items
  ],
  dislikeCount: 9,
  likeCount: 256,
  channelThumbnailUrl: 'https://yt3.ggpht.com/a/AATXAJxo4b4LfwRTPwiINRneCgYMJYIDT_YqodCM5UzT-w=s48-c-k-c0xffffffff-no-rj-mo',
  commentCount: 126
}
Unhandled rejection Error: Video does not exist
    at C:\Users\olli9\OneDrive\Coding\YouTube\node_modules\youtube-info\index.js:19:13
    at tryCatcher (C:\Users\olli9\OneDrive\Coding\YouTube\node_modules\bluebird\js\release\util.js:16:23)
    at Promise._settlePromiseFromHandler (C:\Users\olli9\OneDrive\Coding\YouTube\node_modules\bluebird\js\release\promise.js:547:31)
    at Promise._settlePromise (C:\Users\olli9\OneDrive\Coding\YouTube\node_modules\bluebird\js\release\promise.js:604:18)
    at Promise._settlePromise0 (C:\Users\olli9\OneDrive\Coding\YouTube\node_modules\bluebird\js\release\promise.js:649:10)
    at Promise._settlePromises (C:\Users\olli9\OneDrive\Coding\YouTube\node_modules\bluebird\js\release\promise.js:729:18)
    at _drainQueueStep (C:\Users\olli9\OneDrive\Coding\YouTube\node_modules\bluebird\js\release\async.js:93:12)
    at _drainQueue (C:\Users\olli9\OneDrive\Coding\YouTube\node_modules\bluebird\js\release\async.js:86:9)
    at Async._drainQueues (C:\Users\olli9\OneDrive\Coding\YouTube\node_modules\bluebird\js\release\async.js:102:5)
    at Immediate.Async.drainQueues [as _onImmediate] (C:\Users\olli9\OneDrive\Coding\YouTube\node_modules\bluebird\js\release\async.js:15:14)
    at processImmediate (internal/timers.js:456:21)

【问题讨论】:

    标签: javascript mysql node.js youtube-api


    【解决方案1】:

    问题解决了! 为了更好地为未来做好准备,我直接切换到了 YouTube API。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-05-22
      • 1970-01-01
      • 1970-01-01
      • 2014-10-11
      • 2020-03-12
      • 1970-01-01
      相关资源
      最近更新 更多