forked from DebaucheryLibrarian/traxxx
Added New Sensations. Returning null from q's date formatter when date is invalid.
This commit is contained in:
78
src/scrapers/newsensations.js
Normal file
78
src/scrapers/newsensations.js
Normal file
@@ -0,0 +1,78 @@
|
||||
'use strict';
|
||||
|
||||
const { geta, edate } = require('../utils/q');
|
||||
|
||||
function scrapeBlockLatest(scenes) {
|
||||
return scenes.map(({ html, q, qa, qu, qt }) => {
|
||||
const release = {};
|
||||
|
||||
const entryId = q('div[class*="videothumb"]', 'class').match(/videothumb_(\d+)/)
|
||||
|| q('div[id*="videothumb"]', 'id').match(/videothumb_(\d+)/);
|
||||
|
||||
release.entryId = entryId[1];
|
||||
|
||||
release.title = q('h4 a', true);
|
||||
release.url = qu('h4 a');
|
||||
release.date = edate(html, 'MM/DD/YYYY', /\d{2}\/\d{2}\/\d{4}/);
|
||||
|
||||
release.actors = qa('.tour_update_models a', true);
|
||||
|
||||
release.poster = q('div img').dataset.src;
|
||||
release.photos = [q('div img', 'src0_4x') || q('div img', 'src0_3x') || q('div img', 'src0_2x')];
|
||||
|
||||
release.teaser = qt();
|
||||
|
||||
console.log(release);
|
||||
|
||||
return release;
|
||||
});
|
||||
}
|
||||
|
||||
function scrapeClassicLatest(scenes) {
|
||||
return scenes.map(({ el, q, qa, qd, qu }) => {
|
||||
const release = {};
|
||||
|
||||
release.entryId = el.dataset.setid;
|
||||
release.url = qu('a');
|
||||
|
||||
release.title = q('.update_title_small', true) || q('a:nth-child(2)', true);
|
||||
|
||||
const description = q('a', 'title');
|
||||
if (description) release.description = description;
|
||||
|
||||
const date = qd('.date_small, .update_date', 'MM/DD/YYYY');
|
||||
if (date) release.date = date;
|
||||
|
||||
const durationLine = q('.update_counts', true);
|
||||
if (durationLine) release.duration = Number(durationLine.match(/(\d+) min/i)[1]) * 60;
|
||||
|
||||
const actors = qa('.update_models a', true);
|
||||
release.actors = actors.length > 0 ? actors : q('.update_models', true).split(/,\s*/);
|
||||
|
||||
const photoCount = q('.update_thumb', 'cnt');
|
||||
[release.poster, ...release.photos] = Array.from({ length: photoCount }).map((value, index) => q('.update_thumb', `src${index}_3x`) || q('.update_thumb', `src${index}_2x`) || q('.update_thumb', `src${index}_1x`));
|
||||
|
||||
console.log(release);
|
||||
|
||||
return release;
|
||||
});
|
||||
}
|
||||
|
||||
async function fetchLatest(site, page = 1) {
|
||||
if (!site.parameters) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const url = `${site.url}/tour_${site.parameters.siteId}/categories/movies_${page}_d.html`;
|
||||
const qLatest = await geta(url, '.updatesBlock .movieBlock, .updatesBlock .videoBlock, .latest_updates_block .update_details, .category_listing_block .update_details');
|
||||
|
||||
if (qLatest && site.parameters.block) {
|
||||
return scrapeBlockLatest(qLatest, site);
|
||||
}
|
||||
|
||||
return qLatest && scrapeClassicLatest(qLatest, site);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
fetchLatest,
|
||||
};
|
||||
@@ -36,6 +36,7 @@ const mindgeek = require('./mindgeek');
|
||||
const mofos = require('./mofos');
|
||||
const naturals = require('./21naturals');
|
||||
const naughtyamerica = require('./naughtyamerica');
|
||||
const newsensations = require('./newsensations');
|
||||
const nubiles = require('./nubiles');
|
||||
const perfectgonzo = require('./perfectgonzo');
|
||||
const pervcity = require('./pervcity');
|
||||
@@ -93,6 +94,7 @@ module.exports = {
|
||||
mindgeek,
|
||||
mofos,
|
||||
naughtyamerica,
|
||||
newsensations,
|
||||
nubiles,
|
||||
perfectgonzo,
|
||||
pervcity,
|
||||
|
||||
Reference in New Issue
Block a user