@@ -1,13 +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 PythonShell = require('python-shell');
|
||||
|
||||
var options = {
|
||||
// pythonPath: '/usr/bin/python3',
|
||||
pythonPath: '/Library/Frameworks/Python.framework/Versions/3.6/bin/python3',
|
||||
pythonPath: '/usr/bin/python3',
|
||||
// pythonPath: '/Library/Frameworks/Python.framework/Versions/3.6/bin/python3',
|
||||
args: [searchterm]
|
||||
}
|
||||
|
||||
@@ -15,6 +15,17 @@ async function find(searchterm, callback) {
|
||||
// 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) {
|
||||
return await new Promise((resolve) => {
|
||||
return find(query, function(err, results) {
|
||||
@@ -23,4 +34,12 @@ async function SearchPiratebay(query) {
|
||||
})
|
||||
}
|
||||
|
||||
module.exports = { SearchPiratebay }
|
||||
async function AddMagnet(magnet) {
|
||||
return await new Promise((resolve) => {
|
||||
return callPythonAddMagnet(magnet, function(err, results) {
|
||||
resolve({ success: true })
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
module.exports = { SearchPiratebay, AddMagnet }
|
||||
@@ -74,7 +74,8 @@ router.get('/v1/plex/requests/all', mustBeAuthenticated, require('./controllers/
|
||||
router.put('/v1/plex/request/:requestId', mustBeAuthenticated, require('./controllers/plex/updateRequested.js'));
|
||||
|
||||
// TODO ADD AUTHENTICATION
|
||||
router.get('/v1/pirate/search', require('./controllers/pirate/searchTheBay.js'));
|
||||
router.get('/v1/pirate/search', mustBeAuthenticated, require('./controllers/pirate/searchTheBay.js'));
|
||||
router.post('/v1/pirate/add', mustBeAuthenticated, require('./controllers/pirate/addMagnet.js'));
|
||||
|
||||
/**
|
||||
* TMDB
|
||||
|
||||
23
seasoned_api/src/webserver/controllers/pirate/addMagnet.js
Normal file
23
seasoned_api/src/webserver/controllers/pirate/addMagnet.js
Normal file
@@ -0,0 +1,23 @@
|
||||
|
||||
/*
|
||||
* @Author: KevinMidboe
|
||||
* @Date: 2017-10-21 09:54:31
|
||||
* @Last Modified by: KevinMidboe
|
||||
* @Last Modified time: 2017-10-21 15:32:43
|
||||
*/
|
||||
|
||||
const PirateRepository = require('src/pirate/pirateRepository');
|
||||
|
||||
function updateRequested(req, res) {
|
||||
const magnet = req.body.magnet;
|
||||
|
||||
PirateRepository.AddMagnet(magnet)
|
||||
.then((result) => {
|
||||
res.send(result);
|
||||
})
|
||||
.catch((error) => {
|
||||
res.status(401).send({ success: false, error: error.message });
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = updateRequested;
|
||||
Reference in New Issue
Block a user