traxxx/src/scrapers/topwebmodels.js

61 lines
1.4 KiB
JavaScript
Raw Normal View History

2021-01-14 01:10:35 +00:00
'use strict';
const qu = require('../utils/qu');
const http = require('../utils/http');
const slugify = require('../utils/slugify');
function scrapeAll(scenes) {
return scenes.map((scene) => {
const release = {};
release.entryId = scene.id;
release.url = `https://tour.topwebmodels.com/scenes/${scene.id}/${slugify(scene.title)}`;
release.title = scene.title;
release.description = scene.description;
release.duration = qu.durationToSeconds(scene.videos_duration);
release.date = new Date(scene.release_date);
release.actors = scene.models.map(actor => ({
name: actor.name,
gender: actor.gender || null,
avatar: actor.thumb,
url: `https://tour.topwebmodels.com/models/${actor.id}/${slugify(actor.name)}`,
}));
release.stars = scene.rating;
release.tags = scene.tags.map(tag => tag.name);
release.poster = scene.thumb;
release.channel = slugify(scene.sites[0]?.name, '');
console.log(scene);
console.log(release);
return release;
});
}
async function fetchLatest(channel, page) {
const session = http.session();
await http.get(channel.url);
const res = await http.get(`https://tour.topwebmodels.com/api/sites/${channel.parameters?.slug || channel.slug}?page=${page}`, {
session,
});
console.log(res);
if (res.ok) {
return scrapeAll(res.body.videos.items);
}
return res.status;
}
module.exports = {
fetchLatest,
};