Added PurgatoryX scraper.

This commit is contained in:
DebaucheryLibrarian
2021-11-27 23:55:16 +01:00
parent 2539e88f47
commit 9d7183ac69
32 changed files with 196 additions and 16 deletions

View File

@@ -52,6 +52,12 @@ const parentNetworks = [
},
parent: 'gamma',
},
{
slug: 'radical',
alias: ['kb productions'],
name: 'Radical Entertainment',
url: 'https://radicalcash.com',
},
];
const networks = [
@@ -550,6 +556,7 @@ const networks = [
slug: 'topwebmodels',
name: 'Top Web Models',
url: 'https://tour.topwebmodels.com',
parent: 'radical',
parameters: {
apiKey: '5b637cd8c4bc59cd13686f1c38dcb780',
},
@@ -624,12 +631,12 @@ const networks = [
},
];
exports.seed = knex => Promise.resolve()
exports.seed = (knex) => Promise.resolve()
.then(async () => {
const grandParentNetworkEntries = await upsert('entities', grandParentNetworks.map(network => ({ ...network, type: 'network' })), ['slug', 'type'], knex);
const grandParentNetworkEntries = await upsert('entities', grandParentNetworks.map((network) => ({ ...network, type: 'network' })), ['slug', 'type'], knex);
const grandParentNetworksBySlug = [].concat(grandParentNetworkEntries.inserted, grandParentNetworkEntries.updated).reduce((acc, network) => ({ ...acc, [network.slug]: network.id }), {});
const parentNetworksWithGrandParent = parentNetworks.map(network => ({
const parentNetworksWithGrandParent = parentNetworks.map((network) => ({
slug: network.slug,
name: network.name,
type: network.type || 'network',
@@ -643,7 +650,7 @@ exports.seed = knex => Promise.resolve()
const parentNetworkEntries = await upsert('entities', parentNetworksWithGrandParent, ['slug', 'type'], knex);
const parentNetworksBySlug = [].concat(parentNetworkEntries.inserted, parentNetworkEntries.updated).reduce((acc, network) => ({ ...acc, [network.slug]: network.id }), {});
const networksWithParent = networks.map(network => ({
const networksWithParent = networks.map((network) => ({
slug: network.slug,
name: network.name,
type: network.type || 'network',
@@ -665,14 +672,14 @@ exports.seed = knex => Promise.resolve()
networkEntries.updated,
).reduce((acc, network) => ({ ...acc, [network.slug]: network.id }), {});
const tagSlugs = networks.map(network => network.tags).flat().filter(Boolean);
const tagSlugs = networks.map((network) => network.tags).flat().filter(Boolean);
const tagEntries = await knex('tags').whereIn('slug', tagSlugs);
const tagIdsBySlug = tagEntries.reduce((acc, tag) => ({ ...acc, [tag.slug]: tag.id }), {});
const tagAssociations = networks
.map(network => (network.tags
? network.tags.map(tagSlug => ({
.map((network) => (network.tags
? network.tags.map((tagSlug) => ({
entity_id: networkIdsBySlug[network.slug],
tag_id: tagIdsBySlug[tagSlug],
inherit: true,