const qs = require('querystring'); const url = require('url'); const Entities = require('html-entities').AllHtmlEntities; const util = require('./util'); const VIDEO_URL = 'https://www.youtube.com/watch?v='; const getMetaItem = (body, name) => { return util.between(body, `'); }; /** * Get video description from html * * @param {string} html * @return {string} */ exports.getVideoDescription = (html) => { const regex = /(.+?)<\/p>[\n\r\s]*?<\/div>/im; const description = html.match(regex); return description ? Entities.decode(util.stripHTML(description[1])) : ''; }; /** * Get video media (extra information) from html * * @param {string} body * @return {Object} */ exports.getVideoMedia = (body) => { let mediainfo = util.between(body, '
', '
'); if (mediainfo === '') { return {}; } const regexp = /

([\s\S]*?)<\/h4>[\s\S]*?