Changed the app search site from jackett to piratebay and added some better handling of errors, now the server does not instantly crash on a error.
This commit is contained in:
@@ -1,14 +1,13 @@
|
||||
const assert = require('assert');
|
||||
var PythonShell = require('python-shell');
|
||||
var async = require('async');
|
||||
var PythonShell = require('python-shell');
|
||||
|
||||
async function find(searchterm, callback) {
|
||||
|
||||
var options = {
|
||||
// pythonPath: '/usr/bin/python3',
|
||||
pythonPath: '/Library/Frameworks/Python.framework/Versions/3.6/bin/python3',
|
||||
args: [searchterm, '-s', 'jackett', '--print']
|
||||
pythonPath: '/usr/bin/python3',
|
||||
// pythonPath: '/Library/Frameworks/Python.framework/Versions/3.6/bin/python3',
|
||||
args: [searchterm, '-s', 'piratebay', '--print']
|
||||
}
|
||||
|
||||
PythonShell.run('../app/torrent_search/torrentSearch/search.py', options, callback);
|
||||
@@ -27,10 +26,16 @@ async function callPythonAddMagnet(magnet, callback) {
|
||||
}
|
||||
|
||||
async function SearchPiratebay(query) {
|
||||
return await new Promise((resolve) => {
|
||||
return await new Promise((resolve, reject) => {
|
||||
return find(query, function(err, results) {
|
||||
console.log('err', err, '. result', results);
|
||||
resolve(JSON.parse(results, null, '\t'));
|
||||
if (err) {
|
||||
console.log('THERE WAS A FUCKING ERROR!')
|
||||
reject(Error('There was a error when searching for torrents'))
|
||||
}
|
||||
if (results) {
|
||||
console.log('result', results);
|
||||
resolve(JSON.parse(results, null, '\t'));
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user