forked from DebaucheryLibrarian/traxxx
101 lines
2.3 KiB
JavaScript
101 lines
2.3 KiB
JavaScript
'use strict';
|
|
|
|
const { get, getAll } = require('../utils/qu');
|
|
|
|
function scrapeLatest(scenes) {
|
|
return scenes.map(({ qu }) => {
|
|
const release = {};
|
|
|
|
const href = qu.url('.shoot-thumb-title a');
|
|
release.url = `https://kink.com${href}`;
|
|
|
|
release.shootId = href.split('/').slice(-1)[0];
|
|
release.entryId = release.shootId;
|
|
|
|
release.title = qu.q('.shoot-thumb-title a', true);
|
|
release.date = qu.date('.date', 'MMM DD, YYYY');
|
|
|
|
release.actors = qu.all('.shoot-thumb-models a', true);
|
|
release.stars = qu.q('.average-rating', 'data-rating') / 10;
|
|
|
|
release.poster = qu.img('.adimage');
|
|
release.photos = qu.imgs('.rollover .roll-image', 'data-imagesrc').map(photo => [
|
|
photo.replace('410/', '830/'),
|
|
photo,
|
|
]);
|
|
|
|
release.duration = qu.dur('.video span');
|
|
|
|
return release;
|
|
});
|
|
}
|
|
|
|
async function scrapeScene({ qu }, url) {
|
|
const release = { url };
|
|
|
|
release.shootId = new URL(url).pathname.split('/')[2];
|
|
release.entryId = release.shootId;
|
|
|
|
release.title = qu.q('.shoot-title span.favorite-button', 'data-title');
|
|
release.description = qu.q('.description-text', true);
|
|
|
|
release.date = qu.date('.shoot-date', 'MMMM DD, YYYY');
|
|
release.actors = qu.all('.names a', true).map(actor => actor.replace(/,\s*/, ''));
|
|
release.director = qu.q('.director-name', true);
|
|
|
|
release.photos = qu.imgs('.gallery .thumb img', 'data-image-file');
|
|
release.poster = qu.poster();
|
|
|
|
release.tags = qu.all('.tag-list a[href*="/tag"]', true).map(tag => tag.replace(/,\s*/, ''));
|
|
|
|
const trailer = qu.q('.player span[data-type="trailer-src"]', 'data-url');
|
|
|
|
release.trailer = [
|
|
{
|
|
src: trailer.replace('480p', '1080p'),
|
|
quality: 1080,
|
|
},
|
|
{
|
|
src: trailer.replace('480p', '720p'),
|
|
quality: 720,
|
|
},
|
|
{
|
|
src: trailer,
|
|
quality: 480,
|
|
},
|
|
{
|
|
src: trailer.replace('480p', '360p'),
|
|
quality: 360,
|
|
},
|
|
];
|
|
|
|
release.channel = qu.url('.shoot-logo a').split('/').slice(-1)[0];
|
|
|
|
return release;
|
|
}
|
|
|
|
async function fetchLatest(site, page = 1) {
|
|
const res = await getAll(`${site.url}/latest/page/${page}`, '.shoot-list .shoot');
|
|
|
|
if (res.ok) {
|
|
return scrapeLatest(res.items, site);
|
|
}
|
|
|
|
return res.status;
|
|
}
|
|
|
|
async function fetchScene(url, site) {
|
|
const res = await get(url);
|
|
|
|
if (res.ok) {
|
|
return scrapeScene(res.item, url, site);
|
|
}
|
|
|
|
return res.status;
|
|
}
|
|
|
|
module.exports = {
|
|
fetchLatest,
|
|
fetchScene,
|
|
};
|