Updated Kink channel inventory, separated Kink Men.
This commit is contained in:
@@ -6,13 +6,14 @@ const qu = require('../utils/qu');
|
||||
const http = require('../utils/http');
|
||||
const slugify = require('../utils/slugify');
|
||||
|
||||
function scrapeAll(scenes) {
|
||||
function scrapeAll(scenes, entity) {
|
||||
return scenes.map(({ query }) => {
|
||||
const release = {};
|
||||
const networkUrl = entity.type === 'channel' ? entity.parent.url : entity.url;
|
||||
|
||||
const href = query.url('.shoot-link');
|
||||
|
||||
release.url = `https://www.kink.com${href}`;
|
||||
release.url = `${networkUrl}${href}`;
|
||||
|
||||
release.shootId = href.split('/').slice(-1)[0];
|
||||
release.entryId = release.shootId;
|
||||
@@ -22,7 +23,7 @@ function scrapeAll(scenes) {
|
||||
|
||||
release.actors = query.all('.shoot-thumb-models a').map((actorEl) => ({
|
||||
name: unprint.query.content(actorEl),
|
||||
url: unprint.query.url(actorEl, null, { origin: 'https://www.kink.com' }),
|
||||
url: unprint.query.url(actorEl, null, { origin: networkUrl }),
|
||||
}));
|
||||
|
||||
release.rating = query.number('.thumb-ratings') / 10;
|
||||
@@ -39,7 +40,7 @@ function scrapeAll(scenes) {
|
||||
});
|
||||
}
|
||||
|
||||
function scrapeScene({ query }, url) {
|
||||
function scrapeScene({ query }, url, entity) {
|
||||
const release = { url };
|
||||
|
||||
release.shootId = new URL(url).pathname.split('/')[2];
|
||||
@@ -49,10 +50,12 @@ function scrapeScene({ query }, url) {
|
||||
release.description = query.content('.description-text');
|
||||
|
||||
release.date = query.date('.shoot-date', 'MMMM DD, YYYY');
|
||||
|
||||
release.actors = query.elements('.names a').map((actorEl) => ({
|
||||
name: unprint.query.content(actorEl).replace(/,\s*/, ''),
|
||||
url: unprint.query.url(actorEl, null, { origin: 'https://www.kink.com' }),
|
||||
url: unprint.query.url(actorEl, null, { origin: entity.type === 'channel' ? entity.parent.url : entity.url }),
|
||||
}));
|
||||
|
||||
release.director = query.content('.director-name');
|
||||
|
||||
release.photos = query.imgs('.gallery .thumb img, #gallerySlider .gallery-img', 'data-image-file');
|
||||
@@ -139,25 +142,29 @@ async function scrapeProfile({ query }, actorUrl, include) {
|
||||
profile.releases = await fetchActorReleases(actorUrl);
|
||||
}
|
||||
|
||||
console.log(profile);
|
||||
|
||||
return profile;
|
||||
}
|
||||
|
||||
async function fetchLatest(site, page = 1) {
|
||||
async function fetchLatest(channel, page = 1) {
|
||||
const { tab } = await http.getBrowserSession('kink');
|
||||
const res = await tab.goto(`https://www.kink.com/search?type=shoots&channelIds=${site.slug}&sort=published&page=${page}`);
|
||||
const res = await tab.goto(`${channel.parent.url}/search?type=shoots&channelIds=${channel.parameters?.slug || channel.slug}&sort=published&page=${page}`);
|
||||
const status = res.status();
|
||||
|
||||
if (status === 200) {
|
||||
const html = await tab.content();
|
||||
const items = unprint.initAll(html, '.results .shoot-card');
|
||||
|
||||
const scenes = scrapeAll(items, site);
|
||||
const scenes = scrapeAll(items, channel);
|
||||
|
||||
await tab.close();
|
||||
|
||||
return scenes;
|
||||
}
|
||||
|
||||
await tab.close();
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -178,24 +185,41 @@ async function fetchScene(url, channel) {
|
||||
return scene;
|
||||
}
|
||||
|
||||
await tab.close();
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
async function fetchProfile({ name: actorName }, entity, include) {
|
||||
const searchRes = await qu.getAll(`https://kink.com/search?type=performers&q=${actorName}`, '.model');
|
||||
async function fetchProfile({ name: actorName }, entity, options) {
|
||||
const networkUrl = entity.type === 'channel' ? entity.parent.url : entity.url;
|
||||
const { tab } = await http.getBrowserSession('kink');
|
||||
|
||||
if (searchRes.ok) {
|
||||
const actorItem = searchRes.items.find((item) => item.query.exists(`.model-link img[alt="${actorName}"]`));
|
||||
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}"]`));
|
||||
|
||||
if (actorItem) {
|
||||
const actorPath = actorItem.query.url('.model-link');
|
||||
const actorUrl = `https://kink.com${actorPath}`;
|
||||
const actorRes = await qu.get(actorUrl);
|
||||
const actorUrl = `${networkUrl}${actorPath}`;
|
||||
const actorRes = await tab.goto(actorUrl);
|
||||
const actorStatus = actorRes.status();
|
||||
|
||||
if (actorRes.ok) {
|
||||
return scrapeProfile(actorRes.item, actorUrl, include);
|
||||
if (actorStatus === 200) {
|
||||
const actorHtml = await tab.content();
|
||||
const item = unprint.init(actorHtml);
|
||||
|
||||
await tab.close();
|
||||
|
||||
return scrapeProfile(item, actorUrl, options);
|
||||
}
|
||||
|
||||
await tab.close();
|
||||
|
||||
return actorRes.status;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user