Search code examples
javascriptjsonnode.jsvideoyoutube

Get video title from ytdl-core


I have ytdl-core downloaded and im using it with discord.js. I have a command that plays a YouTube video's audio into voice chat. Does anybody know a way I can get JUST the string of the video title from a link, or a simple way to get the title? Even easier would be just a way to get the title of the video from the link somehow. Any help is appreciated! Thanks!


Solution

  • what you are looking for is getInfo()

    https://github.com/fent/node-ytdl-core#ytdlgetinfourl-options-callbackerr-info

    getInfo('https://www.youtube.com/watch?v=YQHsXMglC9A', function(err, info) {
      console.log(info.title) // "Adele - Hello"
    });