From 2c97803d82bf082e2847f766c505ee4fe080def7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kevin=20Midb=C3=B8e?= Date: Sun, 16 Jul 2017 11:03:30 +0200 Subject: [PATCH] Added a sendRequest function for handliing the post of a movie request --- src/plex/requestRepository.js | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/plex/requestRepository.js b/src/plex/requestRepository.js index 0cc27dd..a4f1872 100644 --- a/src/plex/requestRepository.js +++ b/src/plex/requestRepository.js @@ -8,6 +8,8 @@ const tmdb = new TMDB(configuration.get('tmdb', 'apiKey')); var Promise = require('bluebird'); var rp = require('request-promise'); +var pythonShell = require('python-shell'); + class RequestRepository { searchRequest(query, page, type) { @@ -55,6 +57,30 @@ class RequestRepository { }); } + sendRequest(identifier) { + // TODO try a cache hit on the movie item + + console.log(identifier) + tmdb.lookup(identifier).then(movie => { + console.log(movie.title) + + var options = { + args: [movie.title, movie.year, movie.poster] + } + + pythonShell.run('sendRequest.py', options, function (err, results) { + if (err) throw err; + // TODO Add error handling!! RequestRepository.ERROR + // results is an array consisting of messages collected during execution + + console.log('results: %j', results) + }) + return true; + }) + + + } + } module.exports = RequestRepository; \ No newline at end of file