mvp
This commit is contained in:
parent
249c9cb1f3
commit
789a51c6e2
27
app.js
27
app.js
@ -11,30 +11,23 @@ const port = process.env.NODE_PORT || '3000';
|
|||||||
const inject = fs.readFileSync('./inject.html', 'utf8');
|
const inject = fs.readFileSync('./inject.html', 'utf8');
|
||||||
|
|
||||||
const Transmission = require('transmission-promise')
|
const Transmission = require('transmission-promise')
|
||||||
let tr_client = new Transmission({
|
var tr_client = new Transmission({
|
||||||
host:'192.168.1.176',
|
host:'192.168.1.176',
|
||||||
// port: ,
|
|
||||||
username: 'william',
|
username: 'william',
|
||||||
// password: 'palm7',
|
password: 'palm7',
|
||||||
// ssl: true
|
|
||||||
})
|
})
|
||||||
|
|
||||||
tr_client.on('ready', console.log)
|
app.post("/__api/torrent", async function(req, res, next){
|
||||||
|
|
||||||
tr_client.on('error', console.log)
|
if(req.body.api !== '4412') return res.status(421);
|
||||||
|
|
||||||
|
try{
|
||||||
|
let cres = await tr_client.addUrl(Buffer.from(req.body.magnet, 'base64').toString('binary'));
|
||||||
|
console.log(cres)
|
||||||
|
|
||||||
app.post("/__api/torrent", function(req, res, next){
|
}catch(e){
|
||||||
|
console.error('error', e)
|
||||||
console.log('api', req.body)
|
}
|
||||||
|
|
||||||
tr_client.addUrl(Buffer.from(req.body.magnet, 'base64').toString('binary')).then(function(data){
|
|
||||||
console.log(data)
|
|
||||||
res.status('200')
|
|
||||||
}).error(function(err){
|
|
||||||
console.error(err)
|
|
||||||
res.status('500').json({})
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
app.all("/*.js", function(req, res){res.send('')});
|
app.all("/*.js", function(req, res){res.send('')});
|
||||||
|
@ -10,10 +10,7 @@
|
|||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"express": "^4.17.1",
|
"express": "^4.17.1",
|
||||||
"express-request-proxy": "^2.2.2",
|
|
||||||
"http-proxy-middleware": "^0.20.0",
|
"http-proxy-middleware": "^0.20.0",
|
||||||
"node-transmission": "^1.1.0",
|
|
||||||
"nodemon": "^2.0.2",
|
|
||||||
"transmission-promise": "^1.1.4"
|
"transmission-promise": "^1.1.4"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user