add http-proxy

This commit is contained in:
DIYgod 2016-12-10 00:58:04 +08:00
parent 41a0b484bb
commit b5b8334f43
No known key found for this signature in database
GPG Key ID: F8797DD1088C6506
2 changed files with 4 additions and 2 deletions

View File

@ -9,6 +9,7 @@
"dependencies": {
"blueimp-md5": "^2.4.0",
"express": "^4.13.4",
"http-proxy-agent": "^1.0.0",
"log4js": "^0.6.36",
"mongoose": "^4.1.9",
"node-fetch": "^1.6.3",

View File

@ -4,18 +4,19 @@ var redis = require('../tools/redis');
var fetch = require('node-fetch');
var md5 = require('blueimp-md5');
var xml2js = require('xml2js');
var HttpProxyAgent = require('http-proxy-agent');
var parseString = xml2js.parseString;
var appkey = 'f3bb208b3d081dc8';
var secret = '1c15888dc316e05a15fdd0a02ed6584f';
function getData(cid, res, type) {
var sign = md5(`cid=${cid}&from=miniplay&player=1${secret}`);
var api = `https://interface.bilibili.com/playurl?&cid=${cid}&from=miniplay&player=1&sign=${sign}`;
var api = `http://interface.bilibili.com/playurl?&cid=${cid}&from=miniplay&player=1&sign=${sign}`;
if (type === '1') {
res.send(api);
}
else {
fetch(api).then(
fetch(api, { agent:new HttpProxyAgent('http://183.61.236.54:3128/')}).then(
response => response.text()
).then((data) => {
parseString(data, {explicitArray: false}, function (err, result) {