Improved tag aliasing. Added Penthouse scraper.

This commit is contained in:
DebaucheryLibrarian
2026-11-24 00:39:08 +01:00
parent 7042023c61
commit 49ea9bbec7
8 changed files with 260 additions and 14 deletions
+68 -9
View File
@@ -928,9 +928,9 @@ const tags = [
group: 'position', group: 'position',
}, },
{ {
name: 'natural tits', name: 'natural boobs',
slug: 'natural-tits', slug: 'natural-boobs',
rename: 'natural-boobs', rename: 'natural-tits',
group: 'body', group: 'body',
}, },
{ {
@@ -1757,9 +1757,8 @@ const aliases = [
for: 'big-butt', for: 'big-butt',
}, },
{ {
name: 'natural boobs', name: 'natural tits',
for: 'natural-tits', for: 'natural-boobs',
slug: 'natural-boobs',
}, },
{ {
name: 'big natural tits', name: 'big natural tits',
@@ -2331,7 +2330,7 @@ const aliases = [
}, },
{ {
name: 'natural', name: 'natural',
for: 'natural-tits', for: 'natural-boobs',
}, },
{ {
name: 'natural butt', name: 'natural butt',
@@ -3229,12 +3228,28 @@ const aliases = [
name: 'pleaser heels', name: 'pleaser heels',
for: 'pleasers', for: 'pleasers',
}, },
{
name: 'b/b/g',
for: 'mfm',
},
{
name: 'boobs - natural',
for: 'natural-boobs',
},
{
name: 'cumshot - facial',
for: 'facial',
},
{
name: 'ethnicity - caucasion',
for: 'white',
},
]; ];
const priorities = [ // higher index is higher priority const priorities = [ // higher index is higher priority
['blonde', 'brunette', 'black-hair', 'redhead'], ['blonde', 'brunette', 'black-hair', 'redhead'],
['asian', 'black', 'latina', 'white', 'interracial'], ['asian', 'black', 'latina', 'white', 'interracial'],
['fake-tits', 'natural-tits'], ['fake-tits', 'natural-boobs'],
['bts'], ['bts'],
['blowjob', 'deepthroat', 'oil'], ['blowjob', 'deepthroat', 'oil'],
['toys', 'toy-anal', 'toy-dp', 'piss-drinking'], ['toys', 'toy-anal', 'toy-dp', 'piss-drinking'],
@@ -3257,18 +3272,62 @@ const priorities = [ // higher index is higher priority
return acc; return acc;
}, {}); }, {});
// tables referencing a tag, with the columns that make a tag link unique besides tag_id
const tagReferences = {
releases_tags: ['release_id', 'actor_id'],
movies_tags: ['movie_id'],
chapters_tags: ['chapter_id'],
entities_tags: ['entity_id'],
alerts_tags: ['alert_id'],
feeds_tags: null, // no unique constraint
banners_tags: ['banner_id'],
tags_photos: ['media_id'],
tags_posters: [], // one poster per tag
};
// re-point everything linked to the aliases that are about to be deleted, instead of failing on foreign keys or losing cascaded links
async function moveTagReferences(knex, fromIds, toId) {
await Object.entries(tagReferences).reduce(async (chain, [table, uniqueColumns]) => {
await chain;
const conflict = uniqueColumns
? `AND NOT EXISTS (SELECT 1 FROM ${table} existing WHERE existing.tag_id = :toId ${uniqueColumns.map((column) => `AND existing.${column} IS NOT DISTINCT FROM ${table}.${column}`).join(' ')})`
: '';
await knex.raw(`UPDATE ${table} SET tag_id = :toId WHERE tag_id = ANY(:fromIds) ${conflict}`, { toId, fromIds });
// whatever is left already exists on the target tag
await knex(table).whereIn('tag_id', fromIds).delete();
}, Promise.resolve());
await knex('tags').whereIn('alias_for', fromIds).update({ alias_for: toId });
}
exports.seed = (knex) => Promise.resolve() exports.seed = (knex) => Promise.resolve()
.then(async () => upsert('tags_groups', groups, 'slug', knex)) .then(async () => upsert('tags_groups', groups, 'slug', knex))
.then(async () => { .then(async () => {
await Promise.all(tags.map((async (tag) => { await Promise.all(tags.map((async (tag) => {
if (tag.rename) { if (tag.rename) {
await knex('tags') const target = await knex('tags')
.where('slug', tag.rename)
.whereNull('alias_for')
.first();
const conflictingAliases = await knex('tags')
.where((builder) => { .where((builder) => {
builder builder
.where('slug', tag.slug) .where('slug', tag.slug)
.orWhere('name', tag.name); .orWhere('name', tag.name);
}) })
.whereNotNull('alias_for') .whereNotNull('alias_for')
.pluck('id');
if (target && conflictingAliases.length > 0) {
await moveTagReferences(knex, conflictingAliases, target.id);
}
await knex('tags')
.whereIn('id', conflictingAliases)
.delete(); .delete();
await knex('tags') await knex('tags')
+5
View File
@@ -716,6 +716,11 @@ const networks = [
forceDeepUpdate: true, forceDeepUpdate: true,
}, },
}, },
{
slug: 'penthouse',
name: 'Penthouse',
url: 'https://penthouse.com',
},
{ {
slug: 'perfectgonzo', slug: 'perfectgonzo',
name: 'Perfect Gonzo', name: 'Perfect Gonzo',
+7
View File
@@ -9524,6 +9524,13 @@ const sites = [
url: 'https://www.pascalssubsluts.com', url: 'https://www.pascalssubsluts.com',
tags: ['rough', 'bdsm'], tags: ['rough', 'bdsm'],
}, },
// PENTHOUSE
{
slug: 'penthousegold',
name: 'Penthouse Gold',
url: 'https://penthousegold.com',
parent: 'penthouse',
},
// PERFECT GONZO // PERFECT GONZO
{ {
slug: 'allinternal', slug: 'allinternal',
+2
View File
@@ -29,6 +29,7 @@ const karups = require('./karups');
const kellymadison = require('./kellymadison'); const kellymadison = require('./kellymadison');
const kink = require('./kink'); const kink = require('./kink');
const mariskax = require('./mariskax'); const mariskax = require('./mariskax');
const penthouse = require('./penthouse');
const pornbox = require('./pornbox'); const pornbox = require('./pornbox');
const littlecapricedreams = require('./littlecapricedreams'); const littlecapricedreams = require('./littlecapricedreams');
const loveherfilms = require('./loveherfilms'); const loveherfilms = require('./loveherfilms');
@@ -283,4 +284,5 @@ module.exports = {
adultempire, adultempire,
allherluv: missax, allherluv: missax,
manyvids, manyvids,
penthouse,
}; };
+118
View File
@@ -0,0 +1,118 @@
'use strict';
const unprint = require('unprint');
const slugify = require('../utils/slugify');
const tryUrls = require('../utils/try-urls');
const { convert } = require('../utils/convert');
function getEntryId(url) {
return slugify(new URL(url).pathname.match(/\/scenes\/([\w-]+)/)[1]?.replace(/_vids$/, ''));
}
function scrapeAll(scenes) {
return scenes.map(({ query }) => {
const release = {};
release.url = query.url('h3 a');
release.entryId = getEntryId(release.url);
release.title = query.content('h3 a');
release.date = query.date('.scene-date', 'DD MMM YYYY', { match: null });
release.actors = query.all('.scene-models a').map((actorEl) => ({
name: unprint.query.content(actorEl),
url: unprint.query.url(actorEl, null),
}));
release.poster = query.sourceSet('a picture img');
release.teaser = query.video('.mobile_trailer source');
if (query.exists('.scene-details .ultrahdlabel')) {
release.qualities = [2160];
}
return release;
});
}
async function fetchLatest(channel, page = 1) {
const url = `${channel.origin}/categories/videos_${page}_d.html`;
const res = await unprint.get(url, { selectAll: '.scene' });
if (res.ok) {
return scrapeAll(res.context, channel);
}
return res.status;
}
const qualityMap = {
'4k': 2160,
'1080p': 1080,
'720p': 720,
sd: 480,
// hd: 540, // ???
};
function scrapeScene({ query }, { url }) {
const release = {};
release.entryId = getEntryId(url);
release.title = query.content('.video-content h1');
release.description = query.content('.panel-body p');
release.actors = query.all('.pornstars .model').map((actorEl) => ({
name: unprint.query.content(actorEl, '.model-info h3 a') || unprint.query.content(actorEl, 'a[title]'),
avatar: unprint.query.sourceSet(actorEl, 'picture img'),
}));
release.tags = query.contents('.tags a');
release.poster = query.img('#trailer_player_finished > img') || query.img('meta[itemprop="thumbnailUrl"]', { attribute: 'content' });
release.trailer = query.video('#trailer_player source') || query.video('meta[itemprop="contentURL"]', { attribute: 'content' });
release.qualities = query.contents('.panel-body .full_download_link').map((quality) => qualityMap[quality?.split(' ')[0]?.toLowerCase()]).filter(Boolean);
return release;
}
function scrapeProfile({ query }) {
const profile = {};
const bio = Object.fromEntries(query.all('.model-facts li:nth-child(n+2)').map((bioEl) => [
slugify(unprint.query.content(bioEl, 'em'), '_'),
unprint.query.text(bioEl),
]));
profile.description = query.content('.model-facts-long .toggle-text');
profile.measurements = bio.measurements;
profile.height = convert(bio.height, 'cm');
profile.avatar = query.sourceSet('.img-pornstar img');
return profile;
}
async function fetchProfile({ name: actorName, url: actorUrl }, entity) {
const { res } = await tryUrls([
actorUrl,
`https://penthousegold.com/models/${slugify(actorName, '-')}.html`,
`https://penthousegold.com/models/${slugify(actorName, '')}.html`,
]);
if (res.ok) {
return scrapeProfile(res.context, entity);
}
return res.status;
}
module.exports = {
fetchLatest,
fetchProfile,
scrapeScene,
};
+2
View File
@@ -51,6 +51,7 @@ const naughtyamerica = require('./naughtyamerica');
const newsensations = require('./newsensations'); const newsensations = require('./newsensations');
const nubiles = require('./nubiles'); const nubiles = require('./nubiles');
const pascalssubsluts = require('./pascalssubsluts'); const pascalssubsluts = require('./pascalssubsluts');
const penthouse = require('./penthouse');
const perfectgonzo = require('./perfectgonzo'); const perfectgonzo = require('./perfectgonzo');
const pervcity = require('./pervcity'); const pervcity = require('./pervcity');
const pierrewoodman = require('./pierrewoodman'); const pierrewoodman = require('./pierrewoodman');
@@ -161,6 +162,7 @@ module.exports = {
newsensations, newsensations,
nubiles, nubiles,
pascalssubsluts, pascalssubsluts,
penthouse,
perfectgonzo, perfectgonzo,
pervcity, pervcity,
pierrewoodman, pierrewoodman,
+57 -5
View File
@@ -86,7 +86,8 @@ async function matchTags(rawTags) {
// array binding, large batches can easily exceed the bindings limit otherwise // array binding, large batches can easily exceed the bindings limit otherwise
const tagEntries = await knex('tags') const tagEntries = await knex('tags')
.select('tags.id', 'tags.name', 'tags.alias_for', 'tags.implied_tag_ids') .select('tags.id', 'tags.name', 'tags.alias_for', 'tags.implied_tag_ids')
.whereRaw('lower(tags.name) = ANY(:tags)', { tags }); // normalize stored names the same way as the input, otherwise names with other characters (b/b/g, p.o.v.) never match
.whereRaw('trim(regexp_replace(lower(tags.name), \'[^a-z0-9()-]+\', \' \', \'g\')) = ANY(:tags)', { tags });
const tagIdsBySlug = tagEntries const tagIdsBySlug = tagEntries
.reduce((acc, tag) => ({ .reduce((acc, tag) => ({
@@ -97,6 +98,41 @@ async function matchTags(rawTags) {
return tagIdsBySlug; return tagIdsBySlug;
} }
// implied tag IDs per matched slug, including the implications of an alias' main tag and implications of implied tags
async function matchImpliedTags(tagIdsBySlug) {
const implications = await knex('tags')
.select('id', 'name', 'implied_tag_ids')
.whereRaw('cardinality(implied_tag_ids) > 0');
if (implications.length === 0) {
return {};
}
const impliedIdsById = Object.fromEntries(implications.map((tag) => [tag.id, tag.implied_tag_ids.filter(Boolean)]));
const aliasImpliedIdsBySlug = Object.fromEntries(implications.map((tag) => [slugify(tag.name), tag.implied_tag_ids.filter(Boolean)]));
function resolve(tagIds, seen = new Set()) {
tagIds.forEach((tagId) => {
if (seen.has(tagId)) {
return;
}
seen.add(tagId);
resolve(impliedIdsById[tagId] || [], seen);
});
return seen;
}
return Object.fromEntries(Object.entries(tagIdsBySlug).map(([slug, tagId]) => {
const impliedIds = resolve([tagId, ...(aliasImpliedIdsBySlug[slug] || [])]);
impliedIds.delete(tagId);
return [slug, Array.from(impliedIds)];
}).filter(([, impliedIds]) => impliedIds.length > 0));
}
async function getEntityTags(releases) { async function getEntityTags(releases) {
const entityIds = Array.from(new Set(releases.map((release) => release.entity?.id).filter(Boolean))); const entityIds = Array.from(new Set(releases.map((release) => release.entity?.id).filter(Boolean)));
@@ -121,7 +157,21 @@ async function getEntityTags(releases) {
return entityTagIdsByEntityId; return entityTagIdsByEntityId;
} }
function buildReleaseTagAssociations(releases, tagIdsBySlug, entityTagIdsByEntityId, type) { function buildImpliedTagAssociations(release, tags, impliedIdsBySlug, type) {
const tagIds = new Set(tags.map((tag) => tag.tag_id).filter(Boolean));
const impliedIds = Array.from(new Set(tags.flatMap((tag) => (tag.original_tag && impliedIdsBySlug[slugify(tag.original_tag)]) || [])))
.filter((tagId) => !tagIds.has(tagId));
return impliedIds.map((tagId) => ({
[`${type}_id`]: release.id,
tag_id: tagId,
original_tag: null, // implied rows are not rematched by original tag
...(type === 'chapter' ? {} : { source: 'implied' }), // chapters_tags has no source column
}));
}
function buildReleaseTagAssociations(releases, tagIdsBySlug, entityTagIdsByEntityId, type, impliedIdsBySlug = {}) {
const tagAssociations = releases const tagAssociations = releases
.map((release) => { .map((release) => {
const entityTagIds = entityTagIdsByEntityId[release.entity?.id]?.map((tag) => ({ id: tag.id, original: tag.name })) || []; const entityTagIds = entityTagIdsByEntityId[release.entity?.id]?.map((tag) => ({ id: tag.id, original: tag.name })) || [];
@@ -146,7 +196,7 @@ function buildReleaseTagAssociations(releases, tagIdsBySlug, entityTagIdsByEntit
original_tag: tag.original, original_tag: tag.original,
})); }));
return tags; return tags.concat(buildImpliedTagAssociations(release, tags, impliedIdsBySlug, type));
}) })
.flat(); .flat();
@@ -158,10 +208,12 @@ async function associateReleaseTags(releases, type = 'release') {
return {}; return {};
} }
const tagIdsBySlug = await matchTags(releases.flatMap((release) => release.tags)); const rawTags = releases.flatMap((release) => release.tags);
const entityTagIdsByEntityId = await getEntityTags(releases); const entityTagIdsByEntityId = await getEntityTags(releases);
const tagIdsBySlug = await matchTags(rawTags.concat(Object.values(entityTagIdsByEntityId).flat().map((tag) => tag.name)));
const impliedIdsBySlug = await matchImpliedTags(tagIdsBySlug);
const tagAssociations = buildReleaseTagAssociations(releases, tagIdsBySlug, entityTagIdsByEntityId, type); const tagAssociations = buildReleaseTagAssociations(releases, tagIdsBySlug, entityTagIdsByEntityId, type, impliedIdsBySlug);
await batchInsert(`${type}s_tags`, tagAssociations, { conflict: false }); await batchInsert(`${type}s_tags`, tagAssociations, { conflict: false });
+1
View File
@@ -267,6 +267,7 @@ const actors = [
{ entity: 'darkkotv', name: 'Aidra Fox', fields: ['avatar', 'description', 'dateOfBirth', 'birthPlace', 'ethnicity', 'height', 'weight', 'measurements', 'naturalBoobs', 'hasTattoos', 'hasPiercings'] }, { entity: 'darkkotv', name: 'Aidra Fox', fields: ['avatar', 'description', 'dateOfBirth', 'birthPlace', 'ethnicity', 'height', 'weight', 'measurements', 'naturalBoobs', 'hasTattoos', 'hasPiercings'] },
{ entity: 'jaxslayher', name: 'Eliza Ibarra', fields: ['avatar', 'description', 'eyes', 'height', 'weight', 'birthPlace', 'measurements', 'hairColor'] }, { entity: 'jaxslayher', name: 'Eliza Ibarra', fields: ['avatar', 'description', 'eyes', 'height', 'weight', 'birthPlace', 'measurements', 'hairColor'] },
{ entity: 'cosplayground', name: 'Anna Claire Clouds', url: 'https://cosplayground.com/models/anna-claire-clouds?models=Anna%20Claire%20Clouds', fields: ['avatar', 'description', 'dateOfBirth', 'birthPlace', 'height', 'measurements', 'hairColor', 'ethnicity'] }, { entity: 'cosplayground', name: 'Anna Claire Clouds', url: 'https://cosplayground.com/models/anna-claire-clouds?models=Anna%20Claire%20Clouds', fields: ['avatar', 'description', 'dateOfBirth', 'birthPlace', 'height', 'measurements', 'hairColor', 'ethnicity'] },
{ entity: 'penthouse', name: 'Gianna Dior', fields: ['avatar', 'description', 'measurements', 'height'] },
]; ];
const actorScrapers = scrapers.actors; const actorScrapers = scrapers.actors;