From 6564948af8a5be1dd79e9dee37058a08da4a1d60 Mon Sep 17 00:00:00 2001 From: KevinMidboe Date: Wed, 7 Feb 2018 13:38:25 +0100 Subject: [PATCH] Split up our plex and tmdb classes into more logical files with a common media class that it extends off of. --- seasoned_api/src/media_classes/media.js | 19 ++++++++++++++ seasoned_api/src/media_classes/plex.js | 22 +++++++++++++++++ seasoned_api/src/media_classes/tmdb.js | 33 +++++++++++++++++++++++++ 3 files changed, 74 insertions(+) create mode 100644 seasoned_api/src/media_classes/media.js create mode 100644 seasoned_api/src/media_classes/plex.js create mode 100644 seasoned_api/src/media_classes/tmdb.js diff --git a/seasoned_api/src/media_classes/media.js b/seasoned_api/src/media_classes/media.js new file mode 100644 index 0000000..4ec1627 --- /dev/null +++ b/seasoned_api/src/media_classes/media.js @@ -0,0 +1,19 @@ + +class Media { + constructor(title, year, type) { + this.title = title; + this.year = year; + this.type = type; + } + + toString() { + return `N: ${this.title} | Y: ${this.year} | T: ${this.type}`; + } + + print() { + /* eslint-disable no-console */ + console.log(this.toString()); + } +} + +module.exports = Media; diff --git a/seasoned_api/src/media_classes/plex.js b/seasoned_api/src/media_classes/plex.js new file mode 100644 index 0000000..57528b1 --- /dev/null +++ b/seasoned_api/src/media_classes/plex.js @@ -0,0 +1,22 @@ + +const Media = require('src/media_classes/media'); + +class Plex extends Media { + constructor(title, year, type, summary, poster_path, background_path, added, seasons, episodes) { + super(title, year, type); + + this.summary = summary; + this.poster_path = poster_path; + this.background_path = background_path; + this.added = added; + + this.seasons = seasons; + this.episodes = episodes; + } + + print() { + super.print(); + } +} + +module.exports = Plex; diff --git a/seasoned_api/src/media_classes/tmdb.js b/seasoned_api/src/media_classes/tmdb.js new file mode 100644 index 0000000..c1a7dc6 --- /dev/null +++ b/seasoned_api/src/media_classes/tmdb.js @@ -0,0 +1,33 @@ + +const Media = require('src/media_classes/media'); + +class TMDB extends Media { + // constructor(...args) { + constructor(title, year, type, id, summary, poster_path, background_path, popularity, score, release_status, tagline, seasons, episodes) { + super(title, year, type); + + this.id = id; + this.summary = summary; + this.poster_path = poster_path; + this.background_path = background_path; + this.popularity = popularity; + this.score = score; + + this.release_status = release_status; + this.tagline = tagline; + + this.seasons = seasons; + this.episodes = episodes; + } + + toString() { + return `${super.toString()} | ID: ${this.id}`; + } + + print() { + /* eslint-disable no-console */ + console.log(this.toString()); + } +} + +module.exports = TMDB;