PirateRepo now has a function for calling our add magnet python script with a magnet passed from the controller.
This commit is contained in:
		@@ -1,13 +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 PythonShell = require('python-shell');
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
  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]
 | 
							args: [searchterm]
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -15,6 +15,17 @@ async function find(searchterm, callback) {
 | 
				
			|||||||
  // PythonShell does not support return
 | 
					  // PythonShell does not support return
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					async function callPythonAddMagnet(magnet, callback) {
 | 
				
			||||||
 | 
						var options = {
 | 
				
			||||||
 | 
							pythonPath: '/usr/bin/python3', 
 | 
				
			||||||
 | 
							// pythonPath: '/Library/Frameworks/Python.framework/Versions/3.6/bin/python3',
 | 
				
			||||||
 | 
							args: ['"'+magnet+'"']
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						PythonShell.run('../app/magnet.py', options, callback);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
async function SearchPiratebay(query) {
 | 
					async function SearchPiratebay(query) {
 | 
				
			||||||
	return await new Promise((resolve) => {
 | 
						return await new Promise((resolve) => {
 | 
				
			||||||
		return find(query, function(err, results) {
 | 
							return find(query, function(err, results) {
 | 
				
			||||||
@@ -23,4 +34,14 @@ async function SearchPiratebay(query) {
 | 
				
			|||||||
	})
 | 
						})
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
module.exports = { SearchPiratebay }
 | 
					async function AddMagnet(magnet) {
 | 
				
			||||||
 | 
						return await new Promise((resolve) => {
 | 
				
			||||||
 | 
							return callPythonAddMagnet(magnet, function(err, results) {
 | 
				
			||||||
 | 
								resolve(
 | 
				
			||||||
 | 
									return { success: true }
 | 
				
			||||||
 | 
								)
 | 
				
			||||||
 | 
							})
 | 
				
			||||||
 | 
						})
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					module.exports = { SearchPiratebay, AddMagnet }
 | 
				
			||||||
		Reference in New Issue
	
	Block a user