Passing matching site to profile scrapers. Allowing scrapers to pass avatar metadata. Added scraper and copyright properties to media. Auto-adding copyright from site or scraper to avatars. Separated Porn Pros from Whale Member.
This commit is contained in:
21
src/media.js
21
src/media.js
@@ -137,6 +137,8 @@ async function fetchItem(source, index, existingItemsBySource, domain, role, att
|
||||
entropy,
|
||||
quality: source.quality || null,
|
||||
source: originalSource?.src || originalSource || source.src || source,
|
||||
scraper: source.scraper,
|
||||
copyright: source.copyright,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -191,6 +193,8 @@ async function saveItems(items, domain, role) {
|
||||
extension: item.extension,
|
||||
hash: item.hash,
|
||||
entropy: item.entropy,
|
||||
scraper: item.scraper,
|
||||
copyright: item.copyright,
|
||||
quality: item.quality,
|
||||
source: item.source,
|
||||
};
|
||||
@@ -204,7 +208,9 @@ async function saveItems(items, domain, role) {
|
||||
extension: item.extension,
|
||||
hash: item.hash,
|
||||
entropy: item.entropy,
|
||||
scraper: item.scraper,
|
||||
quality: item.quality,
|
||||
copyright: item.copyright,
|
||||
source: item.source,
|
||||
};
|
||||
} catch (error) {
|
||||
@@ -220,8 +226,10 @@ function curateItemEntries(items) {
|
||||
thumbnail: item.thumbpath,
|
||||
mime: item.mimetype,
|
||||
hash: item.hash,
|
||||
source: item.source,
|
||||
entropy: item.entropy,
|
||||
source: item.source,
|
||||
scraper: item.scraper,
|
||||
copyright: item.copyright,
|
||||
index,
|
||||
}));
|
||||
}
|
||||
@@ -308,16 +316,19 @@ function extractPrimaryItem(associations, targetId, role, primaryRole, primaryIt
|
||||
function associateTargetMedia(targetId, sources, mediaBySource, domain, role, primaryRole, primaryItemsByTargetId) {
|
||||
if (!sources) return { [role]: null, [primaryRole]: null };
|
||||
|
||||
const associations = sources
|
||||
const mediaIds = sources
|
||||
.filter(Boolean)
|
||||
.map((source) => {
|
||||
const mediaItem = Array.isArray(source)
|
||||
? source.reduce((acc, sourceX) => acc || mediaBySource[sourceX.src || sourceX], null)
|
||||
: mediaBySource[source.src || source];
|
||||
|
||||
return mediaItem && { [`${domain}_id`]: targetId, media_id: mediaItem.id };
|
||||
})
|
||||
.filter(Boolean);
|
||||
// return mediaItem && { [`${domain}_id`]: targetId, media_id: mediaItem.id };
|
||||
return mediaItem && mediaItem.id;
|
||||
});
|
||||
|
||||
const uniqueMediaIds = Array.from(new Set(mediaIds.filter(Boolean)));
|
||||
const associations = uniqueMediaIds.map(mediaId => ({ [`${domain}_id`]: targetId, media_id: mediaId }));
|
||||
|
||||
logger.silly(`Associating ${associations.length} ${role}s to ${domain} ${targetId}`);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user