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) {
|
2020-03-09 01:02:29 +00:00
|
|
|
return scenes.map(({ qu }) => {
|
2020-02-12 22:00:32 +00:00
|
|
|
const release = {};
|
2019-03-24 04:28:18 +00:00
|
|
|
|
2020-03-09 01:02:29 +00:00
|
|
|
release.title = qu.q('.title a', true);
|
2019-04-04 02:00:28 +00:00
|
|
|
|
2020-03-09 01:02:29 +00:00
|
|
|
const pathname = qu.url('.title a');
|
2020-02-12 22:00:32 +00:00
|
|
|
release.entryId = pathname.split('/')[3];
|
|
|
|
release.url = `${site.url}${pathname}`;
|
2019-04-07 03:01:06 +00:00
|
|
|
|
2020-03-09 01:02:29 +00:00
|
|
|
release.date = qu.date('.date', 'MMM DD, YYYY');
|
|
|
|
release.actors = qu.all('.models a.model', true);
|
2019-03-24 04:28:18 +00:00
|
|
|
|
2020-03-09 01:02:29 +00:00
|
|
|
release.poster = qu.q('img').dataset.original;
|
2019-04-04 02:00:28 +00:00
|
|
|
|
2020-03-09 01:02:29 +00:00
|
|
|
release.stars = Number(qu.q('.rating', true));
|
|
|
|
release.likes = Number(qu.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-03-09 01:02:29 +00:00
|
|
|
function scrapeScene({ qu }, _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}`;
|
2020-03-08 03:23:10 +00:00
|
|
|
const res = await geta(url, '.selector');
|
2019-03-24 04:28:18 +00:00
|
|
|
|
2020-03-08 03:23:10 +00:00
|
|
|
return res.ok ? scrapeLatest(res.items, site) : res.status;
|
2019-03-24 04:28:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
async function fetchScene(url, site) {
|
2020-03-08 03:23:10 +00:00
|
|
|
const res = await get(url);
|
2019-03-24 04:28:18 +00:00
|
|
|
|
2020-03-08 03:23:10 +00:00
|
|
|
return res.ok ? scrapeScene(res.item, site) : res.status;
|
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
|
|
|
};
|