<commit_before>const ytdl = require('ytdl-core')
const youtube = new (require('youtube-node'))()

exports.name = 'YouTube'
exports.intents = {
  PlayVideo: (intent, cb) => {
    const title = intent.slots.Title.value
    youtube.setKey(process.env.YOUTUBE_KEY)
    youtube.addParam('type', 'video')
    youtube.search(title, 10, (err, result) => {
      if (!err && result && result.items) {
        const item = result.items[0]
        console.log('preparing video..', item)
        ytdl('https://www.youtube.com/watch?v=' + item.id.videoId,
           { quality: 'highest', filter: format => format.container === 'mp4' },
            (err, info) => {
              console.log('download response:', err, info)
              if (err || !info || !info.formats.length) {
                cb({ text: `Trouble playing YouTube video, please try again later.`, shouldEndSession: true })
              }  else {
                const video = info.formats[0]
                cb({ text: `Playing "${item.snippet.title}" from YouTube`, shouldEndSession: true, mediaUrl: video.url })
              }
            })
      } else {
        cb({ text: 'I could not find any results. Play something else?', shouldEndSession: false })
      }
    })
  },
}<commit_msg>debugs<commit_after>const ytdl = require('ytdl-core')
const youtube = new (require('youtube-node'))()

exports.name = 'YouTube'
exports.intents = {
  PlayVideo: (intent, cb) => {
    const title = intent.slots.Title.value
    youtube.setKey(process.env.YOUTUBE_KEY)
    youtube.addParam('type', 'video')
    youtube.search(title, 10, (err, result) => {
      if (!err && result && result.items) {
        const item = result.items[0]
        console.log('preparing video..', item, 'https://www.youtube.com/watch?v=' + item.id.videoId')
        ytdl('https://www.youtube.com/watch?v=' + item.id.videoId,
           { quality: 'highest', filter: format => format.container === 'mp4' },
            (err, info) => {
              console.log('download response:', err, info)
              if (err || !info || !info.formats.length) {
                cb({ text: `Trouble playing YouTube video, please try again later.`, shouldEndSession: true })
              }  else {
                const video = info.formats[0]
                cb({ text: `Playing "${item.snippet.title}" from YouTube`, shouldEndSession: true, mediaUrl: video.url })
              }
            })
      } else {
        cb({ text: 'I could not find any results. Play something else?', shouldEndSession: false })
      }
    })
  },
}
{'fraction_non_alphanumeric': 0.15869905956112854, 'fraction_numerical': 0.003918495297805642, 'mean_word_length': 2.3372549019607844, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 3, 'lorem ipsum': 0, 'www.': 3, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5641090', 'n_tokens_mistral': 799, 'n_tokens_neox': 757, 'n_words': 184}