Including unextracted scenes in date determination.

This commit is contained in:
DebaucheryLibrarian 2021-10-28 02:10:30 +02:00
parent 83dd233991
commit 29b8c5e38e
2 changed files with 16 additions and 22 deletions

View File

@ -45,21 +45,6 @@ function getVideos(data) {
}
function scrapeLatestX(data, site, filterChannel) {
if (site.parameters?.extract === true && data.collections.length > 0) {
// release should not belong to any channel
return null;
}
if (typeof site.parameters?.extract === 'string' && !data.collections.some(collection => collection.shortName === site.parameters.extract)) {
// release should belong to specific channel
return null;
}
if (filterChannel && !data.collections?.some(collection => collection.id === site.parameters?.siteId)) {
// used to separate upcoming Brazzers scenes
return null;
}
const release = {
entryId: data.id,
title: data.title,
@ -90,16 +75,24 @@ function scrapeLatestX(data, site, filterChannel) {
tags: [chapter.name],
}));
if ((site.parameters?.extract === true && data.collections.length > 0) // release should not belong to any channel
|| (typeof site.parameters?.extract === 'string' && !data.collections.some(collection => collection.shortName === site.parameters.extract)) // release should belong to specific channel
|| (filterChannel && !data.collections?.some(collection => collection.id === site.parameters?.siteId))) { // used to separate upcoming Brazzers scenes
return {
...release,
exclude: true,
};
}
return release;
}
async function scrapeLatest(items, site, filterChannel) {
const latestReleases = items.map(data => scrapeLatestX(data, site, filterChannel));
const extractedScenes = latestReleases.filter(Boolean);
return {
scenes: extractedScenes,
unextracted: latestReleases.length - extractedScenes.length,
scenes: latestReleases.filter(scene => !scene.exclude),
unextracted: latestReleases.filter(scene => scene.exclude),
};
}

View File

@ -66,10 +66,10 @@ async function filterUniqueReleases(releases) {
return { uniqueReleases, duplicateReleases };
}
function needNextPage(pageReleases, accReleases, isUpcoming, unextracted = 0) {
function needNextPage(pageReleases, accReleases, isUpcoming, unextracted = []) {
const { localUniqueReleases: uniquePageReleases } = filterLocalUniqueReleases(pageReleases, accReleases);
if (uniquePageReleases.length + unextracted === 0) {
if (uniquePageReleases.length + unextracted.length === 0) {
// page is empty, or only contains scenes from previous page
return false;
}
@ -78,17 +78,18 @@ function needNextPage(pageReleases, accReleases, isUpcoming, unextracted = 0) {
return uniquePageReleases.length > 0 && argv.paginateUpcoming;
}
if (uniquePageReleases.length + unextracted > 0) {
if (uniquePageReleases.length + unextracted.length > 0) {
if (argv.last) {
return accReleases.length + pageReleases.length < argv.last;
}
if (!pageReleases.every(release => !!release.date)) { // some scenes don't have dates
if (!pageReleases.concat(unextracted).every(release => !!release.date)) { // some scenes don't have dates
return accReleases.length + pageReleases.length < argv.missingDateLimit;
}
if (argv.after) {
const oldestReleaseOnPage = pageReleases
.concat(unextracted)
.sort((releaseA, releaseB) => releaseB.date - releaseA.date)
.slice(-1)[0];