forked from DebaucheryLibrarian/traxxx
Added ManyVids API seed.
This commit is contained in:
@@ -762,6 +762,11 @@ const tags = [
|
||||
slug: 'high-heels',
|
||||
group: 'clothing',
|
||||
},
|
||||
{
|
||||
name: 'hotel',
|
||||
slug: 'hotel',
|
||||
group: 'location',
|
||||
},
|
||||
{
|
||||
name: 'humiliation',
|
||||
slug: 'humiliation',
|
||||
|
||||
@@ -7698,6 +7698,7 @@ const sites = [
|
||||
url: 'https://nicoledoshi.manyvids.com',
|
||||
hasLogo: false,
|
||||
parent: 'manyvids',
|
||||
delete: true,
|
||||
},
|
||||
// MARISKA X
|
||||
{
|
||||
|
||||
56
seeds/09_manyvids.js
Normal file
56
seeds/09_manyvids.js
Normal file
@@ -0,0 +1,56 @@
|
||||
'use strict';
|
||||
|
||||
const unprint = require('unprint');
|
||||
const slugify = require('../src/utils/slugify');
|
||||
|
||||
const limit = Number(process.env.MV_LIMIT) || 1000;
|
||||
|
||||
async function fetchCreators(page = 1, acc = []) {
|
||||
console.log(`Fetching creators ${acc.length}/${limit}`);
|
||||
|
||||
// size seems to be capped at 70
|
||||
const res = await unprint.get(`https://api.manyvids.com/search/creators/list?contentPref=1,2,3&sort=top&size=50&from=${(page - 1) * 50}`);
|
||||
|
||||
if (res.ok && res.data?.creators) {
|
||||
const creators = acc.concat(res.data.creators.map((creator) => ({
|
||||
name: creator.stageName,
|
||||
slug: `mv.${slugify(creator.slug, '')}`,
|
||||
url: `https://www.manyvids.com/Profile/${creator.id}/${creator.slug}/`,
|
||||
emblem: creator.avatar?.url || null,
|
||||
})));
|
||||
|
||||
if (creators.length >= limit) {
|
||||
return creators;
|
||||
}
|
||||
|
||||
return fetchCreators(page + 1, creators);
|
||||
}
|
||||
|
||||
return acc;
|
||||
}
|
||||
|
||||
exports.seed = async function (knex) {
|
||||
const channels = await fetchCreators();
|
||||
|
||||
const manyvidsNetwork = await knex('entities')
|
||||
.where('slug', 'manyvids')
|
||||
.where('type', 'network')
|
||||
.first();
|
||||
|
||||
if (!manyvidsNetwork) {
|
||||
throw new Error('ManyVids found, did the network migration run?');
|
||||
}
|
||||
|
||||
await knex('entities')
|
||||
.insert(channels.map((channel) => ({
|
||||
name: channel.name,
|
||||
slug: channel.slug,
|
||||
url: channel.url,
|
||||
parent_id: manyvidsNetwork.id,
|
||||
has_logo: false,
|
||||
})))
|
||||
.onConflict(['slug', 'type'])
|
||||
.merge(['name', 'url']);
|
||||
|
||||
console.log(`Done! ${channels.length} ManyVids creators added as channels`);
|
||||
};
|
||||
Reference in New Issue
Block a user