Fixed linting issues for json objects and tailing semicolon.

This commit is contained in:
2018-05-09 10:52:08 +02:00
parent 657ab10034
commit 5b49216c9d
3 changed files with 19 additions and 11 deletions

View File

@@ -15,6 +15,7 @@ class PlexRepository {
}
search(query) {
console.log('searching:', query)
const options = {
uri: `http://10.0.0.44:32400/search?query=${query}`,
headers: {
@@ -39,7 +40,8 @@ class PlexRepository {
}
else {
plexResult.results.map((plexItem) => {
if (tmdb.title === plexItem.title && tmdb.year === plexItem.year) { tmdb.matchedInPlex = true; }
if (tmdb.title === plexItem.title && tmdb.year === plexItem.year)
tmdb.matchedInPlex = true;
return tmdb;
});
}
@@ -50,6 +52,7 @@ class PlexRepository {
mapResults(response) {
return Promise.resolve()
.then(() => {
console.log('plexResponse:', response)
if (!response.MediaContainer.hasOwnProperty('Metadata')) return [[], 0];
const mappedResults = response.MediaContainer.Metadata.filter((element) => {

View File

@@ -8,7 +8,7 @@ const TMDB_METHODS = {
nowplaying: { movie: 'miscNowPlayingMovies', show: 'tvOnTheAir' },
similar: { movie: 'movieSimilar', show: 'tvSimilar' },
search: { movie: 'searchMovie', show: 'searchTv', multi: 'searchMulti' },
info: { movie: 'movieInfo', show: 'tvInfo' },
info: { movie: 'movieInfo', show: 'tvInfo' }
};
class TMDB {
@@ -65,7 +65,7 @@ class TMDB {
.catch(() => this.tmdb(TMDB_METHODS['search'][type], query))
.catch(() => { throw new Error('Could not search for movies/shows at tmdb.'); })
.then(response => this.cache.set(cacheKey, response))
.then(response => this.mapResults(response))
.then(response => this.mapResults(response));
}
/**
@@ -76,15 +76,15 @@ class TMDB {
* @returns {Promise} dict with query results, current page and total_pages
*/
listSearch(listName, type = 'movie', page = '1') {
const query = { page: page }
console.log(query)
const query = { page: page };
console.log(query);
const cacheKey = `${this.cacheTags[listName]}:${type}:${page}`;
return Promise.resolve()
.then(() => this.cache.get(cacheKey))
.catch(() => this.tmdb(TMDB_METHODS[listName][type], query))
.catch(() => { throw new Error('Error fetching list from tmdb.')})
.catch(() => { throw new Error('Error fetching list from tmdb.'); })
.then(response => this.cache.set(cacheKey, response))
.then(response => this.mapResults(response, type))
.then(response => this.mapResults(response, type));
}
/**
@@ -94,13 +94,18 @@ class TMDB {
* @returns {Promise} dict with tmdb results, mapped as movie/show objects.
*/
mapResults(response, type) {
console.log(response.page)
console.log(response.page);
return Promise.resolve()
.then(() => {
const mappedResults = response.results.filter((element) => {
return (element.media_type === 'movie' || element.media_type === 'tv' || element.media_type === undefined);
}).map((element) => convertTmdbToSeasoned(element, type));
return {results: mappedResults, page: response.page, total_pages: response.total_pages, total_results: response.total_results}
return {
results: mappedResults,
page: response.page,
total_pages: response.total_pages,
total_results: response.total_results
}
})
.catch((error) => { throw new Error(error); });
}

View File

@@ -41,7 +41,7 @@ class UserRepository {
assert(row, 'The user does not exist.');
return row.password;
})
.catch((err) => console.log('there was a error when getting hash', err));
.catch((err) => { console.log(error); throw new Error('Unable to find your user.'); });
}
/**
@@ -57,7 +57,7 @@ class UserRepository {
checkAdmin(user) {
return this.database.get(this.queries.getAdminStateByUser, user.username).then((row) => {
return row.admin;
})
});
}
}