Made Movie and Show inherit from Media.
This commit is contained in:
parent
9ef5ecab12
commit
bc604960fd
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) {
|
constructor(name, year, mediaURLs) {
|
||||||
this.name = name;
|
super(name, mediaURLs);
|
||||||
this.year = year;
|
this.year = year;
|
||||||
this.mediaURLs = mediaURLs;
|
|
||||||
this.downloadURLs = [];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
setDownloadURLs(downloadURLs) {
|
getDownloadPackageName() {
|
||||||
this.downloadURLs = downloadURLs;
|
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) {
|
constructor(name, season, mediaURLs) {
|
||||||
this.name = name;
|
super(name, mediaURLs);
|
||||||
this.season = season < 10 ? `0${season}` : `${season}`;
|
this.season = season < 10 ? `0${season}` : `${season}`;
|
||||||
this.mediaURLs = mediaURLs;
|
|
||||||
this.downloadURLs = [];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
setDownloadURLs(downloadURLs) {
|
getParsedEpisodeNumberForURL(downloadURL) {
|
||||||
this.downloadURLs = downloadURLs;
|
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}`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user