Now makes a async call for python script and returns the ouput of the script when finished as a json object.
This commit is contained in:
@@ -1,34 +1,26 @@
|
|||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
|
var PythonShell = require('python-shell');
|
||||||
|
var async = require('async');
|
||||||
|
|
||||||
class PirateRepository {
|
async function find(searchterm, callback) {
|
||||||
|
var PythonShell = require('python-shell');
|
||||||
|
|
||||||
search(query) {
|
|
||||||
console.log(query)
|
|
||||||
}
|
|
||||||
|
|
||||||
searchMedia(query) {
|
|
||||||
var options = {
|
var options = {
|
||||||
uri: 'http://10.0.0.41:32400/search?query=' + query,
|
// pythonPath: '/usr/bin/python3',
|
||||||
headers: {
|
pythonPath: '/Library/Frameworks/Python.framework/Versions/3.6/bin/python3',
|
||||||
'Accept': 'application/json'
|
args: [searchterm]
|
||||||
},
|
|
||||||
json: true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return rp(options)
|
PythonShell.run('../app/pirateSearch.py', options, callback);
|
||||||
.then((result) => {
|
// PythonShell does not support return
|
||||||
var seasonedMediaObjects = result.MediaContainer.Metadata.reduce(function(match, media_item) {
|
};
|
||||||
if (media_item.type === 'movie' || media_item.type === 'show') {
|
|
||||||
match.push(convertPlexToSeasoned(media_item));
|
async function SearchPiratebay(query) {
|
||||||
}
|
return await new Promise((resolve) => {
|
||||||
return match;
|
return find(query, function(err, results) {
|
||||||
}, []);
|
resolve(JSON.parse(results, null, '\t'));
|
||||||
return seasonedMediaObjects;
|
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
|
||||||
throw new Error(err);
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = PirateRepository;
|
module.exports = { SearchPiratebay }
|
||||||
Reference in New Issue
Block a user