From 56405e54f9709f32c64535564ddf70bbb6459a81 Mon Sep 17 00:00:00 2001 From: Kevin Midboe Date: Wed, 23 Aug 2017 10:26:23 +0200 Subject: [PATCH 1/3] Downgraded from sqlite3 to sqlite because of connection function error. --- seasoned_api/conf/development.json | 2 +- seasoned_api/package.json | 1 + seasoned_api/src/database/sqliteDatabase.js | 9 +++++---- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/seasoned_api/conf/development.json b/seasoned_api/conf/development.json index e5d2fe1..22bde7c 100644 --- a/seasoned_api/conf/development.json +++ b/seasoned_api/conf/development.json @@ -1,6 +1,6 @@ { "database": { - "host": "shows.db" + "host": "../shows.db" }, "webserver": { "port": 31459 diff --git a/seasoned_api/package.json b/seasoned_api/package.json index 3ec5c86..52fe956 100644 --- a/seasoned_api/package.json +++ b/seasoned_api/package.json @@ -15,6 +15,7 @@ "python-shell": "^0.4.0", "request": "^2.81.0", "request-promise": "^4.2", + "sqlite": "^2.2.1", "sqlite3": "^2.5.0" } } diff --git a/seasoned_api/src/database/sqliteDatabase.js b/seasoned_api/src/database/sqliteDatabase.js index 0da7b07..3d0c5a4 100644 --- a/seasoned_api/src/database/sqliteDatabase.js +++ b/seasoned_api/src/database/sqliteDatabase.js @@ -1,19 +1,20 @@ const fs = require('fs'); const path = require('path'); -const sqlite3 = require('sqlite3'); +const sqlite = require('sqlite'); class SqliteDatabase { constructor(host) { this.host = host; - this.connection = sqlite3; + this.connection = sqlite; // this.schemaDirectory = path.join(__dirname, 'schemas'); } connect() { return Promise.resolve() - .then(() => new sqlite3.Database(this.host)) + .then(() => sqlite.open(this.host)) + .then(() => sqlite.exec('pragma foreign_keys = on;')); } all(sql, parameters) { @@ -29,4 +30,4 @@ class SqliteDatabase { } } -module.exports = SqliteDatabase; \ No newline at end of file +module.exports = SqliteDatabase; -- 2.34.1 From 84a897da6e9af1be862fde3288b68aa78694a6ed Mon Sep 17 00:00:00 2001 From: KevinMidboe Date: Sat, 2 Sep 2017 22:51:49 +0200 Subject: [PATCH 2/3] Added popularity and vote_count to movie and show object and added a new check for name and title of movie --- seasoned_api/src/plex/requestRepository.js | 3 +-- seasoned_api/src/tmdb/convertTmdbToSeasoned.js | 14 +++++++++++++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/seasoned_api/src/plex/requestRepository.js b/seasoned_api/src/plex/requestRepository.js index ee3f90d..8aef0ca 100644 --- a/seasoned_api/src/plex/requestRepository.js +++ b/seasoned_api/src/plex/requestRepository.js @@ -28,7 +28,7 @@ class RequestRepository { return Promise.each(plexMedia, function(plexMovie) { if (tmdbMovie.title == plexMovie.title && tmdbMovie.year == plexMovie.year) { tmdbMovie.matchedInPlex = true; - console.log(tmdbMovie.title + ' : ' + tmdbMovie.year); + // console.log('Matched: ' + tmdbMovie.title + ' : ' + tmdbMovie.year); } return tmdbMovie; }) @@ -41,7 +41,6 @@ class RequestRepository { }) }) .catch((error) => { - console.log(error); return error; }); } diff --git a/seasoned_api/src/tmdb/convertTmdbToSeasoned.js b/seasoned_api/src/tmdb/convertTmdbToSeasoned.js index 3f6c65e..3bbfd38 100644 --- a/seasoned_api/src/tmdb/convertTmdbToSeasoned.js +++ b/seasoned_api/src/tmdb/convertTmdbToSeasoned.js @@ -10,7 +10,13 @@ function convertTmdbToSeasoned(tmdbObject) { if (mediaType === 'movie') { const year = new Date(tmdbObject.release_date).getFullYear(); - const movie = new Movie(tmdbObject.title, year, mediaType); + if (tmdbObject.title !== undefined) { + var title = tmdbObject.title; + } else if (tmdbObject.name !== undefined) { + var title = tmdbObject.name; + } + + const movie = new Movie(title, year, mediaType); movie.summary = tmdbObject.overview; movie.rating = tmdbObject.vote_average; @@ -18,6 +24,9 @@ function convertTmdbToSeasoned(tmdbObject) { movie.background = tmdbObject.backdrop_path; movie.genre = tmdbObject.genre_ids; + movie.popularity = tmdbObject.popularity; + movie.vote_count = tmdbObject.vote_count; + return movie; } else if (mediaType === 'tv') { @@ -31,6 +40,9 @@ function convertTmdbToSeasoned(tmdbObject) { show.background = tmdbObject.backdrop_path; show.genre = tmdbObject.genre_ids; + show.popularity = tmdbObject.popularity; + show.vote_count = tmdbObject.vote_count; + return show; } } -- 2.34.1 From dacd44a8f551e958f1724104ca3353bfa5847bff Mon Sep 17 00:00:00 2001 From: KevinMidboe Date: Sat, 2 Sep 2017 22:53:04 +0200 Subject: [PATCH 3/3] Changed the value of the filter to be vote_count >= 80 or popularity > 18 --- seasoned_api/src/tmdb/tmdb.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/seasoned_api/src/tmdb/tmdb.js b/seasoned_api/src/tmdb/tmdb.js index 6d9f18f..a536381 100644 --- a/seasoned_api/src/tmdb/tmdb.js +++ b/seasoned_api/src/tmdb/tmdb.js @@ -16,9 +16,10 @@ class TMDB { .then((reponse) => { try { return reponse.results.filter(function(item) { - return ((item.vote_count >= 20 || item.popularity > 2) && (item.release_date !== undefined || item.first_air_date !== undefined)) + return ((item.vote_count >= 80 || item.popularity > 18) && (item.release_date !== undefined || item.first_air_date !== undefined)) }).map(convertTmdbToSeasoned); } catch (parseError) { + console.log(parseError) throw new Error('Could not parse result.'); } }); -- 2.34.1