Api request #84

Merged
KevinMidboe merged 39 commits from api_request into master 2018-03-19 14:46:19 +00:00
Showing only changes of commit cffba202b0 - Show all commits

View File

@@ -6,7 +6,12 @@ class PlexRepository {
inPlex(tmdbResult) { inPlex(tmdbResult) {
return Promise.resolve() return Promise.resolve()
.then(() => this.search(tmdbResult.title)) .then(() => this.search(tmdbResult.title))
.then(plexResult => this.compareTmdbToPlex(tmdbResult, plexResult)); .then(plexResult => this.compareTmdbToPlex(tmdbResult, plexResult))
.catch((error) => {
console.log(error)
tmdbResult.matchedInPlex = false;
return tmdbResult;
});
} }
search(query) { search(query) {
@@ -19,6 +24,9 @@ class PlexRepository {
}; };
return rp(options) return rp(options)
.catch((error) => {
throw new Error('Unable to search plex.')
})
.then(result => this.mapResults(result)) .then(result => this.mapResults(result))
.then(([mappedResults, resultCount]) => ({ results: mappedResults, total_results: resultCount })); .then(([mappedResults, resultCount]) => ({ results: mappedResults, total_results: resultCount }));
} }