Made Movie and Show inherit from Media.
This commit is contained in:
		
							
								
								
									
										25
									
								
								src/classes/media/Media.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										25
									
								
								src/classes/media/Media.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,25 @@ | ||||
| class Media { | ||||
|   constructor(name, mediaURLs) { | ||||
|     this.name = name; | ||||
|     this.mediaURLs = mediaURLs; | ||||
|     this.downloadURLs = []; | ||||
|   } | ||||
|  | ||||
|   setDownloadURLs(downloadURLs) { | ||||
|     this.downloadURLs = downloadURLs; | ||||
|   } | ||||
|  | ||||
|   getDownloadPackageName() { | ||||
|     throw new Error('Method not implemented!'); | ||||
|   } | ||||
|  | ||||
|   getDownloadDestinationFolder() { | ||||
|     throw new Error('Method not implemented!'); | ||||
|   } | ||||
|  | ||||
|   getDownloadFilename() { | ||||
|     throw new Error('Method not implemented!'); | ||||
|   } | ||||
| } | ||||
|  | ||||
| module.exports = Media; | ||||
| @@ -1,13 +1,21 @@ | ||||
| class Movie { | ||||
| const Media = require('./Media'); | ||||
|  | ||||
| class Movie extends Media { | ||||
|   constructor(name, year, mediaURLs) { | ||||
|     this.name = name; | ||||
|     super(name, mediaURLs); | ||||
|     this.year = year; | ||||
|     this.mediaURLs = mediaURLs; | ||||
|     this.downloadURLs = []; | ||||
|   } | ||||
|  | ||||
|   setDownloadURLs(downloadURLs) { | ||||
|     this.downloadURLs = downloadURLs; | ||||
|   getDownloadPackageName() { | ||||
|     return `${this.name} (${this.year})`; | ||||
|   } | ||||
|  | ||||
|   getDownloadDestinationFolder() { | ||||
|     return `${this.name} (${this.year})`; | ||||
|   } | ||||
|  | ||||
|   getDownloadFilename(ext) { | ||||
|     return `${this.name} (${this.year})${ext}`; | ||||
|   } | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -1,13 +1,26 @@ | ||||
| class Show { | ||||
| const Media = require('./Media'); | ||||
|  | ||||
| class Show extends Media{ | ||||
|   constructor(name, season, mediaURLs) { | ||||
|     this.name = name; | ||||
|     super(name, mediaURLs); | ||||
|     this.season = season < 10 ? `0${season}` : `${season}`; | ||||
|     this.mediaURLs = mediaURLs; | ||||
|     this.downloadURLs = []; | ||||
|   } | ||||
|  | ||||
|   setDownloadURLs(downloadURLs) { | ||||
|     this.downloadURLs = downloadURLs; | ||||
|   getParsedEpisodeNumberForURL(downloadURL) { | ||||
|     const episode = this.downloadURLs.indexOf(downloadURL) + 1; | ||||
|     return episode < 10 ? `0${episode}` : `${episode}`; | ||||
|   } | ||||
|  | ||||
|   getDownloadPackageName() { | ||||
|     return this.name; | ||||
|   } | ||||
|  | ||||
|   getDownloadDestinationFolder() { | ||||
|     return `${this.name}/Season ${this.season}`; | ||||
|   } | ||||
|  | ||||
|   getDownloadFilename(ext, downloadURL) { | ||||
|     return `${this.name} - S${this.season}E${this.getParsedEpisodeNumberForURL(downloadURL)}.${ext}`; | ||||
|   } | ||||
| } | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user