156 lines
4.1 KiB
JavaScript
156 lines
4.1 KiB
JavaScript
'use strict';
|
|
|
|
const qu = require('../utils/qu');
|
|
const http = require('../utils/http');
|
|
const slugify = require('../utils/slugify');
|
|
const { lbsToKg, feetInchesToCm } = require('../utils/convert');
|
|
|
|
function scrapeAll(scenes) {
|
|
return scenes.map((scene) => {
|
|
const release = {};
|
|
|
|
release.entryId = scene.id;
|
|
release.url = `https://teamskeet.com/movies/${release.entryId}`;
|
|
|
|
release.title = scene.title;
|
|
release.date = qu.extractDate(scene.publishedDate);
|
|
|
|
release.actors = scene.models?.map(model => model.modelName) || [];
|
|
|
|
release.poster = [
|
|
scene.img.replace('med.jpg', 'hi.jpg'),
|
|
scene.img,
|
|
];
|
|
|
|
release.teaser = scene.videoTrailer;
|
|
|
|
if (scene.video) {
|
|
release.trailer = { stream: `https://videodelivery.net/${scene.video}/manifest/video.mpd` };
|
|
}
|
|
|
|
release.likes = scene.stats.likeCount;
|
|
release.dislikes = scene.stats.dislikeCount;
|
|
|
|
release.channel = slugify(scene.site.name, '')
|
|
.replace('hobybuchanon', 'tshobybuchanon'); // slug collision with his own site
|
|
|
|
return release;
|
|
});
|
|
}
|
|
|
|
function scrapeScene(scene) {
|
|
const release = {};
|
|
|
|
release.entryId = scene.id;
|
|
|
|
release.title = scene.title;
|
|
release.description = scene.description;
|
|
|
|
release.date = qu.extractDate(scene.publishedDate);
|
|
release.actors = scene.models?.map(model => model.modelName) || [];
|
|
|
|
release.poster = [
|
|
scene.img.replace('med.jpg', 'hi.jpg'),
|
|
scene.img,
|
|
];
|
|
|
|
release.channel = slugify(scene.site.name, '')
|
|
.replace('hobybuchanon', 'tshobybuchanon'); // slug collision with his own site
|
|
|
|
if (scene.video) {
|
|
release.trailer = { stream: `https://videodelivery.net/${scene.video}/manifest/video.mpd` };
|
|
}
|
|
|
|
return release;
|
|
}
|
|
|
|
function scrapeProfile(actor) {
|
|
const profile = {};
|
|
|
|
if (actor.bio.about) {
|
|
// birthdate seems never/rarely correct
|
|
const measurements = actor.bio.about.match(/Measurements: (\d+)(\w+)-(\d+)-(\d+)/i);
|
|
|
|
if (measurements) {
|
|
[profile.bust, profile.cup, profile.waist, profile.hip] = measurements.slice(1);
|
|
} else {
|
|
const breastSize = actor.bio.breastSize?.match(/(\d+)(\w+)/)?.slice(1) || actor.bio.about.match(/Measurements: (\d+)(\w+)/)?.slice(1);
|
|
|
|
if (breastSize) {
|
|
[profile.bust, profile.cup] = breastSize;
|
|
}
|
|
}
|
|
|
|
profile.nationality = actor.bio.about.match(/Nationality: (\w+)/i)?.[1];
|
|
profile.ethnicity = actor.bio.about.match(/Ethnicity: (\w+)/i)?.[1];
|
|
profile.hairColor = actor.bio.about.match(/Hair Color: (\w+)/i)?.[1];
|
|
|
|
const piercings = actor.bio.about.match(/Piercings: (\w+)/i)?.[1];
|
|
const tattoos = actor.bio.about.match(/Tattoos: (\w+)/i)?.[1];
|
|
|
|
if (slugify(piercings) === 'yes') profile.hasPiercings = true;
|
|
if (slugify(piercings) === 'no') profile.hasPiercings = false;
|
|
|
|
if (slugify(tattoos) === 'yes') profile.hasTattoos = true;
|
|
if (slugify(tattoos) === 'no') profile.hasTattoos = false;
|
|
}
|
|
|
|
if (actor.bio.heightFeet && actor.bio.heightInches) {
|
|
profile.height = feetInchesToCm(actor.bio.heightFeet, actor.bio.heightInches);
|
|
}
|
|
|
|
if (actor.bio.weight) {
|
|
profile.weight = lbsToKg(actor.bio.weight);
|
|
}
|
|
|
|
profile.avatar = actor.img;
|
|
profile.releases = scrapeAll(actor.movies);
|
|
|
|
return profile;
|
|
}
|
|
|
|
async function fetchLatest(channel, _page = 1) {
|
|
// freshman year, layna landry
|
|
if (!channel.parameters?.id) {
|
|
return null;
|
|
}
|
|
|
|
const url = `https://store.psmcdn.net/ts-organic-iiiokv9kyo/seriesContent/${channel.parameters.id}/latestMovies.json`;
|
|
const res = await http.get(url);
|
|
|
|
if (res.ok) {
|
|
return scrapeAll(Object.values(res.body), channel);
|
|
}
|
|
|
|
return res.status;
|
|
}
|
|
|
|
async function fetchScene(url, channel) {
|
|
const entryId = new URL(url).pathname.match(/\/movies\/(.+)$/)[1];
|
|
const apiUrl = `https://store.psmcdn.net/ts-organic-iiiokv9kyo/videosContent/${entryId}.json`;
|
|
|
|
const res = await http.get(apiUrl);
|
|
|
|
if (res.ok) {
|
|
return scrapeScene(res.body, channel);
|
|
}
|
|
|
|
return res.status;
|
|
}
|
|
|
|
async function fetchProfile(baseActor) {
|
|
const res = await http.get(`https://store.psmcdn.net/ts-organic-iiiokv9kyo/modelsContent/${slugify(baseActor.name)}.json`);
|
|
|
|
if (res.ok && res.body) {
|
|
return scrapeProfile(res.body);
|
|
}
|
|
|
|
return res.status;
|
|
}
|
|
|
|
module.exports = {
|
|
fetchLatest,
|
|
fetchScene,
|
|
fetchProfile,
|
|
};
|