Added entity resolution prefer to entity options.
This commit is contained in:
@@ -9,6 +9,9 @@ const grandParentNetworks = [
|
||||
name: 'Gamma Entertainment',
|
||||
url: 'https://www.gammaentertainment.com',
|
||||
alias: ['gammaentertainment'],
|
||||
options: {
|
||||
preferNetwork: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
slug: 'hush',
|
||||
|
||||
@@ -836,7 +836,7 @@ async function scrapeActors(argNames) {
|
||||
const entitySlugs = sources.flat();
|
||||
|
||||
const [entitiesBySlug, existingActorEntries] = await Promise.all([
|
||||
fetchEntitiesBySlug(entitySlugs, { types: ['channel', 'network', 'info'], prefer: argv.prefer || 'channel' }),
|
||||
fetchEntitiesBySlug(entitySlugs, { types: ['channel', 'network', 'info'], prefer: argv.prefer || 'options' }),
|
||||
knex('actors')
|
||||
.select(knex.raw('actors.id, actors.name, actors.slug, actors.entry_id, actors.entity_id, row_to_json(entities) as entity'))
|
||||
.whereIn('actors.slug', baseActors.map((baseActor) => baseActor.slug))
|
||||
|
||||
@@ -9,6 +9,7 @@ const knex = require('./knex');
|
||||
const { deleteScenes, deleteMovies, deleteSeries } = require('./releases');
|
||||
const { flushOrphanedMedia } = require('./media');
|
||||
const { resolveScraper, resolveLayoutScraper } = require('./scrapers/resolve');
|
||||
const getRecursiveParameters = require('./utils/get-recursive-parameters');
|
||||
|
||||
function getRecursiveParent(entity) {
|
||||
if (!entity) {
|
||||
@@ -257,13 +258,18 @@ async function fetchEntitiesBySlug(entitySlugs, options = { prefer: 'channel', a
|
||||
entitySlugs: entitySlugs.filter((slug) => !slug.includes('.')),
|
||||
entityHosts: entitySlugs.filter((slug) => slug.includes('.')).map((hostname) => `%${hostname}`),
|
||||
entityTypes: options.types || ['channel', 'network'],
|
||||
sort: knex.raw(options.prefer === 'channel' ? 'asc' : 'desc'),
|
||||
sort: knex.raw(options.prefer === 'channel' || options.prefer === 'options' ? 'asc' : 'desc'),
|
||||
});
|
||||
|
||||
// channel entity will overwrite network entity
|
||||
// by default channel entity will overwrite network entity
|
||||
const entitiesBySlug = entities.rows.reduce((accEntities, { entity }) => {
|
||||
const host = urlToHostname(entity.url);
|
||||
const curatedEntity = accEntities[entity.slug] || accEntities[host] || curateEntity(entity, true);
|
||||
const entityOptions = getRecursiveParameters(entity, 'options');
|
||||
const accEntity = accEntities[entity.slug] || accEntities[host];
|
||||
|
||||
const curatedEntity = !accEntity || (options.prefer === 'options' && entity.type === 'network' && entityOptions.preferNetwork)
|
||||
? curateEntity(entity, true)
|
||||
: accEntity;
|
||||
|
||||
return {
|
||||
...accEntities,
|
||||
|
||||
@@ -329,8 +329,7 @@ const validators = {
|
||||
|
||||
// profiler in this context is shorthand for profile scraper
|
||||
async function init() {
|
||||
// Pride Studios needs prefer network, probably works bests for most Gamma sites. Establish which scrapers need channel and why.
|
||||
const entitiesBySlug = await fetchEntitiesBySlug(Object.keys(actorScrapers), { types: ['channel', 'network', 'info'], prefer: 'network' });
|
||||
const entitiesBySlug = await fetchEntitiesBySlug(Object.keys(actorScrapers), { types: ['channel', 'network', 'info'], prefer: 'options' });
|
||||
|
||||
await Object.entries(actorScrapers).reduce(async (chain, [entitySlug, scraper]) => {
|
||||
await chain;
|
||||
@@ -340,7 +339,6 @@ async function init() {
|
||||
|
||||
const tests = actors.filter((actor) => actor.entity === entitySlug);
|
||||
|
||||
// TODO: remove when all tests are written
|
||||
if (tests.length === 0) {
|
||||
console.log('TODO', entitySlug);
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user