Improved module structure. Added individual scene scrapers for Jules Jordan and XEmpire.
This commit is contained in:
@@ -67,17 +67,55 @@ function scrapeUpcoming(html, site) {
|
||||
});
|
||||
}
|
||||
|
||||
function scrapeScene(html, url, site) {
|
||||
const $ = cheerio.load(html, { normalizeWhitespace: true });
|
||||
|
||||
async function fetchReleases(site) {
|
||||
const [latestRes, upcomingRes] = await Promise.all([
|
||||
bhttp.get(`${site.url}/categories/movies_1_d.html`),
|
||||
bhttp.get(`${site.url}/index.php`),
|
||||
]);
|
||||
const title = $('.title_bar_hilite').text();
|
||||
const date = moment
|
||||
.utc($('.update_date').text(), 'MM/DD/YYYY')
|
||||
.toDate();
|
||||
|
||||
return [
|
||||
...scrapeUpcoming(upcomingRes.body.toString(), site, true),
|
||||
...scrapeLatest(latestRes.body.toString(), site),
|
||||
];
|
||||
const actors = $('.update_description + .update_models a')
|
||||
.map((_actorIndex, actorElement) => $(actorElement).text())
|
||||
.toArray();
|
||||
|
||||
const description = $('.update_description').text().trim();
|
||||
|
||||
const stars = Number($('.avg_rating').text().trim().replace(/[\s|Avg Rating:]/g, ''));
|
||||
|
||||
return {
|
||||
url,
|
||||
title,
|
||||
date,
|
||||
actors,
|
||||
description,
|
||||
rating: {
|
||||
stars,
|
||||
},
|
||||
site,
|
||||
};
|
||||
}
|
||||
|
||||
module.exports = fetchReleases;
|
||||
async function fetchLatest(site) {
|
||||
const res = await bhttp.get(`${site.url}/trial/categories/movies_1_d.html`);
|
||||
|
||||
return scrapeLatest(res.body.toString(), site);
|
||||
}
|
||||
|
||||
async function fetchUpcoming(site) {
|
||||
const res = await bhttp.get(`${site.url}/trial/index.php`);
|
||||
|
||||
return scrapeUpcoming(res.body.toString(), site);
|
||||
}
|
||||
|
||||
async function fetchScene(url, site) {
|
||||
const res = await bhttp.get(url);
|
||||
|
||||
return scrapeScene(res.body.toString(), url, site);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
fetchLatest,
|
||||
fetchUpcoming,
|
||||
fetchScene,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user