Improved case resolution in tag matching. Fixed Kelly Madison scraper returning BTS tag when indicating 'BTS available'.

This commit is contained in:
DebaucheryLibrarian 2025-12-14 22:30:10 +01:00
parent 2052af7977
commit 89c0cd8b2a
3 changed files with 9 additions and 9 deletions

View File

@ -202,6 +202,10 @@ const tags = [
name: 'behind the scenes', name: 'behind the scenes',
slug: 'bts', slug: 'bts',
}, },
{
name: 'BTS available',
slug: 'hasbts',
},
{ {
name: 'belgian', name: 'belgian',
slug: 'belgian', slug: 'belgian',

View File

@ -75,7 +75,8 @@ function scrapeSceneApi(data, channel, parameters) {
})); }));
} }
release.tags = data.categories.map((category) => category.name); // BTS category is used to indicate the scene has a BTS video available, not that it itself is a BTS
release.tags = data.categories.map((category) => (category.name.toLowerCase() === 'bts' ? 'bts available' : category.name));
release.photoCount = data.photosetPhotoCount || data.episode_photoset_photo_count; release.photoCount = data.photosetPhotoCount || data.episode_photoset_photo_count;
return release; return release;

View File

@ -74,19 +74,14 @@ function withRelations(queryBuilder, withMedia) {
} }
async function matchReleaseTags(releases) { async function matchReleaseTags(releases) {
const rawTags = releases const tags = releases
.map((release) => release.tags).flat() .map((release) => release.tags).flat()
.map((tag) => tag.trim().toLowerCase())
.filter(Boolean); .filter(Boolean);
const casedTags = [...new Set(
rawTags
.concat(rawTags.map((tag) => tag.trim().toLowerCase()))
.concat(rawTags.map((tag) => tag.trim().toUpperCase())),
)];
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')
.whereIn('tags.name', casedTags); .whereIn(knex.raw('lower(tags.name)'), tags);
const tagIdsBySlug = tagEntries const tagIdsBySlug = tagEntries
.reduce((acc, tag) => ({ .reduce((acc, tag) => ({