forked from DebaucheryLibrarian/traxxx
71 lines
1.6 KiB
JavaScript
71 lines
1.6 KiB
JavaScript
'use strict';
|
|
|
|
const fs = require('fs').promises;
|
|
const bhttp = require('bhttp');
|
|
const slugify = require('../utils/slugify');
|
|
const { studios: oldStudios } = require('../../seeds/03_studios');
|
|
|
|
async function init() {
|
|
const res = await bhttp.get('https://pornbox.com/studio/list');
|
|
|
|
if (!res.statusCode === 200) {
|
|
throw new Error(`Failed to retrieve studios (${res.statusCode}): ${res.body.toString()}`);
|
|
}
|
|
|
|
const newStudios = res.body.map((studio) => {
|
|
const slug = slugify(studio.name, '');
|
|
const oldStudio = oldStudios.find((oldStudioX) => oldStudioX.slug === slug);
|
|
|
|
const tags = oldStudio?.tags || [];
|
|
|
|
const newStudio = {
|
|
name: studio.name,
|
|
slug,
|
|
url: `https://www.analvids.com/studios/${studio.alias}`,
|
|
parent: 'analvids',
|
|
};
|
|
|
|
if (oldStudio?.alias) {
|
|
newStudio.alias = oldStudio.alias;
|
|
}
|
|
|
|
if (studio.description && studio.description.toLowerCase() !== studio.name.toLowerCase()) {
|
|
newStudio.description = studio.description;
|
|
}
|
|
|
|
if (studio.directions?.includes('gay')) {
|
|
tags.push('gay');
|
|
}
|
|
|
|
if (studio.directions?.includes('lesbian')) {
|
|
tags.push('lesbian');
|
|
}
|
|
|
|
if (studio.directions?.includes('trans')) {
|
|
tags.push('transsexual');
|
|
}
|
|
|
|
if (tags.length > 0) {
|
|
newStudio.tags = Array.from(new Set(tags));
|
|
}
|
|
|
|
return newStudio;
|
|
});
|
|
|
|
await fs.writeFile('./analvids-studios.json', JSON.stringify(newStudios, null, 4));
|
|
|
|
newStudios.reduce((acc, studio) => {
|
|
if (acc.has(studio.slug)) {
|
|
console.log('slug already exists!', studio, studio.slug);
|
|
}
|
|
|
|
acc.add(studio.slug);
|
|
|
|
return acc;
|
|
}, new Set());
|
|
|
|
// console.log(newStudios);
|
|
}
|
|
|
|
init();
|