forked from DebaucheryLibrarian/traxxx
Added network to profile context when site is available.
This commit is contained in:
parent
885aa4f627
commit
003e07491d
|
@ -14,6 +14,7 @@ const logger = require('./logger')(__filename);
|
|||
|
||||
const { toBaseReleases } = require('./deep');
|
||||
const { associateAvatars } = require('./media');
|
||||
const { curateSite } = require('./sites');
|
||||
|
||||
const slugify = require('./utils/slugify');
|
||||
const capitalize = require('./utils/capitalize');
|
||||
|
@ -369,7 +370,7 @@ async function scrapeProfiles(actor, sources, networksBySlug, sitesBySlug) {
|
|||
const scraper = scrapers[scraperSlug];
|
||||
const context = {
|
||||
site: sitesBySlug[scraperSlug] || null,
|
||||
network: networksBySlug[scraperSlug] || null,
|
||||
network: networksBySlug[scraperSlug] || sitesBySlug[scraperSlug]?.network || null,
|
||||
scraper: scraperSlug,
|
||||
};
|
||||
|
||||
|
@ -418,7 +419,13 @@ async function scrapeActors(actorNames) {
|
|||
|
||||
const [networks, sites, existingActorEntries] = await Promise.all([
|
||||
knex('networks').whereIn('slug', siteSlugs),
|
||||
knex('sites').whereIn('slug', siteSlugs),
|
||||
knex('sites')
|
||||
.select(
|
||||
'sites.*',
|
||||
'networks.name as network_name', 'networks.slug as network_slug', 'networks.url as network_url', 'networks.description as network_description', 'networks.parameters as network_parameters',
|
||||
)
|
||||
.whereIn('sites.slug', siteSlugs)
|
||||
.leftJoin('networks', 'sites.network_id', 'networks.id'),
|
||||
knex('actors')
|
||||
.select(['id', 'name', 'slug'])
|
||||
.whereIn('slug', baseActors.map(baseActor => baseActor.slug))
|
||||
|
@ -428,7 +435,7 @@ async function scrapeActors(actorNames) {
|
|||
const existingActorEntriesBySlug = existingActorEntries.reduce((acc, actorEntry) => ({ ...acc, [actorEntry.slug]: actorEntry }), {});
|
||||
|
||||
const networksBySlug = networks.reduce((acc, network) => ({ ...acc, [network.slug]: network }), {});
|
||||
const sitesBySlug = sites.reduce((acc, site) => ({ ...acc, [site.slug]: site }), {});
|
||||
const sitesBySlug = sites.reduce((acc, site) => ({ ...acc, [site.slug]: curateSite(site) }), {});
|
||||
|
||||
const newBaseActors = baseActors.filter(baseActor => !existingActorEntriesBySlug[baseActor.slug]);
|
||||
|
||||
|
|
|
@ -615,7 +615,7 @@ async function associateAvatars(profiles) {
|
|||
? {
|
||||
...profile,
|
||||
avatarBaseMedia: toBaseMedias([profile.avatar], 'avatars', {
|
||||
copyright: profile.network?.name || null,
|
||||
copyright: profile.network?.name || profile.site?.name || null,
|
||||
scraper: profile.scraper || null,
|
||||
})[0],
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ const argv = require('./argv');
|
|||
const knex = require('./knex');
|
||||
const whereOr = require('./utils/where-or');
|
||||
|
||||
async function curateSite(site, includeParameters = false, includeTags = true) {
|
||||
function curateSite(site, includeParameters = false) {
|
||||
const curatedSite = {
|
||||
id: site.id,
|
||||
name: site.name,
|
||||
|
@ -26,12 +26,14 @@ async function curateSite(site, includeParameters = false, includeTags = true) {
|
|||
},
|
||||
};
|
||||
|
||||
/*
|
||||
if (includeTags) {
|
||||
curatedSite.tags = await knex('sites_tags')
|
||||
.select('tags.*', 'sites_tags.inherit')
|
||||
.where('site_id', site.id)
|
||||
.join('tags', 'tags.id', 'sites_tags.tag_id');
|
||||
}
|
||||
*/
|
||||
|
||||
return curatedSite;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue