Compare commits
26 Commits
4f13e4ed28
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
186f9660c3 | ||
|
|
ef7c24ab47 | ||
|
|
1b6aaafe10 | ||
|
|
31aa1118e7 | ||
|
|
74d03b7483 | ||
|
|
40ea7eb80a | ||
|
|
0d30115ad5 | ||
|
|
0560fac1ff | ||
|
|
108bf3b168 | ||
|
|
155e235246 | ||
|
|
bff665c6ec | ||
|
|
c7111329dc | ||
|
|
d7c1c0ae5c | ||
|
|
ea298d7edb | ||
|
|
99dfcae920 | ||
|
|
24cba1e1fa | ||
|
|
076bdad310 | ||
|
|
d432d291dd | ||
|
|
220f7e787d | ||
|
|
f1caa77e4b | ||
|
|
ff633436cb | ||
|
|
6860072a51 | ||
|
|
2c7b4cfc22 | ||
|
|
7d9e1be8d4 | ||
|
|
00db4b1b5b | ||
|
|
9f1cf1575a |
@@ -27,7 +27,7 @@
|
||||
"require-await": "off",
|
||||
"no-param-reassign": ["error", {
|
||||
"props": true,
|
||||
"ignorePropertyModificationsFor": ["state", "acc", "req"]
|
||||
"ignorePropertyModificationsFor": ["state", "acc", "req", "error"]
|
||||
}]
|
||||
},
|
||||
"globals": {
|
||||
|
||||
@@ -188,6 +188,8 @@ module.exports = {
|
||||
'wishescumtrue',
|
||||
// hentaied
|
||||
'somegore',
|
||||
// digital playground
|
||||
'digitalplayground', // no longer updates, produces a bunch of garbage for some reason
|
||||
],
|
||||
networks: [
|
||||
// dummy network for testing
|
||||
@@ -279,7 +281,7 @@ module.exports = {
|
||||
trailerQuality: [540, 720, 960, 480, 1080, 360, 320, 1440, 1600, 1920, 2160, 270, 240, 180],
|
||||
limit: 25, // max number of photos per release
|
||||
attempts: 2,
|
||||
flushOrphaned: true,
|
||||
flushOrphaned: false,
|
||||
flushWindow: 1000,
|
||||
streams: {
|
||||
enabled: true, // fetch streams
|
||||
|
||||
21
migrations/20260304020542_scene_actor_tags.js
Normal file
21
migrations/20260304020542_scene_actor_tags.js
Normal file
@@ -0,0 +1,21 @@
|
||||
exports.up = async function(knex) {
|
||||
await knex.schema.alterTable('releases_tags', (table) => {
|
||||
table.integer('actor_id')
|
||||
.references('id')
|
||||
.inTable('actors');
|
||||
|
||||
table.dropUnique(['tag_id', 'release_id']);
|
||||
});
|
||||
|
||||
await knex.raw('CREATE UNIQUE INDEX releases_tags_tag_id_release_id_actor_id ON releases_tags (tag_id, release_id, COALESCE(actor_id, -1))');
|
||||
};
|
||||
|
||||
exports.down = async function(knex) {
|
||||
await knex.schema.alterTable('releases_tags', (table) => {
|
||||
table.dropColumn('actor_id');
|
||||
|
||||
table.unique(['tag_id', 'release_id']);
|
||||
});
|
||||
|
||||
await knex.raw('DROP INDEX IF EXISTS releases_tags_tag_id_release_id_actor_id');
|
||||
};
|
||||
4
package-lock.json
generated
4
package-lock.json
generated
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "traxxx",
|
||||
"version": "1.250.29",
|
||||
"version": "1.250.41",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "traxxx",
|
||||
"version": "1.250.29",
|
||||
"version": "1.250.41",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"@aws-sdk/client-s3": "^3.458.0",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "traxxx",
|
||||
"version": "1.250.29",
|
||||
"version": "1.250.41",
|
||||
"description": "All the latest porn releases in one place",
|
||||
"main": "src/app.js",
|
||||
"scripts": {
|
||||
|
||||
@@ -2,6 +2,14 @@
|
||||
const omit = require('object.omit');
|
||||
|
||||
const upsert = require('../src/utils/upsert');
|
||||
const redis = require('../src/redis');
|
||||
|
||||
const entityPrefixes = {
|
||||
channel: '',
|
||||
network: '_',
|
||||
studio: '*',
|
||||
info: '@',
|
||||
};
|
||||
|
||||
const grandParentNetworks = [
|
||||
{
|
||||
@@ -905,80 +913,88 @@ const networks = [
|
||||
},
|
||||
];
|
||||
|
||||
exports.seed = (knex) => Promise.resolve()
|
||||
.then(async () => {
|
||||
await Promise.all([].concat(grandParentNetworks, parentNetworks, networks).map(async (network) => {
|
||||
if (network.rename) {
|
||||
return knex('entities')
|
||||
.where({
|
||||
type: network.type || 'network',
|
||||
slug: network.rename,
|
||||
})
|
||||
.update('slug', network.slug);
|
||||
}
|
||||
exports.seed = async (knex) => {
|
||||
await Promise.all([].concat(grandParentNetworks, parentNetworks, networks).map(async (network) => {
|
||||
if (network.rename) {
|
||||
return knex('entities')
|
||||
.where({
|
||||
type: network.type || 'network',
|
||||
slug: network.rename,
|
||||
})
|
||||
.update('slug', network.slug);
|
||||
}
|
||||
|
||||
return null;
|
||||
}).filter(Boolean));
|
||||
return null;
|
||||
}).filter(Boolean));
|
||||
|
||||
const grandParentNetworkEntries = await upsert('entities', grandParentNetworks.map((network) => (omit({ ...network, type: 'network' }, 'rename'))), ['slug', 'type'], knex);
|
||||
const grandParentNetworksBySlug = [].concat(grandParentNetworkEntries.inserted, grandParentNetworkEntries.updated).reduce((acc, network) => ({ ...acc, [network.slug]: network.id }), {});
|
||||
const grandParentNetworkEntries = await upsert('entities', grandParentNetworks.map((network) => (omit({ ...network, type: 'network' }, 'rename'))), ['slug', 'type'], knex);
|
||||
const grandParentNetworksBySlug = [].concat(grandParentNetworkEntries.inserted, grandParentNetworkEntries.updated).reduce((acc, network) => ({ ...acc, [network.slug]: network.id }), {});
|
||||
|
||||
const parentNetworksWithGrandParent = parentNetworks.map((network) => ({
|
||||
slug: network.slug,
|
||||
name: network.name,
|
||||
type: network.type || 'network',
|
||||
alias: network.alias,
|
||||
url: network.url,
|
||||
description: network.description,
|
||||
has_logo: network.hasLogo ?? true,
|
||||
showcased: typeof network.showcased === 'boolean' ? network.showcased : true,
|
||||
parameters: network.parameters || null,
|
||||
options: network.options,
|
||||
parent_id: grandParentNetworksBySlug[network.parent] || null,
|
||||
}));
|
||||
const parentNetworksWithGrandParent = parentNetworks.map((network) => ({
|
||||
slug: network.slug,
|
||||
name: network.name,
|
||||
type: network.type || 'network',
|
||||
alias: network.alias,
|
||||
url: network.url,
|
||||
description: network.description,
|
||||
has_logo: network.hasLogo ?? true,
|
||||
showcased: typeof network.showcased === 'boolean' ? network.showcased : true,
|
||||
parameters: network.parameters || null,
|
||||
options: network.options,
|
||||
parent_id: grandParentNetworksBySlug[network.parent] || null,
|
||||
}));
|
||||
|
||||
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 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) => ({
|
||||
slug: network.slug,
|
||||
name: network.name,
|
||||
type: network.type || 'network',
|
||||
alias: network.alias,
|
||||
url: network.url,
|
||||
description: network.description,
|
||||
has_logo: network.hasLogo ?? true,
|
||||
showcased: typeof network.showcased === 'boolean' ? network.showcased : true,
|
||||
parameters: network.parameters || null,
|
||||
options: network.options,
|
||||
parent_id: parentNetworksBySlug[network.parent] || grandParentNetworksBySlug[network.parent] || null,
|
||||
}));
|
||||
const networksWithParent = networks.map((network) => ({
|
||||
slug: network.slug,
|
||||
name: network.name,
|
||||
type: network.type || 'network',
|
||||
alias: network.alias,
|
||||
url: network.url,
|
||||
description: network.description,
|
||||
has_logo: network.hasLogo ?? true,
|
||||
showcased: typeof network.showcased === 'boolean' ? network.showcased : true,
|
||||
parameters: network.parameters || null,
|
||||
options: network.options,
|
||||
parent_id: parentNetworksBySlug[network.parent] || grandParentNetworksBySlug[network.parent] || null,
|
||||
}));
|
||||
|
||||
const networkEntries = await upsert('entities', networksWithParent, ['slug', 'type'], knex);
|
||||
const networkEntries = await upsert('entities', networksWithParent, ['slug', 'type'], knex);
|
||||
|
||||
const networkIdsBySlug = [].concat(
|
||||
grandParentNetworkEntries.inserted,
|
||||
grandParentNetworkEntries.updated,
|
||||
parentNetworkEntries.inserted,
|
||||
parentNetworkEntries.updated,
|
||||
networkEntries.inserted,
|
||||
networkEntries.updated,
|
||||
).reduce((acc, network) => ({ ...acc, [network.slug]: network.id }), {});
|
||||
const networkIdsBySlug = [].concat(
|
||||
grandParentNetworkEntries.inserted,
|
||||
grandParentNetworkEntries.updated,
|
||||
parentNetworkEntries.inserted,
|
||||
parentNetworkEntries.updated,
|
||||
networkEntries.inserted,
|
||||
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 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) => ({
|
||||
entity_id: networkIdsBySlug[network.slug],
|
||||
tag_id: tagIdsBySlug[tagSlug],
|
||||
inherit: true,
|
||||
}))
|
||||
: []))
|
||||
.flat();
|
||||
const tagAssociations = networks
|
||||
.map((network) => (network.tags
|
||||
? network.tags.map((tagSlug) => ({
|
||||
entity_id: networkIdsBySlug[network.slug],
|
||||
tag_id: tagIdsBySlug[tagSlug],
|
||||
inherit: true,
|
||||
}))
|
||||
: []))
|
||||
.flat();
|
||||
|
||||
await upsert('entities_tags', tagAssociations, ['entity_id', 'tag_id'], knex);
|
||||
});
|
||||
await upsert('entities_tags', tagAssociations, ['entity_id', 'tag_id'], knex);
|
||||
|
||||
const entities = await knex('entities').select('id', 'slug', 'type');
|
||||
|
||||
await redis.connect();
|
||||
|
||||
await redis.del('traxxx:entities:id_by_slug');
|
||||
await redis.hSet('traxxx:entities:id_by_slug', entities.map((entity) => [`${entityPrefixes[entity.type]}${entity.slug}`, entity.id]));
|
||||
|
||||
await redis.disconnect();
|
||||
};
|
||||
|
||||
@@ -1,4 +1,12 @@
|
||||
const upsert = require('../src/utils/upsert');
|
||||
const redis = require('../src/redis');
|
||||
|
||||
const entityPrefixes = {
|
||||
channel: '',
|
||||
network: '_',
|
||||
studio: '*',
|
||||
info: '@',
|
||||
};
|
||||
|
||||
/* eslint-disable max-len */
|
||||
const sites = [
|
||||
@@ -609,6 +617,9 @@ const sites = [
|
||||
slug: 'asgmaxoriginals',
|
||||
url: 'https://www.asgmax.com/en/channel/asgmaxoriginals',
|
||||
parent: 'asgmax',
|
||||
parameters: {
|
||||
queryChannel: 'asgmaxoriginals',
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'ASG Max Films',
|
||||
@@ -616,6 +627,9 @@ const sites = [
|
||||
url: 'https://www.asgmax.com/en/channel/asgmaxfilms',
|
||||
parent: 'asgmax',
|
||||
hasLogo: false,
|
||||
parameters: {
|
||||
queryChannel: 'asgmaxfilms',
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'ASG International',
|
||||
@@ -623,6 +637,9 @@ const sites = [
|
||||
url: 'https://www.asgmax.com/en/channel/asginternational',
|
||||
parent: 'asgmax',
|
||||
hasLogo: false,
|
||||
parameters: {
|
||||
queryChannel: 'asginternational',
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'ASG Massage',
|
||||
@@ -631,6 +648,9 @@ const sites = [
|
||||
parent: 'asgmax',
|
||||
tags: ['massage'],
|
||||
hasLogo: false,
|
||||
parameters: {
|
||||
queryChannel: 'asgmassage',
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'ASG Auditions',
|
||||
@@ -639,6 +659,9 @@ const sites = [
|
||||
parent: 'asgmax',
|
||||
tags: ['audition'],
|
||||
hasLogo: false,
|
||||
parameters: {
|
||||
queryChannel: 'asgauditions',
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'ASG Free Use',
|
||||
@@ -647,6 +670,9 @@ const sites = [
|
||||
parent: 'asgmax',
|
||||
tags: ['free-use'],
|
||||
hasLogo: false,
|
||||
parameters: {
|
||||
queryChannel: 'asgfreeuse',
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'Exeter Hill College',
|
||||
@@ -655,6 +681,9 @@ const sites = [
|
||||
parent: 'asgmax',
|
||||
hasLogo: false,
|
||||
tags: ['animated'],
|
||||
parameters: {
|
||||
queryChannel: 'asgexeterhillcollege',
|
||||
},
|
||||
},
|
||||
// ASG MAX INDEPENDENT
|
||||
{
|
||||
@@ -5433,6 +5462,12 @@ const sites = [
|
||||
referer: 'https://www.girlsway.com',
|
||||
},
|
||||
},
|
||||
{
|
||||
slug: 'lesbianfactor',
|
||||
name: 'Lesbian Factor',
|
||||
url: 'https://www.lesbianfactor.com',
|
||||
parent: 'girlsway',
|
||||
},
|
||||
// HITZEFREI
|
||||
{
|
||||
slug: 'unleashed',
|
||||
@@ -5543,6 +5578,16 @@ const sites = [
|
||||
latest: 'https://seehimfuck.com',
|
||||
},
|
||||
},
|
||||
{
|
||||
slug: 'seehimsolo',
|
||||
name: 'See Him Solo',
|
||||
url: 'https://seehimsolo.com',
|
||||
tags: ['male-focus', 'solo'],
|
||||
parent: 'hussiepass',
|
||||
parameters: {
|
||||
latest: 'https://seehimsolo.com/categories/movies-2/{page}/latest/',
|
||||
},
|
||||
},
|
||||
{
|
||||
slug: 'interracialpovs',
|
||||
name: 'Interracial POVs',
|
||||
@@ -9392,9 +9437,9 @@ const sites = [
|
||||
parent: 'nubiles',
|
||||
},
|
||||
{
|
||||
slug: 'caughtmycoach',
|
||||
name: 'Caught My Coach',
|
||||
url: 'https://caughtmycoach.com',
|
||||
slug: 'shesbreedingmaterial',
|
||||
name: 'She\'s Breeding Material',
|
||||
url: 'https://shesbreedingmaterial.com',
|
||||
parent: 'nubiles',
|
||||
},
|
||||
// PASCALS SUBSLUTS
|
||||
@@ -10517,15 +10562,28 @@ const sites = [
|
||||
siteAsSerie: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'Hardwerk',
|
||||
slug: 'hardwerk',
|
||||
url: 'https://hardwerk.com',
|
||||
independent: true,
|
||||
parent: 'radical',
|
||||
parameters: {
|
||||
endpoint: 'jC4SrjH8YVDtRejiA0PMx',
|
||||
videos: 'films',
|
||||
actors: 'performers',
|
||||
},
|
||||
},
|
||||
// REALITY KINGS
|
||||
{
|
||||
name: 'Look At Her Now',
|
||||
url: 'https://www.lookathernow.com',
|
||||
description: 'Look At Her Now brings you best HD reality porn videos every week. Check out these girls before and after they get some rough pounding.',
|
||||
parameters: { native: true },
|
||||
// parameters: { siteId: 300 },
|
||||
slug: 'lookathernow',
|
||||
parent: 'realitykings',
|
||||
parameters: {
|
||||
siteId: 364,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'We Live Together',
|
||||
@@ -15502,195 +15560,86 @@ sites.reduce((acc, site) => {
|
||||
}, new Set());
|
||||
|
||||
/* eslint-disable max-len */
|
||||
exports.seed = (knex) => Promise.resolve()
|
||||
.then(async () => {
|
||||
await Promise.all(sites.map(async (channel) => {
|
||||
if (channel.rename) {
|
||||
await knex('entities')
|
||||
.where({
|
||||
type: channel.type || 'channel',
|
||||
slug: channel.rename,
|
||||
})
|
||||
.update('slug', channel.slug);
|
||||
exports.seed = async (knex) => {
|
||||
await Promise.all(sites.map(async (channel) => {
|
||||
if (channel.rename) {
|
||||
await knex('entities')
|
||||
.where({
|
||||
type: channel.type || 'channel',
|
||||
slug: channel.rename,
|
||||
})
|
||||
.update('slug', channel.slug);
|
||||
|
||||
return;
|
||||
return;
|
||||
}
|
||||
|
||||
if (channel.delete) {
|
||||
await knex('entities')
|
||||
.where({
|
||||
type: channel.type || 'channel',
|
||||
slug: channel.slug,
|
||||
})
|
||||
.delete();
|
||||
}
|
||||
}).filter(Boolean));
|
||||
|
||||
const networks = await knex('entities')
|
||||
.where('type', 'network')
|
||||
.orWhereNull('parent_id');
|
||||
|
||||
const networksMap = networks.filter((network) => !network.delete).reduce((acc, { id, slug }) => ({ ...acc, [slug]: id }), {});
|
||||
|
||||
const tags = await knex('tags').select('*').whereNull('alias_for');
|
||||
const tagsMap = tags.reduce((acc, { id, slug }) => ({ ...acc, [slug]: id }), {});
|
||||
|
||||
const sitesWithNetworks = sites.filter((site) => !site.delete).map((site) => ({
|
||||
slug: site.slug,
|
||||
name: site.name,
|
||||
name_stylized: site.style,
|
||||
type: site.type || 'channel',
|
||||
alias: site.alias,
|
||||
description: site.description,
|
||||
url: site.url,
|
||||
parameters: site.parameters || null,
|
||||
options: site.options,
|
||||
parent_id: networksMap[site.parent] || null,
|
||||
priority: site.priority || 0,
|
||||
independent: !!site.independent,
|
||||
visible: site.visible,
|
||||
showcased: site.showcased,
|
||||
has_logo: site.hasLogo === undefined ? true : site.hasLogo,
|
||||
}));
|
||||
|
||||
const { inserted, updated } = await upsert('entities', sitesWithNetworks, ['slug', 'type'], knex);
|
||||
const sitesMap = [].concat(inserted, updated).reduce((acc, { id, slug }) => ({ ...acc, [slug]: id }), {});
|
||||
|
||||
const tagAssociations = sites.map((site) => (site.tags && !site.delete
|
||||
? site.tags.map((tagSlug) => {
|
||||
const tag = tagsMap[tagSlug];
|
||||
|
||||
if (!tag) {
|
||||
console.warn(`Tag ${tagSlug} for ${site.slug} does not exist`);
|
||||
}
|
||||
|
||||
if (channel.delete) {
|
||||
await knex('entities')
|
||||
.where({
|
||||
type: channel.type || 'channel',
|
||||
slug: channel.slug,
|
||||
})
|
||||
.delete();
|
||||
}
|
||||
}).filter(Boolean));
|
||||
return {
|
||||
entity_id: sitesMap[site.slug],
|
||||
tag_id: tagsMap[tagSlug],
|
||||
inherit: true,
|
||||
};
|
||||
})
|
||||
: []
|
||||
)).flat();
|
||||
|
||||
const networks = await knex('entities')
|
||||
.where('type', 'network')
|
||||
.orWhereNull('parent_id');
|
||||
await upsert('entities_tags', tagAssociations, ['entity_id', 'tag_id'], knex);
|
||||
|
||||
const networksMap = networks.filter((network) => !network.delete).reduce((acc, { id, slug }) => ({ ...acc, [slug]: id }), {});
|
||||
const entities = await knex('entities').select('id', 'slug', 'type');
|
||||
|
||||
const tags = await knex('tags').select('*').whereNull('alias_for');
|
||||
const tagsMap = tags.reduce((acc, { id, slug }) => ({ ...acc, [slug]: id }), {});
|
||||
await redis.connect();
|
||||
|
||||
const sitesWithNetworks = sites.filter((site) => !site.delete).map((site) => ({
|
||||
slug: site.slug,
|
||||
name: site.name,
|
||||
name_stylized: site.style,
|
||||
type: site.type || 'channel',
|
||||
alias: site.alias,
|
||||
description: site.description,
|
||||
url: site.url,
|
||||
parameters: site.parameters || null,
|
||||
options: site.options,
|
||||
parent_id: networksMap[site.parent] || null,
|
||||
priority: site.priority || 0,
|
||||
independent: !!site.independent,
|
||||
visible: site.visible,
|
||||
showcased: site.showcased,
|
||||
has_logo: site.hasLogo === undefined ? true : site.hasLogo,
|
||||
}));
|
||||
await redis.del('traxxx:entities:id_by_slug');
|
||||
await redis.hSet('traxxx:entities:id_by_slug', entities.map((entity) => [`${entityPrefixes[entity.type]}${entity.slug}`, entity.id]));
|
||||
|
||||
const { inserted, updated } = await upsert('entities', sitesWithNetworks, ['slug', 'type'], knex);
|
||||
const sitesMap = [].concat(inserted, updated).reduce((acc, { id, slug }) => ({ ...acc, [slug]: id }), {});
|
||||
|
||||
const tagAssociations = sites.map((site) => (site.tags && !site.delete
|
||||
? site.tags.map((tagSlug) => {
|
||||
const tag = tagsMap[tagSlug];
|
||||
|
||||
if (!tag) {
|
||||
console.warn(`Tag ${tagSlug} for ${site.slug} does not exist`);
|
||||
}
|
||||
|
||||
return {
|
||||
entity_id: sitesMap[site.slug],
|
||||
tag_id: tagsMap[tagSlug],
|
||||
inherit: true,
|
||||
};
|
||||
})
|
||||
: []
|
||||
)).flat();
|
||||
|
||||
return upsert('entities_tags', tagAssociations, ['entity_id', 'tag_id'], knex);
|
||||
});
|
||||
await redis.disconnect();
|
||||
};
|
||||
|
||||
exports.sites = sites;
|
||||
|
||||
/*
|
||||
'X-Art' => 'xart',
|
||||
'met-art' => 'metart',
|
||||
'18og' => '18OnlyGirls',
|
||||
'a1o1' => 'Asian1on1',
|
||||
'add' => 'ManualAddActors',
|
||||
'analb' => 'AnalBeauty',
|
||||
'bgonzo' => 'BangGonzo',
|
||||
'btlbd' => 'BigTitsLikeBigDicks',
|
||||
'bjf' => 'BlowjobFridays',
|
||||
'cws' => 'CzechWifeSwap',
|
||||
'Daughter' => 'DaughterSwap',
|
||||
'Daughters' => 'DaughterSwap',
|
||||
'dc' => 'DorcelVision',
|
||||
'dpg' => 'DigitalPlayground',
|
||||
'dsw' => 'DaughterSwap',
|
||||
'faq' => 'FirstAnalQuest',
|
||||
'ft' => 'FastTimes',
|
||||
'fittingroom' => 'Fitting-Room',
|
||||
'gbcp' => 'GangbangCreampie',
|
||||
'hart' => 'Hegre',
|
||||
'hegre-art' => 'Hegre',
|
||||
'kha' => 'KarupsHA',
|
||||
'kow' => 'KarupsOW',
|
||||
'kpc' => 'KarupsPC',
|
||||
'la' => 'LatinAdultery',
|
||||
'lcd' => 'LittleCaprice',
|
||||
'lhf' => 'LoveHerFeet',
|
||||
'littlecapricedreams' => 'Little Caprice Dreams',
|
||||
'maj' => 'ManoJob',
|
||||
'mfl' => 'Mofos',
|
||||
'mj' => 'ManoJob',
|
||||
'mpov' => 'MrPOV',
|
||||
'naughtyamericavr' => 'NaughtyAmerica',
|
||||
'news' => 'NewSensations',
|
||||
'ps' => 'PropertySex',
|
||||
'sart' => 'SexArt',
|
||||
'sbj' => 'StreetBlowjobs',
|
||||
'sislove' => 'SisLovesMe',
|
||||
'tds' => 'TheDickSuckers',
|
||||
'these' => 'TheStripperExperience',
|
||||
'tlc' => 'TeensLoveCream',
|
||||
'tle' => 'TheLifeErotic',
|
||||
'tog' => 'TonightsGirlfriend',
|
||||
'wowg' => 'WowGirls',
|
||||
'wy' => 'WebYoung',
|
||||
'itc' => 'InTheCrack',
|
||||
"abbw" => "AbbyWinters",
|
||||
"abme" => "AbuseMe",
|
||||
"ana" => "AnalAngels",
|
||||
"atke" => "ATKExotics",
|
||||
"atkg" => "ATKGalleria",
|
||||
"atkgfs" => "ATKGirlfriends",
|
||||
"atkh" => "ATKHairy",
|
||||
"aktp" => "ATKPetites",
|
||||
"ba" => "Beauty-Angels",
|
||||
"bna" => "BrandNew",
|
||||
"bam" => "BruceAndMorgan",
|
||||
"bcast" => "BrutalCastings",
|
||||
"bd" => "BrutalDildos",
|
||||
"bpu" => "BrutalPickups",
|
||||
"cza" => "CzhecAmateurs",
|
||||
"czbb" => "CzechBangBus",
|
||||
"czb" => "CzechBitch",
|
||||
"cc" => "CzechCasting",
|
||||
"czc" => "CzechCouples",
|
||||
"czestro" => "CzechEstrogenolit",
|
||||
"czf" => "CzechFantasy",
|
||||
"czgb" => "CzechGangBang",
|
||||
"cgfs" => "CzechGFS",
|
||||
"czharem" => "CzechHarem",
|
||||
"czm" => "CzechMassage",
|
||||
"czo" => "CzechOrgasm",
|
||||
"czps" => "CzechPawnShop",
|
||||
"css" => "CzechStreets",
|
||||
"cztaxi" => "CzechTaxi",
|
||||
"czt" => "CzechTwins",
|
||||
"dts" => "DeepThroatSirens",
|
||||
"doan" => "DiaryOfANanny",
|
||||
"ds" => "DungeonSex",
|
||||
"ffr" => "FacialsForever",
|
||||
"ff" => "FilthyFamily",
|
||||
"fbbg" => "FirstBGG",
|
||||
"fs" => "FuckStudies",
|
||||
"tfcp" => "FullyClothedPissing",
|
||||
"gdp" => "GirlsDoPorn",
|
||||
"Harmony" => "HarmonyVision",
|
||||
"hletee" => "HelplessTeens",
|
||||
"jlmf" => "JessieLoadsMonsterFacials",
|
||||
"lang" => "LANewGirl",
|
||||
"mmp" => "MMPNetwork",
|
||||
"mbc" => "MyBabysittersClub",
|
||||
"nvg" => "NetVideoGirls",
|
||||
"oo" => "Only-Opaques",
|
||||
"os" => "Only-Secretaries",
|
||||
"oss" => "OnlySilAndSatin",
|
||||
"psus" => "PascalsSubSluts",
|
||||
"psp" => "PorsntarsPunishment",
|
||||
"pdmqfo" => "QuestForOrgasm",
|
||||
"sed" => "SexualDisgrace",
|
||||
"sislov" => "SisLovesMe",
|
||||
"tslw" => "SlimeWave",
|
||||
"stre" => "StrictRestraint",
|
||||
"t18" => "Taboo18",
|
||||
"tsma" => "TeenSexMania",
|
||||
"tsm" => "TeenSexMovs",
|
||||
"ttw" => "TeensInTheWoods",
|
||||
"tgw" => "ThaiGirlsWild",
|
||||
"taob" => "TheArtOfBlowJob",
|
||||
"trwo" => "TheRealWorkout",
|
||||
"tt" => "TryTeens",
|
||||
"vp" => "VIPissy",
|
||||
"wrh" => "WeAreHairy",
|
||||
"yt" => "YoungThroats",
|
||||
];
|
||||
*/
|
||||
|
||||
@@ -719,6 +719,11 @@ const affiliates = [
|
||||
url: 'https://register.join-toughlovex.com/track/MzAwMDA5NzkuMy43Ni4xOTcuMC4wLjAuMC4w',
|
||||
comment: 'rev share',
|
||||
},
|
||||
{
|
||||
channel: 'hardwerk',
|
||||
url: 'https://register.hardwerk.com/track/MzAwMDA5NzkuMy4xNTEuMzM5LjAuMC4wLjAuMA',
|
||||
comment: 'rev share',
|
||||
},
|
||||
// radical > topwebmodels
|
||||
{
|
||||
network: 'topwebmodels',
|
||||
@@ -945,6 +950,46 @@ const affiliates = [
|
||||
query: 'ref=4c331ef6',
|
||||
},
|
||||
},
|
||||
// POV Porn Cash / HussiePass
|
||||
{
|
||||
network: 'hussiepass',
|
||||
url: 'https://secure.hussiepass.com/track/MTk0NS4xLjUuNy4wLjAuMC4wLjA',
|
||||
comment: '50% revshare',
|
||||
parameters: {
|
||||
// hussiepass website does not show network scenes
|
||||
channelScenes: false,
|
||||
},
|
||||
},
|
||||
{
|
||||
channel: 'povpornstars',
|
||||
url: 'https://join.povpornstars.com/track/MTk0NS4xLjMuNS4wLjAuMC4wLjA',
|
||||
comment: '50% revshare',
|
||||
},
|
||||
{
|
||||
channel: 'interracialpovs',
|
||||
url: 'https://join.interracialpovs.com/track/MTk0NS4xLjYuOC4wLjAuMC4wLjA',
|
||||
comment: '50% revshare',
|
||||
},
|
||||
{
|
||||
channel: 'ravebunnys',
|
||||
url: 'https://secure.ravebunnys.com/track/MTk0NS4xLjExLjI5LjAuMC4wLjAuMA',
|
||||
comment: '50% revshare',
|
||||
},
|
||||
{
|
||||
channel: 'hotandtatted',
|
||||
url: 'https://join.hotandtatted.com/track/MTk0NS4xLjEwLjEyLjAuMC4wLjAuMA',
|
||||
comment: '50% revshare',
|
||||
},
|
||||
{
|
||||
channel: 'seehimfuck',
|
||||
url: 'https://join.seehimfuck.com/track/MTk0NS4xLjcuOS4wLjAuMC4wLjA',
|
||||
comment: '50% revshare',
|
||||
},
|
||||
{
|
||||
channel: 'seehimsolo',
|
||||
url: 'https://join.seehimsolo.com/track/MTk0NS4xLjguMTAuMC4wLjAuMC4w',
|
||||
comment: '50% revshare',
|
||||
},
|
||||
// etc
|
||||
{
|
||||
network: 'bang',
|
||||
|
||||
22
src/knex.js
22
src/knex.js
@@ -3,7 +3,7 @@
|
||||
const config = require('config');
|
||||
const knex = require('knex');
|
||||
|
||||
module.exports = knex({
|
||||
const knexInstance = knex({
|
||||
client: 'pg',
|
||||
connection: config.database.owner,
|
||||
pool: config.database.pool,
|
||||
@@ -11,3 +11,23 @@ module.exports = knex({
|
||||
asyncStackTraces: process.env.NODE_ENV === 'development',
|
||||
// debug: process.env.NODE_ENV === 'development',
|
||||
});
|
||||
|
||||
knexInstance.on('query', function onQuery(query) {
|
||||
const bindingCount = query.bindings?.length ?? 0;
|
||||
|
||||
if (bindingCount > 50000) {
|
||||
const error = new Error(`[knex] Dangerous query: ${bindingCount} bindings detected: ${query.sql?.slice(0, 200)}${query.sql?.length > 200 ? '...' : ''}`);
|
||||
|
||||
Error.captureStackTrace(error, onQuery);
|
||||
// console.error(error);
|
||||
|
||||
throw error; // optionally hard-fail so you get a real stack trace
|
||||
}
|
||||
});
|
||||
|
||||
knexInstance.on('query-error', (error, query) => {
|
||||
error.knexSql = `${query.sql?.slice(0, 200)}${query.sql?.length > 200 ? '...' : ''}`;
|
||||
error.knexBindingCount = query.bindings?.length;
|
||||
});
|
||||
|
||||
module.exports = knexInstance;
|
||||
|
||||
10
src/media.js
10
src/media.js
@@ -23,7 +23,7 @@ const logger = require('./logger')(__filename);
|
||||
const argv = require('./argv');
|
||||
const knex = require('./knex');
|
||||
const http = require('./utils/http');
|
||||
const bulkInsert = require('./utils/bulk-insert');
|
||||
const batchInsert = require('./utils/batch-insert');
|
||||
const chunk = require('./utils/chunk');
|
||||
const { get } = require('./utils/qu');
|
||||
const { fetchEntityReleaseIds } = require('./entity-releases');
|
||||
@@ -647,6 +647,7 @@ async function fetchHttpSource(source, tempFileTarget, hashStream) {
|
||||
const res = await http.get(source.src, {
|
||||
limits: 'media',
|
||||
headers: {
|
||||
host: new URL(source.src).hostname,
|
||||
...(source.referer && { referer: source.referer }),
|
||||
...(source.host && { host: source.host }),
|
||||
},
|
||||
@@ -923,7 +924,8 @@ async function storeMedias(baseMedias, options) {
|
||||
const newMediaEntries = newMediaWithEntries.filter((media) => media.newEntry).map((media) => media.entry);
|
||||
|
||||
try {
|
||||
await bulkInsert('media', newMediaEntries, false);
|
||||
console.log('NEW MEDIA ENTRIES', newMediaEntries);
|
||||
await batchInsert('media', newMediaEntries, { confict: false });
|
||||
|
||||
return [...newMediaWithEntries, ...existingHashMedias];
|
||||
} catch (error) {
|
||||
@@ -992,11 +994,11 @@ async function associateReleaseMedia(releases, type = 'release') {
|
||||
.filter(Boolean);
|
||||
|
||||
if (associations.length > 0) {
|
||||
await bulkInsert(`${type}s_${role}`, associations, false);
|
||||
await batchInsert(`${type}s_${role}`, associations, { conflict: false });
|
||||
}
|
||||
} catch (error) {
|
||||
if (error.entries) {
|
||||
logger.error(util.inspect(error.entries, null, null, { color: true }));
|
||||
logger.error(util.inspect(error.entries.slice(0, 2), null, null, { color: true }), `${Math.min(error.entries.length, 2)} of ${error.length}`);
|
||||
}
|
||||
|
||||
logger.error(`Failed to store ${type} ${role}: ${error.message} (${error.detail || 'no detail'})`);
|
||||
|
||||
@@ -140,6 +140,7 @@ module.exports = {
|
||||
purgatoryx: radical,
|
||||
topwebmodels: radical,
|
||||
lucidflix: radical,
|
||||
hardwerk: radical,
|
||||
// hush / hussiepass
|
||||
eyeontheguy: hush,
|
||||
hushpass: hush,
|
||||
|
||||
@@ -148,7 +148,6 @@ function scrapeRelease(data, url, channel, networkName, options) {
|
||||
[release.poster, ...release.photos] = getThumbs(data).map((src) => ({
|
||||
src,
|
||||
referer: url,
|
||||
host: 'mediavault-private-fl.project1content.com',
|
||||
}));
|
||||
|
||||
const { teaser, trailer } = getVideos(data);
|
||||
@@ -274,7 +273,7 @@ async function fetchLatest(site, page = 1, options) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const { instanceToken } = options.beforeNetwork?.instanceToken
|
||||
const { instanceToken } = options.beforeNetwork?.instanceToken && !(options.parameters?.native || options.parameters?.childSession || options.parameters?.parentSession === false)
|
||||
? options.beforeNetwork
|
||||
: await getSession(site, options.parameters, url);
|
||||
|
||||
|
||||
@@ -70,8 +70,7 @@ function scrapeAll(scenes, entity) {
|
||||
async function fetchLatest(site, page = 1) {
|
||||
const url = `${site.url}/video/gallery/${(page - 1) * 12}`; // /0 redirects back to /
|
||||
|
||||
const res = await unprint.get(url, {
|
||||
interface: 'request',
|
||||
const res = await unprint.browser(url, {
|
||||
selectAll: '.content-grid-item',
|
||||
});
|
||||
|
||||
@@ -86,9 +85,8 @@ async function fetchUpcoming(site) {
|
||||
if (site.parameters?.upcoming) {
|
||||
const url = `${site.url}/video/upcoming`;
|
||||
|
||||
const res = await unprint.get(url, {
|
||||
const res = await unprint.browser(url, {
|
||||
selectAll: '.content-grid-item',
|
||||
interface: 'request',
|
||||
});
|
||||
|
||||
if (res.ok) {
|
||||
@@ -139,9 +137,7 @@ async function scrapeScene({ query }, { url, entity, include }) {
|
||||
}
|
||||
|
||||
async function fetchScene(url, entity, _baseRelease, include) {
|
||||
const res = await unprint.get(url, {
|
||||
interface: 'request',
|
||||
});
|
||||
const res = await unprint.browser(url);
|
||||
|
||||
if (res.ok) {
|
||||
return scrapeScene(res.context, { url, entity, include });
|
||||
@@ -185,9 +181,7 @@ async function findModel(actor, entity) {
|
||||
|
||||
const url = `${origin}/model/alpha/${firstLetter}`;
|
||||
|
||||
const resModels = await unprint.get(url, {
|
||||
interface: 'request',
|
||||
});
|
||||
const resModels = await unprint.browser(url);
|
||||
|
||||
if (!resModels.ok) {
|
||||
return resModels.status;
|
||||
@@ -217,9 +211,7 @@ async function fetchProfile(actor, { entity }) {
|
||||
const model = await findModel(actor, entity);
|
||||
|
||||
if (model) {
|
||||
const resModel = await unprint.get(model.url, {
|
||||
interface: 'request',
|
||||
});
|
||||
const resModel = await unprint.browser(model.url);
|
||||
|
||||
if (resModel.ok) {
|
||||
return scrapeProfile(resModel.context, model.avatar);
|
||||
|
||||
@@ -215,7 +215,7 @@ function scrapeProfile(data, channel, scenes, parameters) {
|
||||
|
||||
async function fetchProfile(actor, { channel, parameters }) {
|
||||
const endpoint = await fetchEndpoint(channel);
|
||||
const res = await http.get(`${channel.url}/_next/data/${endpoint}/models/${actor.slug}.json?slug=${actor.slug}`);
|
||||
const res = await http.get(`${channel.url}/_next/data/${endpoint}/${parameters.actors || 'models'}/${actor.slug}.json?slug=${actor.slug}`);
|
||||
|
||||
if (res.ok && res.body.pageProps?.model) {
|
||||
return scrapeProfile(res.body.pageProps.model, channel, res.body.pageProps.model_contents, parameters);
|
||||
|
||||
15
src/tools/huge-query.js
Normal file
15
src/tools/huge-query.js
Normal file
@@ -0,0 +1,15 @@
|
||||
'use strict';
|
||||
|
||||
const knex = require('../knex');
|
||||
|
||||
async function init() {
|
||||
const data = Array.from({ length: 100_000 }, (value, index) => ({
|
||||
id: `test_affiliate_${index}`,
|
||||
}));
|
||||
|
||||
await knex('affiliates').insert(data);
|
||||
|
||||
console.log('Done!');
|
||||
}
|
||||
|
||||
init();
|
||||
@@ -41,7 +41,7 @@ async function fetchScenes() {
|
||||
studios.name as studio_name,
|
||||
grandparents.id as parent_network_id,
|
||||
COALESCE(JSON_AGG(DISTINCT (actors.id, actors.name)) FILTER (WHERE actors.id IS NOT NULL), '[]') as actors,
|
||||
COALESCE(JSON_AGG(DISTINCT (tags.id, tags.name, tags.priority, tags_aliases.name)) FILTER (WHERE tags.id IS NOT NULL), '[]') as tags,
|
||||
COALESCE(JSON_AGG(DISTINCT (tags.id, tags.name, tags.priority, tags_aliases.name, local_tags.actor_id)) FILTER (WHERE tags.id IS NOT NULL), '[]') as tags,
|
||||
COALESCE(JSON_AGG(DISTINCT (movies.id, movies.title)) FILTER (WHERE movies.id IS NOT NULL), '[]') as movies,
|
||||
COALESCE(JSON_AGG(DISTINCT (series.id, series.title)) FILTER (WHERE series.id IS NOT NULL), '[]') as series,
|
||||
COALESCE(JSON_AGG(DISTINCT (releases_fingerprints.hash)) FILTER (WHERE releases_fingerprints.hash IS NOT NULL), '[]') as fingerprints,
|
||||
@@ -136,6 +136,14 @@ async function init() {
|
||||
dupe_index int
|
||||
)`);
|
||||
|
||||
await utilsApi.sql('drop table if exists scenes_tags');
|
||||
await utilsApi.sql(`create table scenes_tags (
|
||||
id int,
|
||||
scene_id int,
|
||||
tag_id int,
|
||||
actor_id int
|
||||
)`);
|
||||
|
||||
console.log('Recreated scenes table');
|
||||
console.log('Fetching scenes from primary database');
|
||||
|
||||
@@ -143,49 +151,62 @@ async function init() {
|
||||
|
||||
console.log('Fetched scenes from primary database');
|
||||
|
||||
const docs = scenes.map((scene) => {
|
||||
const docs = scenes.flatMap((scene) => {
|
||||
const flatActors = scene.actors.flatMap((actor) => actor.f2.match(/[\w']+/g)); // match word characters to filter out brackets etc.
|
||||
const flatTags = scene.tags.filter((tag) => tag.f3 > 6).flatMap((tag) => (tag.f4 ? `${tag.f2} ${tag.f4}` : tag.f2).match(/[\w']+/g)); // only make top tags searchable to minimize cluttered results
|
||||
const filteredTitle = filterTitle(scene.title, [...flatActors, ...flatTags]);
|
||||
|
||||
return {
|
||||
replace: {
|
||||
index: 'scenes',
|
||||
id: scene.id,
|
||||
doc: {
|
||||
title: scene.title || undefined,
|
||||
title_filtered: filteredTitle || undefined,
|
||||
date: scene.date ? Math.round(scene.date.getTime() / 1000) : undefined,
|
||||
created_at: Math.round(scene.created_at.getTime() / 1000),
|
||||
effective_date: Math.round((scene.date || scene.created_at).getTime() / 1000),
|
||||
is_showcased: scene.showcased,
|
||||
entry_id: scene.entry_id || undefined,
|
||||
shoot_id: scene.shoot_id || undefined,
|
||||
channel_id: scene.channel_id,
|
||||
channel_slug: scene.channel_slug,
|
||||
channel_name: [].concat(scene.channel_name, scene.channel_aliases).join(' '),
|
||||
network_id: scene.network_id || undefined,
|
||||
network_slug: scene.network_slug || undefined,
|
||||
network_name: [].concat(scene.network_name, scene.network_aliases).join(' ') || undefined,
|
||||
studio_id: scene.studio_id || undefined,
|
||||
studio_slug: scene.studio_slug || undefined,
|
||||
studio_name: scene.studio_name || undefined,
|
||||
entity_ids: [scene.channel_id, scene.network_id, scene.parent_network_id, scene.studio_id].filter(Boolean), // manticore does not support OR, this allows IN
|
||||
actor_ids: scene.actors.map((actor) => actor.f1),
|
||||
actors: scene.actors.map((actor) => actor.f2).join(),
|
||||
tag_ids: scene.tags.map((tag) => tag.f1),
|
||||
tags: flatTags.join(' '),
|
||||
movie_ids: scene.movies.map((movie) => movie.f1),
|
||||
movies: scene.movies.map((movie) => movie.f2).join(' '),
|
||||
serie_ids: scene.series.map((serie) => serie.f1),
|
||||
series: scene.series.map((serie) => serie.f2).join(' '),
|
||||
fingerprints: scene.fingerprints.join(' '),
|
||||
meta: scene.date ? format(scene.date, 'y yy M MM MMM MMMM d dd') : undefined,
|
||||
stashed: scene.stashed || 0,
|
||||
dupe_index: scene.dupe_index || 0,
|
||||
return [
|
||||
{
|
||||
replace: {
|
||||
index: 'scenes',
|
||||
id: scene.id,
|
||||
doc: {
|
||||
title: scene.title || undefined,
|
||||
title_filtered: filteredTitle || undefined,
|
||||
date: scene.date ? Math.round(scene.date.getTime() / 1000) : undefined,
|
||||
created_at: Math.round(scene.created_at.getTime() / 1000),
|
||||
effective_date: Math.round((scene.date || scene.created_at).getTime() / 1000),
|
||||
is_showcased: scene.showcased,
|
||||
entry_id: scene.entry_id || undefined,
|
||||
shoot_id: scene.shoot_id || undefined,
|
||||
channel_id: scene.channel_id,
|
||||
channel_slug: scene.channel_slug,
|
||||
channel_name: [].concat(scene.channel_name, scene.channel_aliases).join(' '),
|
||||
network_id: scene.network_id || undefined,
|
||||
network_slug: scene.network_slug || undefined,
|
||||
network_name: [].concat(scene.network_name, scene.network_aliases).join(' ') || undefined,
|
||||
studio_id: scene.studio_id || undefined,
|
||||
studio_slug: scene.studio_slug || undefined,
|
||||
studio_name: scene.studio_name || undefined,
|
||||
entity_ids: [scene.channel_id, scene.network_id, scene.parent_network_id, scene.studio_id].filter(Boolean), // manticore does not support OR, this allows IN
|
||||
actor_ids: scene.actors.map((actor) => actor.f1),
|
||||
actors: scene.actors.map((actor) => actor.f2).join(),
|
||||
tag_ids: scene.tags.map((tag) => tag.f1),
|
||||
tags: flatTags.join(' '),
|
||||
movie_ids: scene.movies.map((movie) => movie.f1),
|
||||
movies: scene.movies.map((movie) => movie.f2).join(' '),
|
||||
serie_ids: scene.series.map((serie) => serie.f1),
|
||||
series: scene.series.map((serie) => serie.f2).join(' '),
|
||||
fingerprints: scene.fingerprints.join(' '),
|
||||
meta: scene.date ? format(scene.date, 'y yy M MM MMM MMMM d dd') : undefined,
|
||||
stashed: scene.stashed || 0,
|
||||
dupe_index: scene.dupe_index || 0,
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
...scene.tags.map((tag) => ({
|
||||
replace: {
|
||||
index: 'scenes_tags',
|
||||
// id: scene.id,
|
||||
doc: {
|
||||
scene_id: scene.id,
|
||||
tag_id: tag.f1,
|
||||
actor_id: tag.f5,
|
||||
},
|
||||
},
|
||||
})),
|
||||
];
|
||||
});
|
||||
|
||||
// const accData = chunk(docs, 10000).reduce(async (chain, docsChunk, index, array) => {
|
||||
|
||||
88
src/tools/manticore-stashes.js
Normal file
88
src/tools/manticore-stashes.js
Normal file
@@ -0,0 +1,88 @@
|
||||
'use strict';
|
||||
|
||||
const config = require('config');
|
||||
const manticore = require('manticoresearch');
|
||||
|
||||
const knex = require('../knex');
|
||||
const chunk = require('../utils/chunk');
|
||||
|
||||
const mantiClient = new manticore.ApiClient();
|
||||
|
||||
mantiClient.basePath = `http://${config.database.manticore.host}:${config.database.manticore.httpPort}`;
|
||||
|
||||
const utilsApi = new manticore.UtilsApi(mantiClient);
|
||||
const indexApi = new manticore.IndexApi(mantiClient);
|
||||
|
||||
async function syncStashes(domain = 'scene') {
|
||||
await utilsApi.sql(`truncate table ${domain}s_stashed`);
|
||||
|
||||
const stashes = await knex(`stashes_${domain}s`)
|
||||
.select(
|
||||
`stashes_${domain}s.id as stashed_id`,
|
||||
`stashes_${domain}s.${domain}_id`,
|
||||
'stashes.id as stash_id',
|
||||
'stashes.user_id as user_id',
|
||||
`stashes_${domain}s.created_at as created_at`,
|
||||
)
|
||||
.leftJoin('stashes', 'stashes.id', `stashes_${domain}s.stash_id`);
|
||||
|
||||
await chunk(stashes, 1000).reduce(async (chain, stashChunk, index) => {
|
||||
await chain;
|
||||
|
||||
const stashDocs = stashChunk.map((stash) => ({
|
||||
replace: {
|
||||
index: `${domain}s_stashed`,
|
||||
id: stash.stashed_id,
|
||||
doc: {
|
||||
[`${domain}_id`]: stash[`${domain}_id`],
|
||||
stash_id: stash.stash_id,
|
||||
user_id: stash.user_id,
|
||||
created_at: Math.round(stash.created_at.getTime() / 1000),
|
||||
},
|
||||
},
|
||||
}));
|
||||
|
||||
await indexApi.bulk(stashDocs.map((doc) => JSON.stringify(doc)).join('\n'));
|
||||
|
||||
console.log(`Synced ${index * 1000 + stashChunk.length}/${stashes.length} ${domain} stashes`);
|
||||
}, Promise.resolve());
|
||||
}
|
||||
|
||||
async function init() {
|
||||
await utilsApi.sql('drop table if exists scenes_stashed');
|
||||
|
||||
await utilsApi.sql(`create table if not exists scenes_stashed (
|
||||
scene_id int,
|
||||
stash_id int,
|
||||
user_id int,
|
||||
created_at timestamp
|
||||
)`);
|
||||
|
||||
await utilsApi.sql('drop table if exists movies_stashed');
|
||||
|
||||
await utilsApi.sql(`create table if not exists movies_stashed (
|
||||
movie_id int,
|
||||
stash_id int,
|
||||
user_id int,
|
||||
created_at timestamp
|
||||
)`);
|
||||
|
||||
await utilsApi.sql('drop table if exists actors_stashed');
|
||||
|
||||
await utilsApi.sql(`create table if not exists actors_stashed (
|
||||
actor_id int,
|
||||
stash_id int,
|
||||
user_id int,
|
||||
created_at timestamp
|
||||
)`);
|
||||
|
||||
await syncStashes('scene');
|
||||
await syncStashes('actor');
|
||||
await syncStashes('movie');
|
||||
|
||||
console.log('Done!');
|
||||
|
||||
knex.destroy();
|
||||
}
|
||||
|
||||
init();
|
||||
@@ -16,14 +16,14 @@ async function updateManticoreStashedScenes(docs) {
|
||||
await chunk(docs, 1000).reduce(async (chain, docsChunk) => {
|
||||
await chain;
|
||||
|
||||
const sceneIds = docsChunk.map((doc) => doc.replace.id);
|
||||
const sceneIds = docsChunk.filter((doc) => !!doc.replace).map((doc) => doc.replace.id);
|
||||
|
||||
const stashes = await knex('stashes_scenes')
|
||||
.select('stashes_scenes.id as stashed_id', 'stashes_scenes.scene_id', 'stashes_scenes.created_at', 'stashes.id as stash_id', 'stashes.user_id as user_id')
|
||||
.leftJoin('stashes', 'stashes.id', 'stashes_scenes.stash_id')
|
||||
.whereIn('scene_id', sceneIds);
|
||||
|
||||
const stashDocs = docsChunk.flatMap((doc) => {
|
||||
const stashDocs = docsChunk.filter((doc) => doc.replace).flatMap((doc) => {
|
||||
const sceneStashes = stashes.filter((stash) => stash.scene_id === doc.replace.id);
|
||||
|
||||
if (sceneStashes.length === 0) {
|
||||
@@ -50,6 +50,25 @@ async function updateManticoreStashedScenes(docs) {
|
||||
if (stashDocs.length > 0) {
|
||||
await indexApi.bulk(stashDocs.map((doc) => JSON.stringify(doc)).join('\n'));
|
||||
}
|
||||
|
||||
const deleteSceneIds = docs.filter((doc) => doc.delete).map((doc) => doc.delete.id);
|
||||
|
||||
if (deleteSceneIds.length > 0) {
|
||||
await indexApi.callDelete({
|
||||
index: 'scenes_stashed',
|
||||
query: {
|
||||
bool: {
|
||||
must: [
|
||||
{
|
||||
in: {
|
||||
scene_id: deleteSceneIds,
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
}, Promise.resolve());
|
||||
}
|
||||
|
||||
@@ -128,9 +147,20 @@ async function updateManticoreSceneSearch(releaseIds) {
|
||||
studios.showcased
|
||||
`, releaseIds && [releaseIds]);
|
||||
|
||||
// console.log(scenes.rows);
|
||||
const scenesById = Object.fromEntries(scenes.rows.map((scene) => [scene.id, scene]));
|
||||
|
||||
const docs = releaseIds.map((sceneId) => {
|
||||
const scene = scenesById[sceneId];
|
||||
|
||||
if (!scene) {
|
||||
return {
|
||||
delete: {
|
||||
index: 'scenes',
|
||||
id: sceneId,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
const docs = scenes.rows.map((scene) => {
|
||||
const flatActors = scene.actors.flatMap((actor) => actor.f2.split(' '));
|
||||
const flatTags = scene.tags.filter((tag) => tag.f3 > 6).flatMap((tag) => [tag.f2].concat(tag.f4)).filter(Boolean); // only make top tags searchable to minimize cluttered results
|
||||
const filteredTitle = filterTitle(scene.title, [...flatActors, ...flatTags]);
|
||||
@@ -291,7 +321,20 @@ async function updateManticoreMovieSearch(movieIds) {
|
||||
movies_covers.*
|
||||
`, movieIds && [movieIds]);
|
||||
|
||||
const docs = movies.rows.map((movie) => {
|
||||
const moviesById = Object.fromEntries(movies.rows.map((movie) => [movie.id, movie]));
|
||||
|
||||
const docs = movieIds.map((movieId) => {
|
||||
const movie = moviesById[movieId];
|
||||
|
||||
if (!movie) {
|
||||
return {
|
||||
delete: {
|
||||
index: 'movies',
|
||||
id: movieId,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
const combinedTags = Object.values(Object.fromEntries(movie.tags.concat(movie.movie_tags).map((tag) => [tag.f1, {
|
||||
id: tag.f1,
|
||||
name: tag.f2,
|
||||
|
||||
@@ -4,11 +4,12 @@ const knex = require('../knex');
|
||||
const chunk = require('./chunk');
|
||||
const logger = require('../logger')(__filename);
|
||||
|
||||
const chunkTarget = 50_000; // PostgreSQL allows 65,535 binding parameters, allow for a bit of margin
|
||||
|
||||
// improved version of bulkInsert
|
||||
async function batchInsert(table, items, {
|
||||
conflict = true,
|
||||
update = false,
|
||||
chunkSize = 1000,
|
||||
concurrent = false,
|
||||
transaction,
|
||||
commit = false,
|
||||
@@ -17,6 +18,10 @@ async function batchInsert(table, items, {
|
||||
throw new Error('No table specified for batch insert');
|
||||
}
|
||||
|
||||
if (conflict && update) {
|
||||
throw new Error('Batch insert conflict must specify columns, or update must be disabled');
|
||||
}
|
||||
|
||||
if (!Array.isArray(items)) {
|
||||
throw new Error('Batch insert items are not an array');
|
||||
}
|
||||
@@ -25,8 +30,20 @@ async function batchInsert(table, items, {
|
||||
return [];
|
||||
}
|
||||
|
||||
const chunks = chunk(items, chunkSize);
|
||||
// PostgreSQL's bindings limit applies to individual values, so item size needs to be taken into account
|
||||
const itemSize = items.reduce((acc, item) => Math.max(acc, Object.keys(item).length), 0);
|
||||
|
||||
if (itemSize === 0) {
|
||||
throw new Error('Batch insert items are empty');
|
||||
}
|
||||
|
||||
const chunks = chunk(items, Math.floor(chunkTarget / itemSize));
|
||||
const conflicts = [].concat(conflict).filter((column) => typeof column === 'string'); // conflict might be 'true'
|
||||
|
||||
if (conflicts.length > 0 && !update) {
|
||||
throw new Error('Batch insert conflict columns must be specified together with update');
|
||||
}
|
||||
|
||||
const trx = transaction || await knex.transaction();
|
||||
|
||||
try {
|
||||
@@ -49,12 +66,6 @@ async function batchInsert(table, items, {
|
||||
.onConflict(conflicts)
|
||||
.merge();
|
||||
}
|
||||
|
||||
throw new Error('Batch insert conflict columns must be specified together with update');
|
||||
}
|
||||
|
||||
if (conflict && update) {
|
||||
throw new Error('Batch insert conflict must specify columns, or update must be disabled');
|
||||
}
|
||||
|
||||
// error on any conflict
|
||||
|
||||
@@ -153,6 +153,7 @@ const actors = [
|
||||
{ entity: 'topwebmodels', name: 'Lexi Belle', fields: ['avatar', 'dateOfBirth', 'birthPlace', 'measurements', 'height', 'weight', 'eyes', 'hairColor'] },
|
||||
{ entity: 'purgatoryx', name: 'Kenzie Reeves', fields: ['avatar', 'description', 'gender', 'dateOfBirth', 'birthPlace', 'measurements', 'height', 'weight', 'eyes', 'hairColor'] },
|
||||
{ entity: 'lucidflix', name: 'Ava Amira', fields: ['avatar', 'description', 'gender'] },
|
||||
{ entity: 'hardwerk', name: 'Luna Silver', fields: ['avatar', 'gender'] },
|
||||
// wankz
|
||||
{ entity: 'wankzvr', name: 'Melody Marks', fields: ['avatar', 'gender', 'description', 'birthPlace', 'height', 'measurements', 'age'] },
|
||||
{ entity: 'milfvr', name: 'Ember Snow', fields: ['avatar', 'gender', 'description', 'measurements', 'birthPlace', 'height', 'age'] },
|
||||
|
||||
Reference in New Issue
Block a user