Decoding HTML entities in title, description and location.

This commit is contained in:
DebaucheryLibrarian 2023-06-15 16:56:27 +02:00
parent d7f9157424
commit 5d3358ed91
2 changed files with 11 additions and 5 deletions

View File

@ -28,6 +28,7 @@
.button { .button {
display: inline-flex; display: inline-flex;
align-items: center; align-items: center;
justify-content: center;
border: none; border: none;
background: none; background: none;
padding: .5rem; padding: .5rem;

View File

@ -2,6 +2,7 @@
const config = require('config'); const config = require('config');
const Promise = require('bluebird'); const Promise = require('bluebird');
const { decode } = require('html-entities');
const argv = require('./argv'); const argv = require('./argv');
const logger = require('./logger')(__filename); const logger = require('./logger')(__filename);
@ -29,7 +30,8 @@ async function curateReleaseEntry(release, batchId, existingRelease, type = 'sce
}); });
const curatedRelease = { const curatedRelease = {
title: release.title, id: release.id, // release is updated
title: decode(release.title),
entry_id: release.entryId || null, entry_id: release.entryId || null,
entity_id: release.entity.id, entity_id: release.entity.id,
studio_id: release.studio?.id || null, studio_id: release.studio?.id || null,
@ -37,7 +39,7 @@ async function curateReleaseEntry(release, batchId, existingRelease, type = 'sce
date: Number(release.date) ? release.date : null, date: Number(release.date) ? release.date : null,
date_precision: release.datePrecision, date_precision: release.datePrecision,
slug, slug,
description: release.description, description: decode(release.description),
comment: release.comment, comment: release.comment,
deep: typeof release.deep === 'boolean' ? release.deep : false, deep: typeof release.deep === 'boolean' ? release.deep : false,
deep_url: release.deepUrl, deep_url: release.deepUrl,
@ -52,10 +54,10 @@ async function curateReleaseEntry(release, batchId, existingRelease, type = 'sce
} }
if (release.productionLocation) { if (release.productionLocation) {
curatedRelease.production_location = release.productionLocation; curatedRelease.production_location = decode(release.productionLocation);
if (argv.resolvePlace) { if (argv.resolvePlace) {
const productionLocation = await resolvePlace(release.productionLocation); const productionLocation = await resolvePlace(decode(release.productionLocation));
if (productionLocation) { if (productionLocation) {
curatedRelease.production_city = productionLocation.city; curatedRelease.production_city = productionLocation.city;
@ -469,8 +471,11 @@ async function storeScenes(releases, useBatchId) {
const uniqueReleasesWithId = attachReleaseIds(uniqueReleases, storedReleaseEntries, batchId); const uniqueReleasesWithId = attachReleaseIds(uniqueReleases, storedReleaseEntries, batchId);
const duplicateReleasesWithId = attachReleaseIds(duplicateReleases, duplicateReleaseEntries, batchId); const duplicateReleasesWithId = attachReleaseIds(duplicateReleases, duplicateReleaseEntries, batchId);
const curatedDuplicateReleases = await Promise.all(duplicateReleasesWithId.map((release) => curateReleaseEntry(release, batchId)));
const releasesWithId = uniqueReleasesWithId.concat(duplicateReleasesWithId); const releasesWithId = uniqueReleasesWithId.concat(duplicateReleasesWithId);
console.log(curatedDuplicateReleases);
const updated = await knex.raw(` const updated = await knex.raw(`
UPDATE releases UPDATE releases
SET url = COALESCE(new.url, releases.url), SET url = COALESCE(new.url, releases.url),
@ -485,7 +490,7 @@ async function storeScenes(releases, useBatchId) {
AS new(id int, url text, date timestamptz, entity json, title text, description text, duration integer, deep boolean) AS new(id int, url text, date timestamptz, entity json, title text, description text, duration integer, deep boolean)
WHERE releases.id = new.id WHERE releases.id = new.id
`, { `, {
scenes: JSON.stringify(duplicateReleasesWithId), scenes: JSON.stringify(curatedDuplicateReleases),
}); });
const [actors, storedSeries] = await Promise.all([ const [actors, storedSeries] = await Promise.all([