Refactored media module. Returning 320p and 720p videos from MindGeek as teasers instead of trailers.
This commit is contained in:
@@ -12,7 +12,8 @@ const scrapers = require('./scrapers/scrapers');
|
||||
const whereOr = require('./utils/where-or');
|
||||
const resolvePlace = require('./utils/resolve-place');
|
||||
const slugify = require('./utils/slugify');
|
||||
const { createMediaDirectory, storePhotos } = require('./media_legacy');
|
||||
// const { createMediaDirectory, storePhotos } = require('./media_legacy');
|
||||
const { storeMedia, associateMedia } = require('./media');
|
||||
|
||||
async function curateActor(actor) {
|
||||
const [aliases, avatar, photos, social] = await Promise.all([
|
||||
@@ -250,6 +251,17 @@ async function storeSocialLinks(urls, actorId) {
|
||||
await knex('actors_social').insert(curatedSocialEntries);
|
||||
}
|
||||
|
||||
async function storeAvatars(avatars, actorId) {
|
||||
if (!avatars || avatars.length === 0) {
|
||||
return [];
|
||||
}
|
||||
|
||||
const avatarsBySource = await storeMedia(avatars, 'actor', 'avatar');
|
||||
await associateMedia({ [actorId]: avatars }, avatarsBySource, 'actor', 'photo', 'avatar');
|
||||
|
||||
return avatarsBySource;
|
||||
}
|
||||
|
||||
async function storeActor(actor, scraped = false, scrapeSuccess = false) {
|
||||
const curatedActor = curateActorEntry(actor, scraped, scrapeSuccess);
|
||||
|
||||
@@ -260,15 +272,7 @@ async function storeActor(actor, scraped = false, scrapeSuccess = false) {
|
||||
await storeSocialLinks(actor.social, actorEntry.id);
|
||||
|
||||
if (actor.avatars) {
|
||||
await createMediaDirectory('actors', `${actorEntry.slug}/`);
|
||||
await storePhotos(actor.avatars, {
|
||||
domain: 'actor',
|
||||
role: 'photo',
|
||||
primaryRole: 'avatar',
|
||||
targetId: actorEntry.id,
|
||||
subpath: `${actorEntry.slug}/`,
|
||||
naming: 'timestamp',
|
||||
}, actorEntry.name);
|
||||
await storeAvatars(actor.avatars, actorEntry.id);
|
||||
}
|
||||
|
||||
logger.info(`Added new entry for actor '${actor.name}'`);
|
||||
@@ -421,19 +425,9 @@ async function scrapeActors(actorNames) {
|
||||
|
||||
if (argv.save) {
|
||||
if (actorEntry && profile) {
|
||||
await createMediaDirectory('actors', `${actorEntry.slug}/`);
|
||||
|
||||
await Promise.all([
|
||||
updateActor(profile, true, true),
|
||||
// storeAvatars(profile, actorEntry),
|
||||
storePhotos(profile.avatars, {
|
||||
domain: 'actor',
|
||||
role: 'photo',
|
||||
primaryRole: 'avatar',
|
||||
targetId: actorEntry.id,
|
||||
subpath: `${actorEntry.slug}/`,
|
||||
naming: 'timestamp',
|
||||
}, actorEntry.name),
|
||||
storeAvatars(profile.avatars, actorEntry.id),
|
||||
]);
|
||||
|
||||
return profile;
|
||||
|
||||
Reference in New Issue
Block a user