2019-03-24 04:28:18 +00:00
|
|
|
'use strict';
|
|
|
|
|
2022-12-28 00:34:12 +00:00
|
|
|
const unprint = require('unprint');
|
|
|
|
|
2022-10-25 21:13:24 +00:00
|
|
|
const http = require('../utils/http');
|
2022-12-28 00:34:12 +00:00
|
|
|
const slugify = require('../utils/slugify');
|
2020-06-27 00:57:30 +00:00
|
|
|
|
2022-12-31 16:50:39 +00:00
|
|
|
function scrapeAll(scenes, entity) {
|
2020-07-12 22:12:01 +00:00
|
|
|
return scenes.map(({ query }) => {
|
2020-06-27 00:57:30 +00:00
|
|
|
const release = {};
|
2022-12-31 16:50:39 +00:00
|
|
|
const networkUrl = entity.type === 'channel' ? entity.parent.url : entity.url;
|
2020-06-27 00:57:30 +00:00
|
|
|
|
2022-12-28 00:34:12 +00:00
|
|
|
const href = query.url('.shoot-link');
|
|
|
|
|
2022-12-31 16:50:39 +00:00
|
|
|
release.url = `${networkUrl}${href}`;
|
2020-06-27 00:57:30 +00:00
|
|
|
|
|
|
|
release.shootId = href.split('/').slice(-1)[0];
|
|
|
|
release.entryId = release.shootId;
|
|
|
|
|
2022-12-28 00:34:12 +00:00
|
|
|
release.title = query.content('.shoot-thumb-title a', true);
|
2020-07-12 22:12:01 +00:00
|
|
|
release.date = query.date('.date', 'MMM DD, YYYY');
|
2020-06-27 00:57:30 +00:00
|
|
|
|
2022-12-28 00:34:12 +00:00
|
|
|
release.actors = query.all('.shoot-thumb-models a').map((actorEl) => ({
|
|
|
|
name: unprint.query.content(actorEl),
|
2022-12-31 16:50:39 +00:00
|
|
|
url: unprint.query.url(actorEl, null, { origin: networkUrl }),
|
2022-12-28 00:34:12 +00:00
|
|
|
}));
|
|
|
|
|
|
|
|
release.rating = query.number('.thumb-ratings') / 10;
|
2020-06-27 00:57:30 +00:00
|
|
|
|
2020-07-12 22:12:01 +00:00
|
|
|
release.poster = query.img('.adimage');
|
2022-12-28 00:34:12 +00:00
|
|
|
release.photos = query.imgs('.rollover .roll-image', { attribute: 'data-imagesrc' }).map((photo) => [
|
2023-05-30 22:29:54 +00:00
|
|
|
photo
|
|
|
|
.replace('410/', '830/')
|
|
|
|
.replace('_thumb', '_full'),
|
2020-06-27 00:57:30 +00:00
|
|
|
photo,
|
|
|
|
]);
|
|
|
|
|
2023-07-01 23:04:39 +00:00
|
|
|
release.trailer = `https://cdnp.kink.com/imagedb/${release.entryId}/trailer/${release.entryId}_trailer_high.mp4`;
|
|
|
|
|
2020-07-12 22:12:01 +00:00
|
|
|
release.duration = query.dur('.video span');
|
2020-06-27 00:57:30 +00:00
|
|
|
|
|
|
|
return release;
|
2020-05-14 02:26:05 +00:00
|
|
|
});
|
2019-03-24 04:28:18 +00:00
|
|
|
}
|
|
|
|
|
2022-12-31 16:50:39 +00:00
|
|
|
function scrapeScene({ query }, url, entity) {
|
2020-06-27 00:57:30 +00:00
|
|
|
const release = { url };
|
|
|
|
|
|
|
|
release.shootId = new URL(url).pathname.split('/')[2];
|
|
|
|
release.entryId = release.shootId;
|
|
|
|
|
2022-12-28 00:34:12 +00:00
|
|
|
release.title = query.attribute('.shoot-title .favorite-button', 'data-title') || query.content('.shoot-title');
|
|
|
|
release.description = query.content('.description-text');
|
2020-06-27 00:57:30 +00:00
|
|
|
|
2020-07-12 22:12:01 +00:00
|
|
|
release.date = query.date('.shoot-date', 'MMMM DD, YYYY');
|
2022-12-31 16:50:39 +00:00
|
|
|
|
2022-12-28 00:34:12 +00:00
|
|
|
release.actors = query.elements('.names a').map((actorEl) => ({
|
|
|
|
name: unprint.query.content(actorEl).replace(/,\s*/, ''),
|
2022-12-31 16:50:39 +00:00
|
|
|
url: unprint.query.url(actorEl, null, { origin: entity.type === 'channel' ? entity.parent.url : entity.url }),
|
2022-12-28 00:34:12 +00:00
|
|
|
}));
|
2022-12-31 16:50:39 +00:00
|
|
|
|
2022-12-28 00:34:12 +00:00
|
|
|
release.director = query.content('.director-name');
|
2020-06-27 00:57:30 +00:00
|
|
|
|
2023-05-30 22:29:54 +00:00
|
|
|
release.photos = query.imgs('.gallery .thumb img, #gallerySlider .gallery-img', { attribute: 'data-image-file' });
|
2020-07-12 22:12:01 +00:00
|
|
|
release.poster = query.poster();
|
2023-07-01 23:04:39 +00:00
|
|
|
release.trailer = query.dataset('.player span[data-type="trailer-src"]', 'url') || `https://cdnp.kink.com/imagedb/${release.entryId}/trailer/${release.entryId}_trailer_high.mp4`;
|
2020-06-27 00:57:30 +00:00
|
|
|
|
2022-12-28 00:34:12 +00:00
|
|
|
release.tags = query.contents('.tag-list a[href*="/tag"]').map((tag) => tag.replace(/,\s*/, ''));
|
2020-06-27 00:57:30 +00:00
|
|
|
|
2022-12-28 00:34:12 +00:00
|
|
|
release.channel = slugify(query.url('.shoot-logo a')?.split('/').slice(-1)[0], '');
|
|
|
|
|
2020-06-27 00:57:30 +00:00
|
|
|
return release;
|
2019-03-24 04:28:18 +00:00
|
|
|
}
|
|
|
|
|
2023-01-01 23:54:10 +00:00
|
|
|
async function fetchActorReleases(actorId, entity, page = 1, accReleases = []) {
|
|
|
|
const networkUrl = entity.type === 'channel' ? entity.parent.url : entity.url;
|
|
|
|
const { tab } = await http.getBrowserSession('kink');
|
|
|
|
const res = await tab.goto(`${networkUrl}/search?type=shoots&performerIds=${actorId}&sort=published&page=${page}`);
|
2020-07-12 22:12:01 +00:00
|
|
|
|
2023-01-01 23:54:10 +00:00
|
|
|
if (res.status() === 200) {
|
|
|
|
const html = await tab.content();
|
|
|
|
const item = unprint.init(html);
|
|
|
|
const releases = scrapeAll(unprint.initAll(html, '.results .shoot-card'), entity);
|
|
|
|
const hasNextPage = item.query.exists('.paginated-nav li:last-child:not(.disabled)');
|
|
|
|
|
|
|
|
await tab.close();
|
2020-07-12 22:12:01 +00:00
|
|
|
|
|
|
|
if (hasNextPage) {
|
2023-01-01 23:54:10 +00:00
|
|
|
return fetchActorReleases(actorId, entity, page + 1, accReleases.concat(releases));
|
2020-07-12 22:12:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return accReleases.concat(releases);
|
|
|
|
}
|
|
|
|
|
2023-01-01 23:54:10 +00:00
|
|
|
await tab.close();
|
|
|
|
|
2020-07-12 22:12:01 +00:00
|
|
|
return accReleases;
|
|
|
|
}
|
|
|
|
|
2023-01-01 23:54:10 +00:00
|
|
|
async function scrapeProfile({ query }, actorUrl, entity, include) {
|
2020-07-12 22:12:01 +00:00
|
|
|
const profile = {};
|
|
|
|
|
2023-01-01 23:54:10 +00:00
|
|
|
profile.entryId = actorUrl.match(/\/model\/(\d+)\//)?.[1] || query.attribute('.favorite-button.bio-favorite', 'data-id');
|
|
|
|
profile.description = query.content('.bio-outer #expand-text');
|
2020-07-12 22:12:01 +00:00
|
|
|
|
2023-01-01 23:54:10 +00:00
|
|
|
const tags = query.contents('.bio-tags a').map((tag) => tag.toLowerCase());
|
2020-07-12 22:12:01 +00:00
|
|
|
|
|
|
|
if (tags.includes('brunette') || tags.includes('brunet')) profile.hairColor = 'brown';
|
|
|
|
if (tags.includes('blonde') || tags.includes('blond')) profile.hairColor = 'blonde';
|
|
|
|
if (tags.includes('black hair')) profile.hairColor = 'black';
|
|
|
|
if (tags.includes('redhead')) profile.hairColor = 'red';
|
|
|
|
|
|
|
|
if (tags.includes('natural boobs')) profile.naturalBoobs = true;
|
|
|
|
if (tags.includes('fake boobs')) profile.naturalBoobs = false;
|
|
|
|
|
|
|
|
if (tags.includes('white')) profile.ethnicity = 'white';
|
|
|
|
if (tags.includes('latin')) profile.ethnicity = 'latin';
|
|
|
|
if (tags.includes('Black')) profile.ethnicity = 'black';
|
|
|
|
|
|
|
|
if (tags.includes('pierced nipples')) profile.hasPiercings = true;
|
|
|
|
if (tags.includes('tattoo')) profile.hasTattoos = true;
|
|
|
|
|
|
|
|
if (tags.includes('foreskin')) profile.hasForeskin = true;
|
|
|
|
|
|
|
|
if ((tags.includes('big dick') || tags.includes('foreskin'))
|
|
|
|
&& (tags.includes('fake boobs') || tags.includes('big tits'))) profile.gender = 'transsexual';
|
|
|
|
|
|
|
|
profile.avatar = query.img('.bio-slider-img, .bio-img:not([src*="Missing"])');
|
|
|
|
profile.social = query.urls('a.social-link');
|
|
|
|
|
2023-01-01 23:54:10 +00:00
|
|
|
if (include.releases && profile.entryId) {
|
|
|
|
profile.releases = await fetchActorReleases(profile.entryId, entity);
|
2020-07-12 22:12:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return profile;
|
|
|
|
}
|
|
|
|
|
2022-12-31 16:50:39 +00:00
|
|
|
async function fetchLatest(channel, page = 1) {
|
2022-12-28 22:06:08 +00:00
|
|
|
const { tab } = await http.getBrowserSession('kink');
|
2022-12-31 16:50:39 +00:00
|
|
|
const res = await tab.goto(`${channel.parent.url}/search?type=shoots&channelIds=${channel.parameters?.slug || channel.slug}&sort=published&page=${page}`);
|
2022-12-28 00:34:12 +00:00
|
|
|
const status = res.status();
|
|
|
|
|
|
|
|
if (status === 200) {
|
|
|
|
const html = await tab.content();
|
|
|
|
const items = unprint.initAll(html, '.results .shoot-card');
|
2022-10-25 21:13:24 +00:00
|
|
|
|
2022-12-31 16:50:39 +00:00
|
|
|
const scenes = scrapeAll(items, channel);
|
2022-10-25 21:13:24 +00:00
|
|
|
|
2022-12-28 00:34:12 +00:00
|
|
|
await tab.close();
|
|
|
|
|
|
|
|
return scenes;
|
|
|
|
}
|
|
|
|
|
2022-12-31 16:50:39 +00:00
|
|
|
await tab.close();
|
|
|
|
|
2022-12-28 00:34:12 +00:00
|
|
|
return status;
|
2022-10-25 21:13:24 +00:00
|
|
|
}
|
|
|
|
|
2022-12-28 00:34:12 +00:00
|
|
|
async function fetchScene(url, channel) {
|
|
|
|
const { tab } = await http.getBrowserSession('kink');
|
|
|
|
const res = await tab.goto(url);
|
2020-06-27 00:57:30 +00:00
|
|
|
|
2022-12-28 00:34:12 +00:00
|
|
|
const status = res.status();
|
2022-10-25 21:13:24 +00:00
|
|
|
|
2022-12-28 00:34:12 +00:00
|
|
|
if (status === 200) {
|
|
|
|
const html = await tab.content();
|
|
|
|
const item = unprint.init(html);
|
|
|
|
|
|
|
|
const scene = scrapeScene(item, url, channel);
|
|
|
|
|
|
|
|
await tab.close();
|
|
|
|
|
|
|
|
return scene;
|
2020-06-27 00:57:30 +00:00
|
|
|
}
|
2019-03-24 04:28:18 +00:00
|
|
|
|
2022-12-31 16:50:39 +00:00
|
|
|
await tab.close();
|
|
|
|
|
2022-12-28 00:34:12 +00:00
|
|
|
return status;
|
2019-03-24 04:28:18 +00:00
|
|
|
}
|
|
|
|
|
2022-12-31 16:50:39 +00:00
|
|
|
async function fetchProfile({ name: actorName }, entity, options) {
|
|
|
|
const networkUrl = entity.type === 'channel' ? entity.parent.url : entity.url;
|
|
|
|
const { tab } = await http.getBrowserSession('kink');
|
2020-07-12 22:12:01 +00:00
|
|
|
|
2022-12-31 16:50:39 +00:00
|
|
|
const searchRes = await tab.goto(`${networkUrl}/search?type=performers&q=${actorName}`);
|
|
|
|
const searchStatus = searchRes.status();
|
|
|
|
|
|
|
|
if (searchStatus === 200) {
|
|
|
|
const searchHtml = await tab.content();
|
|
|
|
|
|
|
|
const searchResItems = unprint.initAll(searchHtml, '.model');
|
|
|
|
const actorItem = searchResItems.find((item) => item.query.exists(`.model-link img[alt="${actorName}"]`));
|
2020-07-12 22:12:01 +00:00
|
|
|
|
|
|
|
if (actorItem) {
|
|
|
|
const actorPath = actorItem.query.url('.model-link');
|
2022-12-31 16:50:39 +00:00
|
|
|
const actorUrl = `${networkUrl}${actorPath}`;
|
|
|
|
const actorRes = await tab.goto(actorUrl);
|
|
|
|
const actorStatus = actorRes.status();
|
|
|
|
|
|
|
|
if (actorStatus === 200) {
|
|
|
|
const actorHtml = await tab.content();
|
|
|
|
const item = unprint.init(actorHtml);
|
2020-07-12 22:12:01 +00:00
|
|
|
|
2022-12-31 16:50:39 +00:00
|
|
|
await tab.close();
|
|
|
|
|
2023-01-01 23:54:10 +00:00
|
|
|
return scrapeProfile(item, actorUrl, entity, options);
|
2020-07-12 22:12:01 +00:00
|
|
|
}
|
|
|
|
|
2022-12-31 16:50:39 +00:00
|
|
|
await tab.close();
|
|
|
|
|
2020-07-12 22:12:01 +00:00
|
|
|
return actorRes.status;
|
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
return searchRes.status;
|
|
|
|
}
|
|
|
|
|
2019-03-24 04:28:18 +00:00
|
|
|
module.exports = {
|
2022-12-28 00:34:12 +00:00
|
|
|
// beforeNetwork,
|
2020-05-14 02:26:05 +00:00
|
|
|
fetchLatest,
|
2022-12-28 00:34:12 +00:00
|
|
|
fetchScene,
|
2020-07-12 22:12:01 +00:00
|
|
|
fetchProfile,
|
2019-03-24 04:28:18 +00:00
|
|
|
};
|