Skip to content

Extra Info

Kain edited this page Mar 20, 2023 · 2 revisions

If you want more information on a single video you can use ytdl-core by fent to fetch full video information like descriptions, exact upload date, likes and dislikes, ect.
I strongly recommend using this instead of the scraped information, as YouTube's render data is unreliable and changes often. The video ID is all you need to load more info using ytdl.

Example:

import youtube from 'scrape-youtube';
import * as ytdl from 'ytdl-core';

youtube.search('Short Change Hero').then(async (results) => {
    const target = results.videos[0];
    const info = await ytdl.getInfo(target.link);

    console.log(info.videoDetails.title); // Short Change Hero
    console.log(info.videoDetails.uploadDate); // 2017-02-11
    console.log(info.videoDetails.dislikes); // 8046
    console.log(info.videoDetails.channelId); // UCbGFbVqBTN3aCjUwz3FChFw
});

Notice

I would recommend against using this on every single result returned by this package, only on a single video you want specific information for. The last thing you want to do is hammer the YouTube API with 20+ requests per search.

This package was made for chat bots or any program that requires basic search information first and advanced information later, the ideal situation would be:

  1. User enters a query
  2. A search is made using scrape-youtube
  3. A list of results is displayed to the user
  4. User selects the video they want
  5. The selected ID is passed on to ytdl and exact/detailed information is loaded
Clone this wiki locally