2020-01-10 21:10:11 +00:00
|
|
|
'use strict';
|
|
|
|
|
2020-11-04 03:02:51 +00:00
|
|
|
const qu = require('../utils/qu');
|
2020-01-10 21:10:11 +00:00
|
|
|
|
2020-11-04 03:02:51 +00:00
|
|
|
function scrapeLatest(items, channel) {
|
|
|
|
return items.map(({ query }) => {
|
|
|
|
const release = {};
|
2020-01-10 21:10:11 +00:00
|
|
|
|
2020-11-04 03:02:51 +00:00
|
|
|
release.url = query.url('h5 a', null, { origin: channel.url });
|
|
|
|
release.entryId = new URL(release.url).pathname.match(/\/(\d+)/)[1];
|
2020-01-10 21:10:11 +00:00
|
|
|
|
2020-11-04 03:02:51 +00:00
|
|
|
release.title = query.cnt('h5 a');
|
2020-01-10 21:10:11 +00:00
|
|
|
|
2020-11-04 03:02:51 +00:00
|
|
|
[release.poster, ...release.photos] = query.imgs('.screenshot').map(src => [
|
|
|
|
// unnecessarily large
|
|
|
|
// src.replace(/\/\d+/, 3840),
|
|
|
|
// src.replace(/\/\d+/, '/2000'),
|
|
|
|
src.replace(/\/\d+/, '/1500'),
|
|
|
|
src.replace(/\/\d+/, '/1000'),
|
|
|
|
src,
|
|
|
|
]);
|
2020-01-10 21:10:11 +00:00
|
|
|
|
2020-11-04 03:02:51 +00:00
|
|
|
return release;
|
|
|
|
});
|
2020-01-10 21:10:11 +00:00
|
|
|
}
|
|
|
|
|
2020-11-04 03:02:51 +00:00
|
|
|
function scrapeScene({ query, html }, url, channel) {
|
|
|
|
const release = {};
|
|
|
|
|
|
|
|
release.entryId = new URL(url).pathname.match(/\/(\d+)/)[1];
|
|
|
|
|
|
|
|
release.title = query.cnt('h1.description');
|
|
|
|
release.actors = query
|
|
|
|
.all('.video-performer')
|
|
|
|
.map((actorEl) => {
|
|
|
|
const actorUrl = query.url(actorEl, 'a', 'href', { origin: channel.url });
|
|
|
|
const entryId = new URL(url).pathname.match(/\/(\d+)/)?.[1];
|
2020-11-10 21:44:15 +00:00
|
|
|
const avatar = query.img(actorEl, 'img:not([data-bgsrc*="not-available"])', 'data-bgsrc');
|
2020-11-04 03:02:51 +00:00
|
|
|
|
|
|
|
return {
|
|
|
|
name: query.cnt(actorEl, '.video-performer-name'),
|
|
|
|
gender: 'female',
|
2020-11-10 21:44:15 +00:00
|
|
|
avatar: avatar && [
|
2020-11-04 03:02:51 +00:00
|
|
|
avatar.replace(/\/actor\/(\d+)/, '/actor/500'),
|
|
|
|
avatar,
|
|
|
|
],
|
|
|
|
url: actorUrl,
|
|
|
|
entryId,
|
|
|
|
};
|
|
|
|
})
|
|
|
|
.concat({ name: 'Jay Rock', gender: 'male' });
|
|
|
|
|
|
|
|
release.date = query.date('.release-date:first-child', 'MMM DD, YYYY', /\w+ \d{1,2}, \d{4}/);
|
|
|
|
release.duration = query.number('.release-date:last-child') * 60;
|
|
|
|
|
|
|
|
release.studio = query.cnt('.studio span:nth-child(2)');
|
|
|
|
release.director = query.text('.director');
|
|
|
|
|
|
|
|
release.tags = query.cnts('.tags a');
|
|
|
|
|
|
|
|
const poster = html.match(/url\((https.+\.jpg)\)/)?.[1];
|
|
|
|
const photos = query.imgs('#moreScreenshots img');
|
|
|
|
|
|
|
|
[release.poster, ...release.photos] = [poster]
|
|
|
|
.concat(photos)
|
|
|
|
.filter(Boolean)
|
|
|
|
.map(src => [
|
|
|
|
src.replace(/\/(\d+)\/\d+/, '/$1/1500'),
|
|
|
|
src.replace(/\/(\d+)\/\d+/, '/$1/1000'),
|
|
|
|
src,
|
|
|
|
]);
|
|
|
|
|
|
|
|
const videoId = html.match(/item: (\d+)/)?.[1];
|
|
|
|
|
|
|
|
if (videoId) {
|
|
|
|
release.trailer = { stream: `https://trailer.adultempire.com/hls/trailer/${videoId}/master.m3u8` };
|
2020-05-14 02:26:05 +00:00
|
|
|
}
|
2020-01-10 21:10:11 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
return release;
|
2020-01-10 21:10:11 +00:00
|
|
|
}
|
|
|
|
|
2020-11-04 03:02:51 +00:00
|
|
|
async function fetchLatest(channel, page = 1) {
|
|
|
|
const res = await qu.getAll(`https://jayspov.net/jays-pov-updates.html?view=list&page=${page}`, '.item-grid-list-view > .grid-item');
|
2020-01-10 21:10:11 +00:00
|
|
|
|
2020-11-04 03:02:51 +00:00
|
|
|
if (res.ok) {
|
|
|
|
return scrapeLatest(res.items, channel);
|
2020-05-14 02:26:05 +00:00
|
|
|
}
|
2020-01-10 21:10:11 +00:00
|
|
|
|
2020-11-04 03:02:51 +00:00
|
|
|
return res.status;
|
2020-01-10 21:10:11 +00:00
|
|
|
}
|
|
|
|
|
2020-11-04 03:02:51 +00:00
|
|
|
async function fetchScene(url, channel) {
|
|
|
|
const res = await qu.get(url);
|
2020-01-10 21:10:11 +00:00
|
|
|
|
2020-11-04 03:02:51 +00:00
|
|
|
if (res.ok) {
|
|
|
|
return scrapeScene(res.item, url, channel);
|
2020-05-14 02:26:05 +00:00
|
|
|
}
|
2020-01-10 21:10:11 +00:00
|
|
|
|
2020-11-04 03:02:51 +00:00
|
|
|
return res.status;
|
2020-01-10 21:10:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = {
|
2020-05-14 02:26:05 +00:00
|
|
|
fetchLatest,
|
2020-11-04 03:02:51 +00:00
|
|
|
fetchScene,
|
2020-01-10 21:10:11 +00:00
|
|
|
};
|