Sharing title filter function between manticore update module and sync tool, fixing sync tool title filter word boundaries.

This commit is contained in:
DebaucheryLibrarian
2024-07-05 02:55:02 +02:00
parent f11a009395
commit 36a51f0491
3 changed files with 13 additions and 2 deletions

View File

@@ -6,6 +6,7 @@ const args = require('yargs').argv;
const { format } = require('date-fns');
const knex = require('../knex');
const filterTitle = require('../utils/filter-title');
const mantiClient = new manticore.ApiClient();
@@ -116,7 +117,7 @@ async function init() {
const docs = scenes.map((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 = scene.title && [...flatActors, ...flatTags].reduce((accTitle, tag) => accTitle.replace(new RegExp(tag.replace(/[^\w\s]+/g, ''), 'i'), ''), scene.title).trim().replace(/\s{2,}/, ' ');
const filteredTitle = filterTitle(scene.title, [...flatActors, ...flatTags]);
return {
replace: {