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');
|
const assert = require('assert');
|
||||||
var PythonShell = require('python-shell');
|
var PythonShell = require('python-shell');
|
||||||
var async = require('async');
|
var async = require('async');
|
||||||
var PythonShell = require('python-shell');
|
|
||||||
|
|
||||||
async function find(searchterm, callback) {
|
async function find(searchterm, callback) {
|
||||||
|
|
||||||
var options = {
|
var options = {
|
||||||
// pythonPath: '/usr/bin/python3',
|
pythonPath: '/usr/bin/python3',
|
||||||
pythonPath: '/Library/Frameworks/Python.framework/Versions/3.6/bin/python3',
|
// pythonPath: '/Library/Frameworks/Python.framework/Versions/3.6/bin/python3',
|
||||||
args: [searchterm, '-s', 'jackett', '--print']
|
args: [searchterm, '-s', 'piratebay', '--print']
|
||||||
}
|
}
|
||||||
|
|
||||||
PythonShell.run('../app/torrent_search/torrentSearch/search.py', options, callback);
|
PythonShell.run('../app/torrent_search/torrentSearch/search.py', options, callback);
|
||||||
@@ -27,10 +26,16 @@ async function callPythonAddMagnet(magnet, callback) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function SearchPiratebay(query) {
|
async function SearchPiratebay(query) {
|
||||||
return await new Promise((resolve) => {
|
return await new Promise((resolve, reject) => {
|
||||||
return find(query, function(err, results) {
|
return find(query, function(err, results) {
|
||||||
console.log('err', err, '. result', results);
|
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'));
|
resolve(JSON.parse(results, null, '\t'));
|
||||||
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user