From 8739ec08cf5f92104cb903722377ed251369ee0b Mon Sep 17 00:00:00 2001 From: DebaucheryLibrarian Date: Sat, 2 Jan 2021 03:20:39 +0100 Subject: [PATCH] Fixed qu init selector. Fixed Aziani scene page scope. --- src/scrapers/aziani.js | 2 +- src/utils/qu.js | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/scrapers/aziani.js b/src/scrapers/aziani.js index 31a3390e2..f6cb83d61 100644 --- a/src/scrapers/aziani.js +++ b/src/scrapers/aziani.js @@ -117,7 +117,7 @@ async function fetchLatest(site, page) { } async function fetchScene(url, site) { - const res = await get(url, '.page-content .row'); + const res = await get(url, '.trailer'); if (res.ok) { return scrapeScene(res.item, url, site); diff --git a/src/utils/qu.js b/src/utils/qu.js index 907bbab31..e6ce1eae5 100644 --- a/src/utils/qu.js +++ b/src/utils/qu.js @@ -408,8 +408,12 @@ const quFuncs = { videos, }; -function init(element, window) { - if (!element) return null; +function init(context, selector, window) { + if (!context) { + return null; + } + + const element = selector ? context.querySelector(selector) : context; const legacyContextFuncs = Object.entries(legacyFuncs) // dynamically attach methods with context .reduce((acc, [key, func]) => ({ @@ -444,21 +448,17 @@ function init(element, window) { function initAll(context, selector, window) { if (Array.isArray(context)) { - return context.map(element => init(element, window)); + return context.map(element => init(element, null, window)); } return Array.from(context.querySelectorAll(selector)) - .map(element => init(element, window)); + .map(element => init(element, null, window)); } function extract(htmlValue, selector, options) { const { window } = new JSDOM(htmlValue, { virtualConsole, ...options }); - if (selector) { - return init(window.document.querySelector(selector), window); - } - - return init(window.document, window); + return init(window.document, selector, window); } function extractAll(htmlValue, selector, options) {