traxxx/src/scrapers/teamskeet.js

157 lines
4.2 KiB
JavaScript
Raw Normal View History

2020-01-12 04:30:46 +00:00
'use strict';
const qu = require('../utils/qu');
const http = require('../utils/http');
const slugify = require('../utils/slugify');
const { lbsToKg, feetInchesToCm } = require('../utils/convert');
2020-01-12 04:30:46 +00:00
function scrapeAll(scenes) {
return scenes.map((scene) => {
const release = {};
2020-01-12 04:30:46 +00:00
release.entryId = scene.id;
release.url = `https://teamskeet.com/movies/${release.entryId}`;
2020-01-12 04:30:46 +00:00
release.title = scene.title;
release.date = qu.extractDate(scene.publishedDate);
2020-01-12 04:30:46 +00:00
release.actors = scene.models?.map(model => model.modelName) || [];
2020-01-12 04:30:46 +00:00
release.poster = [
scene.img.replace('med.jpg', 'hi.jpg'),
scene.img,
];
2020-01-12 04:30:46 +00:00
release.teaser = scene.videoTrailer;
2020-01-12 04:30:46 +00:00
if (scene.video) {
release.trailer = { stream: `https://videodelivery.net/${scene.video}/manifest/video.mpd` };
}
2020-01-12 04:30:46 +00:00
release.likes = scene.stats.likeCount;
release.dislikes = scene.stats.dislikeCount;
2020-01-12 04:30:46 +00:00
release.channel = slugify(scene.site.name, '')
.replace('hobybuchanon', 'tshobybuchanon'); // slug collision with his own site
2020-01-12 04:30:46 +00:00
return release;
});
2020-01-12 04:30:46 +00:00
}
function scrapeScene(scene) {
const release = {};
2020-01-12 04:30:46 +00:00
release.entryId = scene.id;
2020-01-12 04:30:46 +00:00
release.title = scene.title;
release.description = scene.description;
2020-01-12 04:30:46 +00:00
release.date = qu.extractDate(scene.publishedDate);
release.actors = scene.models?.map(model => model.modelName) || [];
2020-01-12 04:30:46 +00:00
release.poster = [
scene.img.replace('med.jpg', 'hi.jpg'),
scene.img,
];
2020-01-12 04:30:46 +00:00
release.channel = slugify(scene.site.name, '')
.replace('hobybuchanon', 'tshobybuchanon'); // slug collision with his own site
2020-01-12 04:30:46 +00:00
if (scene.video) {
release.trailer = { stream: `https://videodelivery.net/${scene.video}/manifest/video.mpd` };
}
2020-01-12 04:30:46 +00:00
return release;
2020-01-12 04:30:46 +00:00
}
function scrapeProfile(actor) {
const profile = {};
2020-01-13 22:45:09 +00:00
// TODO: split bio https://store.psmcdn.net/ts-organic-iiiokv9kyo/modelsContent/valerie-white.json
if (actor.bio.about && !/\band\b/.test(actor.bio.about)) {
// birthdate seems never/rarely correct
const measurements = actor.bio.about.match(/Measurements: (\d+)(\w+)-(\d+)-(\d+)/i);
2020-01-13 22:45:09 +00:00
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);
2020-01-13 22:45:09 +00:00
if (breastSize) {
[profile.bust, profile.cup] = breastSize;
}
}
2020-01-13 22:45:09 +00:00
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];
2020-01-13 22:45:09 +00:00
const piercings = actor.bio.about.match(/Piercings: (\w+)/i)?.[1];
const tattoos = actor.bio.about.match(/Tattoos: (\w+)/i)?.[1];
2020-01-13 22:45:09 +00:00
if (slugify(piercings) === 'yes') profile.hasPiercings = true;
if (slugify(piercings) === 'no') profile.hasPiercings = false;
2020-01-13 22:45:09 +00:00
if (slugify(tattoos) === 'yes') profile.hasTattoos = true;
if (slugify(tattoos) === 'no') profile.hasTattoos = false;
}
2020-01-13 22:45:09 +00:00
if (actor.bio.heightFeet && actor.bio.heightInches) {
profile.height = feetInchesToCm(actor.bio.heightFeet, actor.bio.heightInches);
}
2020-01-13 22:45:09 +00:00
if (actor.bio.weight) {
profile.weight = lbsToKg(actor.bio.weight);
}
2020-01-13 22:45:09 +00:00
profile.avatar = actor.img;
profile.releases = scrapeAll(actor.movies);
2020-01-13 22:45:09 +00:00
return profile;
2020-01-13 22:45:09 +00:00
}
async function fetchLatest(channel, _page = 1) {
// freshman year, layna landry
if (!channel.parameters?.id) {
return null;
}
2020-01-12 04:30:46 +00:00
const url = `https://store.psmcdn.net/ts-organic-iiiokv9kyo/seriesContent/${channel.parameters.id}/latestMovies.json`;
const res = await http.get(url);
2020-01-13 22:45:09 +00:00
if (res.ok) {
return scrapeAll(Object.values(res.body), channel);
}
2020-01-13 22:45:09 +00:00
return res.status;
2020-01-13 22:45:09 +00:00
}
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);
2020-01-13 22:45:09 +00:00
if (res.ok) {
return scrapeScene(res.body, channel);
}
2020-01-13 22:45:09 +00:00
return res.status;
2020-01-13 22:45:09 +00:00
}
async function fetchProfile(baseActor) {
const res = await http.get(`https://store.psmcdn.net/ts-organic-iiiokv9kyo/modelsContent/${slugify(baseActor.name)}.json`);
2020-01-12 04:30:46 +00:00
if (res.ok && res.body) {
return scrapeProfile(res.body);
}
2020-01-13 22:45:09 +00:00
return res.status;
2020-01-12 04:30:46 +00:00
}
module.exports = {
fetchLatest,
fetchScene,
fetchProfile,
2020-01-12 04:30:46 +00:00
};