Added teaser support. Added Score network with scraper for Scoreland. Improved q. Added assets.
This commit is contained in:
12
src/media.js
12
src/media.js
@@ -188,7 +188,7 @@ async function storePhotos(photos, {
|
||||
targetId,
|
||||
subpath,
|
||||
primaryRole, // role to assign to first photo if not already in database, used mainly for avatars
|
||||
entropy = 2.5, // filter out fallback avatars and other generic clipart
|
||||
entropyFilter = 2.5, // filter out fallback avatars and other generic clipart
|
||||
}, label) {
|
||||
if (!photos || photos.length === 0) {
|
||||
logger.info(`No ${role}s available for ${label}`);
|
||||
@@ -200,7 +200,7 @@ async function storePhotos(photos, {
|
||||
|
||||
const metaFiles = await Promise.map(sourceOriginals, async (photoUrl, index) => fetchPhoto(photoUrl, index, label), {
|
||||
concurrency: 10,
|
||||
}).filter(photo => photo && photo.entropy > entropy);
|
||||
}).filter(photo => photo && photo.entropy > entropyFilter);
|
||||
|
||||
const metaFilesByHash = metaFiles.reduce((acc, photo) => ({ ...acc, [photo.hash]: photo }), {}); // pre-filter hash duplicates within set; may occur through fallbacks
|
||||
const [hashDuplicates, hashOriginals] = await findDuplicates(Object.values(metaFilesByHash), 'hash', 'hash', label);
|
||||
@@ -285,6 +285,7 @@ async function storeReleasePhotos(releases, label) {
|
||||
|
||||
async function storeTrailer(trailers, {
|
||||
domain = 'releases',
|
||||
role = 'trailer',
|
||||
targetId,
|
||||
subpath,
|
||||
}, label) {
|
||||
@@ -294,7 +295,7 @@ async function storeTrailer(trailers, {
|
||||
: trailers;
|
||||
|
||||
if (!trailer || !trailer.src) {
|
||||
logger.info(`No trailer available for ${label}`);
|
||||
logger.info(`No ${role} available for ${label}`);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -306,7 +307,7 @@ async function storeTrailer(trailers, {
|
||||
|
||||
const res = await bhttp.get(trailerX.src);
|
||||
const hash = getHash(res.body);
|
||||
const filepath = path.join(domain, subpath, `trailer${trailerX.quality ? `_${trailerX.quality}` : ''}.${mime.getExtension(mimetype)}`);
|
||||
const filepath = path.join(domain, subpath, `${role}${trailerX.quality ? `_${trailerX.quality}` : ''}.${mime.getExtension(mimetype)}`);
|
||||
|
||||
return {
|
||||
trailer: res.body,
|
||||
@@ -327,6 +328,7 @@ async function storeTrailer(trailers, {
|
||||
source: trailerX.source,
|
||||
quality: trailerX.quality,
|
||||
hash: trailerX.hash,
|
||||
type: role,
|
||||
})))
|
||||
.returning('*');
|
||||
|
||||
@@ -336,7 +338,7 @@ async function storeTrailer(trailers, {
|
||||
? [...sourceDuplicates, ...hashDuplicates, ...newTrailers]
|
||||
: [...sourceDuplicates, ...hashDuplicates];
|
||||
|
||||
await upsert('releases_trailers', trailerEntries.map(trailerEntry => ({
|
||||
await upsert(`releases_${role}s`, trailerEntries.map(trailerEntry => ({
|
||||
release_id: targetId,
|
||||
media_id: trailerEntry.id,
|
||||
})), ['release_id', 'media_id']);
|
||||
|
||||
Reference in New Issue
Block a user