Added media status check.
This commit is contained in:
		| @@ -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; | ||||
|     }); | ||||
|   } | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user