Made Movie and Show inherit from Media.

This commit is contained in:
moonstar-x 2021-06-12 00:19:17 -05:00
parent 9ef5ecab12
commit bc604960fd
3 changed files with 58 additions and 12 deletions

View 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;

View File

@ -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}`;
}
}

View File

@ -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}`;
}
}