Added media status check.

This commit is contained in:
moonstar-x 2021-06-12 00:49:03 -05:00
parent 80cb8836a7
commit 4178159d75

View File

@ -38,6 +38,11 @@ class KissAsianScraper {
const name = await this.getCurrentMediaName();
const type = await this.getCurrentMediaType();
const isCompleted = await this.getCurrentMediaStatusCompleted();
if (!isCompleted) {
Logger.warn(`Warning! ${name} is still not completed. Proceed only if you're certain.`);
}
Logger.info(`Getting media links for ${type} ${name}...`);
@ -137,6 +142,25 @@ class KissAsianScraper {
return parseInt(year, 10);
}
}
return null;
});
}
async getCurrentMediaStatusCompleted() {
return await this.page.evaluate(() => {
const infoSpans = document.querySelectorAll('span.info');
for (let i = 0; i < infoSpans.length; i++) {
const span = infoSpans.item(i);
if (span.textContent === 'Status:') {
const status = span.nextSibling.textContent;
return status === 'Completed';
}
}
return null;
});
}