Storing actor profile URL when provided from scene page.
This commit is contained in:
@@ -148,6 +148,7 @@ function curateActor(actor, withDetails = false, isProfile = false) {
|
||||
id: actor.id,
|
||||
name: actor.name,
|
||||
slug: actor.slug,
|
||||
url: actor.url,
|
||||
gender: actor.gender,
|
||||
entityId: actor.entity_id,
|
||||
aliasFor: actor.alias_for,
|
||||
@@ -238,6 +239,7 @@ function curateProfileEntry(profile) {
|
||||
entity_id: profile.entity?.id || null,
|
||||
date_of_birth: profile.dateOfBirth,
|
||||
date_of_death: profile.dateOfDeath,
|
||||
url: profile.url,
|
||||
gender: profile.gender,
|
||||
ethnicity: profile.ethnicity,
|
||||
description: profile.description,
|
||||
@@ -552,7 +554,10 @@ async function scrapeProfiles(actor, sources, entitiesBySlug, existingProfilesBy
|
||||
|
||||
logger.verbose(`Searching profile for '${actor.name}' on '${label}'`);
|
||||
|
||||
const profile = await scraper.fetchProfile(actor, context, include);
|
||||
const profile = await scraper.fetchProfile(curateActor({
|
||||
...existingProfile,
|
||||
...actor,
|
||||
}), context, include);
|
||||
|
||||
if (!profile || typeof profile === 'number') { // scraper returns HTTP code on request failure
|
||||
logger.verbose(`Profile for '${actor.name}' not available on ${label}, scraper returned ${profile}`);
|
||||
@@ -657,7 +662,11 @@ async function scrapeActors(argNames) {
|
||||
|
||||
const actors = existingActorEntries.concat(Array.isArray(newActorEntries) ? newActorEntries : []);
|
||||
|
||||
const existingProfiles = await knex('actors_profiles').whereIn('actor_id', actors.map(actor => actor.id));
|
||||
const existingProfiles = await knex('actors_profiles')
|
||||
.select(knex.raw('actors_profiles.*, row_to_json(avatars) as avatar'))
|
||||
.whereIn('actor_id', actors.map(actor => actor.id))
|
||||
.leftJoin('media as avatars', 'avatars.id', 'actors_profiles.avatar_media_id');
|
||||
|
||||
const existingProfilesByActorEntityId = existingProfiles.reduce((acc, profile) => ({
|
||||
...acc,
|
||||
[profile.actor_id]: {
|
||||
@@ -724,6 +733,8 @@ async function getOrCreateActors(baseActors, batchId) {
|
||||
}))
|
||||
.filter(actor => !!actor.id);
|
||||
|
||||
console.log(newActorIdsByEntityIdAndSlug, newActorProfiles);
|
||||
|
||||
await storeProfiles(newActorProfiles);
|
||||
|
||||
if (Array.isArray(newActors)) {
|
||||
|
||||
Reference in New Issue
Block a user