diff --git a/src/classes/media/Media.js b/src/classes/media/Media.js new file mode 100644 index 0000000..be899d6 --- /dev/null +++ b/src/classes/media/Media.js @@ -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; diff --git a/src/classes/media/Movie.js b/src/classes/media/Movie.js index 0d95a0a..ce66bb9 100644 --- a/src/classes/media/Movie.js +++ b/src/classes/media/Movie.js @@ -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}`; } } diff --git a/src/classes/media/Show.js b/src/classes/media/Show.js index d0e114c..583dd21 100644 --- a/src/classes/media/Show.js +++ b/src/classes/media/Show.js @@ -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}`; } }