Added year to Movie.
This commit is contained in:
		| @@ -1,6 +1,7 @@ | ||||
| class Movie { | ||||
|   constructor(name, mediaURLs) { | ||||
|   constructor(name, year, mediaURLs) { | ||||
|     this.name = name; | ||||
|     this.year = year; | ||||
|     this.mediaURLs = mediaURLs; | ||||
|     this.downloadURLs = []; | ||||
|   } | ||||
|   | ||||
| @@ -36,11 +36,8 @@ class KissAsianScraper { | ||||
|  | ||||
|     Logger.info(`Visited ${mediaURL}`); | ||||
|  | ||||
|     const name = await this.page.evaluate(() => { | ||||
|       const a = document.querySelector('div.barContent a.bigChar'); | ||||
|       return a.text; | ||||
|     }); | ||||
|     const type = await this.getCurrentMediaPageType(); | ||||
|     const name = await this.getCurrentMediaName(); | ||||
|     const type = await this.getCurrentMediaType(); | ||||
|  | ||||
|     Logger.info(`Getting media links for ${type} ${name}...`); | ||||
|  | ||||
| @@ -64,7 +61,9 @@ class KissAsianScraper { | ||||
|       return new Show(name, 1, mediaURLs); | ||||
|     } | ||||
|  | ||||
|     return new Movie(name, mediaURLs); | ||||
|     const year = await this.getCurrentMediaYear(); | ||||
|  | ||||
|     return new Movie(name, year, mediaURLs); | ||||
|   } | ||||
|  | ||||
|   async directlyVisitPlayerURL(playerURL) { | ||||
| @@ -118,7 +117,30 @@ class KissAsianScraper { | ||||
|     } | ||||
|   } | ||||
|  | ||||
|   async getCurrentMediaPageType() { | ||||
|   async getCurrentMediaName() { | ||||
|     return await this.page.evaluate(() => { | ||||
|       const a = document.querySelector('div.barContent a.bigChar'); | ||||
|       return a.text; | ||||
|     }); | ||||
|   } | ||||
|  | ||||
|   async getCurrentMediaYear() { | ||||
|     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 === 'Date aired:') { | ||||
|           const date = span.nextSibling.textContent; | ||||
|           const [year] = date.match(/\d{4}/); | ||||
|  | ||||
|           return parseInt(year, 10); | ||||
|         } | ||||
|       } | ||||
|     }); | ||||
|   } | ||||
|  | ||||
|   async getCurrentMediaType() { | ||||
|     const isMovie = await this.page.evaluate(() => { | ||||
|       const a = document.querySelector('a[href="/Genre/Movie"]'); | ||||
|       return !!a; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user