Refactored media module to generalize avatar and poster storage into photo storage.
This commit is contained in:
@@ -9,7 +9,7 @@ const argv = require('./argv');
|
||||
const scrapers = require('./scrapers/scrapers');
|
||||
const whereOr = require('./utils/where-or');
|
||||
const resolvePlace = require('./utils/resolve-place');
|
||||
const { createActorMediaDirectory, storeAvatars } = require('./media');
|
||||
const { createMediaDirectory, storePhotos } = require('./media');
|
||||
|
||||
async function curateActor(actor) {
|
||||
const [aliases, photos, social] = await Promise.all([
|
||||
@@ -352,11 +352,19 @@ async function scrapeActors(actorNames) {
|
||||
|
||||
if (argv.save) {
|
||||
if (actorEntry && profile) {
|
||||
await createActorMediaDirectory(profile, actorEntry);
|
||||
await createMediaDirectory('actors', `${actorEntry.slug}/`);
|
||||
|
||||
await Promise.all([
|
||||
updateActor(profile, true, true),
|
||||
storeAvatars(profile, actorEntry),
|
||||
// storeAvatars(profile, actorEntry),
|
||||
storePhotos(profile.avatars, {
|
||||
domain: 'actors',
|
||||
role: 'photo',
|
||||
primaryRole: 'avatar',
|
||||
targetId: actorEntry.id,
|
||||
subpath: `${actorEntry.slug}/`,
|
||||
naming: 'timestamp',
|
||||
}, actorEntry.name),
|
||||
]);
|
||||
|
||||
return;
|
||||
@@ -364,8 +372,15 @@ async function scrapeActors(actorNames) {
|
||||
|
||||
const newActorEntry = await storeActor(profile, true, true);
|
||||
|
||||
await createActorMediaDirectory(profile, newActorEntry);
|
||||
await storeAvatars(profile, newActorEntry);
|
||||
await createMediaDirectory('actors', `${newActorEntry.slug}/`);
|
||||
await storePhotos(profile.avatars, {
|
||||
domain: 'actors',
|
||||
role: 'photo',
|
||||
primaryRole: 'avatar',
|
||||
targetId: newActorEntry.id,
|
||||
subpath: `${newActorEntry.slug}/`,
|
||||
naming: 'timestamp',
|
||||
}, newActorEntry.name);
|
||||
}
|
||||
} catch (error) {
|
||||
console.warn(actorName, error);
|
||||
|
||||
Reference in New Issue
Block a user