2019-03-24 04:28:18 +00:00
|
|
|
'use strict';
|
|
|
|
|
2020-02-12 22:00:32 +00:00
|
|
|
const { get, geta } = require('../utils/q');
|
2019-03-24 04:28:18 +00:00
|
|
|
|
2020-02-12 22:00:32 +00:00
|
|
|
function scrapeLatest(scenes, site) {
|
|
|
|
return scenes.map(({ q, qa, qu, qd }) => {
|
|
|
|
const release = {};
|
2019-03-24 04:28:18 +00:00
|
|
|
|
2020-02-12 22:00:32 +00:00
|
|
|
release.title = q('.title a', true);
|
2019-04-04 02:00:28 +00:00
|
|
|
|
2020-02-12 22:00:32 +00:00
|
|
|
const pathname = qu('.title a');
|
|
|
|
release.entryId = pathname.split('/')[3];
|
|
|
|
release.url = `${site.url}${pathname}`;
|
2019-04-07 03:01:06 +00:00
|
|
|
|
2020-02-12 22:00:32 +00:00
|
|
|
release.date = qd('.date', 'MMM DD, YYYY');
|
|
|
|
release.actors = qa('.models a.model', true);
|
2019-03-24 04:28:18 +00:00
|
|
|
|
2020-02-12 22:00:32 +00:00
|
|
|
release.poster = q('img').dataset.original;
|
2019-04-04 02:00:28 +00:00
|
|
|
|
2020-02-12 22:00:32 +00:00
|
|
|
release.stars = Number(q('.rating', true));
|
|
|
|
release.likes = Number(q('.likes', true));
|
2019-04-07 03:01:06 +00:00
|
|
|
|
2020-02-12 22:00:32 +00:00
|
|
|
console.log(release);
|
|
|
|
return release;
|
2019-04-04 02:00:28 +00:00
|
|
|
});
|
2019-03-24 04:28:18 +00:00
|
|
|
}
|
|
|
|
|
2020-02-13 02:44:04 +00:00
|
|
|
function scrapeScene({ q }, _site) {
|
2020-02-12 22:00:32 +00:00
|
|
|
const release = {};
|
2019-04-07 03:01:06 +00:00
|
|
|
|
2020-02-12 22:00:32 +00:00
|
|
|
console.log(release);
|
|
|
|
return release;
|
2019-03-24 04:28:18 +00:00
|
|
|
}
|
|
|
|
|
2019-04-06 21:24:26 +00:00
|
|
|
async function fetchLatest(site, page = 1) {
|
2020-02-12 22:00:32 +00:00
|
|
|
const url = `${site.url}/${page}`;
|
|
|
|
const qLatest = await geta(url, '.selector');
|
2019-03-24 04:28:18 +00:00
|
|
|
|
2020-02-12 22:00:32 +00:00
|
|
|
return qLatest && scrapeLatest(qLatest, site);
|
2019-03-24 04:28:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
async function fetchScene(url, site) {
|
2020-02-12 22:00:32 +00:00
|
|
|
const qScene = await get(url);
|
2019-03-24 04:28:18 +00:00
|
|
|
|
2020-02-12 22:00:32 +00:00
|
|
|
return qScene && scrapeScene(qScene, site);
|
2019-03-24 04:28:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
fetchLatest,
|
2020-02-13 02:44:04 +00:00
|
|
|
fetchScene,
|
2019-03-24 04:28:18 +00:00
|
|
|
};
|