Renamed file. Now converts to both movie and show. Also added more data that is saved to the object.
This commit is contained in:
@@ -1,22 +0,0 @@
|
||||
const Movie = require('src/media_classes/movie');
|
||||
|
||||
function convertPlexToMovie(plexMovie) {
|
||||
const movie = new Movie();
|
||||
movie.title = plexMovie.title;
|
||||
|
||||
if (plexMovie.type === 'episode') {
|
||||
movie.title = plexMovie.grandparentTitle;
|
||||
movie.childTitle = plexMovie.title;
|
||||
movie.season = plexMovie.parentIndex;
|
||||
movie.episode = plexMovie.index;
|
||||
}
|
||||
movie.year = plexMovie.year;
|
||||
movie.library = plexMovie.librarySectionTitle;
|
||||
movie.type = plexMovie.type;
|
||||
movie.poster = plexMovie.thumb;
|
||||
movie.background = plexMovie.art;
|
||||
|
||||
return movie;
|
||||
}
|
||||
|
||||
module.exports = convertPlexToMovie;
|
||||
39
seasoned_api/src/plex/convertPlexToSeasoned.js
Normal file
39
seasoned_api/src/plex/convertPlexToSeasoned.js
Normal file
@@ -0,0 +1,39 @@
|
||||
const Movie = require('src/media_classes/movie');
|
||||
const Show = require('src/media_classes/show');
|
||||
|
||||
function convertPlexToSeasoned(plexObject) {
|
||||
|
||||
const mediaType = plexObject.type;
|
||||
// There are many diff types of content, we only want to look at movies and tv shows
|
||||
if (mediaType === 'movie') {
|
||||
const movie = new Movie(plexObject.title, plexObject.year, mediaType);
|
||||
|
||||
movie.summary = plexObject.summary;
|
||||
movie.rating = plexObject.rating;
|
||||
movie.poster = plexObject.thumb;
|
||||
movie.background = plexObject.art;
|
||||
movie.genre = plexObject.genre;
|
||||
movie.added = new Date(plexObject.addedAt * 1000);
|
||||
|
||||
movie.mediaInfo = plexObject.Media;
|
||||
|
||||
return movie;
|
||||
}
|
||||
else if (mediaType === 'show') {
|
||||
const show = new Show(plexObject.title, plexObject.year, mediaType);
|
||||
|
||||
show.summary = plexObject.summary;
|
||||
show.rating = plexObject.rating;
|
||||
show.poster = plexObject.thumb;
|
||||
show.background = plexObject.art;
|
||||
show.genre = plexObject.genre;
|
||||
show.added = new Date(plexObject.addedAt * 1000);
|
||||
|
||||
show.seasons = plexObject.childCount;
|
||||
show.episodes = plexObject.leafCount;
|
||||
|
||||
return show;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = convertPlexToSeasoned;
|
||||
Reference in New Issue
Block a user