traxxx/src/scrapers/teamskeet.js

171 lines
4.4 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 && !/\band\b/.test(actor.bio.about)) {
const bio = actor.bio.about.split(/\n/).filter(Boolean).reduce((acc, item) => {
const [key, value] = item.match(/(.+): (.+)/).slice(1);
return { ...acc, [slugify(key, '_')]: value.trim() };
}, {});
// birthdate seems never/rarely correct
const measurements = bio.measurements?.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.birthPlace = bio.birth_location;
profile.nationality = bio.nationality;
profile.ethnicity = bio.ethnicity;
profile.hairColor = bio.hair_color;
const piercings = actor.bio.about.match(/Piercings: (\w+)/i)?.[1];
const tattoos = actor.bio.about.match(/Tattoos: (\w+)/i)?.[1];
if (/yes|various/i.test(piercings)) profile.hasPiercings = true;
else if (/no/i.test(piercings)) profile.hasPiercings = false;
else if (bio.piercings) {
profile.hasPiercings = true;
profile.piercings = piercings;
}
if (/yes|various/i.test(tattoos)) profile.hasTattoos = true;
else if (/no/i.test(tattoos)) profile.hasTattoos = false;
else if (bio.tattoos) {
profile.hasTattoos = true;
profile.tattoos = tattoos;
}
}
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,
};