'use strict'; const fetch = require('node-fetch'); const cheerio = require('cheerio'); const base = 'https://www.erome.com/'; async function erome(host) { const res = await fetch(`${base}a/${host.id}`); if (res.ok) { throw new Error(`Unable to retrieve info for Erome album '${host.id}' :(`); } const html = await res.text(); const $ = cheerio.load(html); const videoUrls = $('video').toArray().map((videoEl) => { const sourceHd = $(videoEl).find('source[label="HD"]'); const sourceSd = $(videoEl).find('source[label="SD"]'); console.log(sourceHd.attr('src')); return sourceHd ? base + sourceHd.attr('src') : base + sourceSd.attr('src'); }); console.log(videoUrls); } module.exports = erome;