2016-2-21 00:15 /
主要的麻烦是连接不稳定……
下面直接上代码好了
Unhandled rejection Error: connect ETIMEDOUT 104.25.77.5:80
at Object.exports._errnoException (util.js:856:11)
at exports._exceptionWithHostPort (util.js:879:20)
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1062:14)
Unhandled rejection Error: connect ETIMEDOUT 104.25.77.5:80
at Object.exports._errnoException (util.js:856:11)
at exports._exceptionWithHostPort (util.js:879:20)
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1062:14)
下面直接上代码好了
'use strict';
var Promise = require('bluebird');
var request = Promise.promisifyAll(require('request'));
var BlueBirdQueue = require('bluebird-queue');
var queue = new BlueBirdQueue({
concurrency: 5
});
var origUid = "";
var newUid = "";
var origUserName = "";
var newUserName = "";
var newCookie = "Cookie数据";
var animates = []
.concat([原账号的ID数据]);
var origAuthToken = "";
var newAuthToken = "";
request.postAsync({
url: 'http://api.bgm.tv/auth?source=onAir',
form: {
password: '原账号密码',
username: '用户名',
source: 'onAir',
auth: 0,
sysuid: 0,
sysusername: 0,
}
})
.then(resp => JSON.parse(resp.body))
.then(body => {
origUid = body.id;
origUserName = body.username;
origAuthToken = body.auth;
return request.postAsync({
url: 'http://api.bgm.tv/auth?source=onAir',
form: {
password: '新账号密码',
username: '账户名',
source: 'onAir',
auth: 0,
sysuid: 0,
sysusername: 0,
}
}).then(resp => JSON.parse(resp.body))
})
.then(body => {
newUid = body.id;
newUserName = body.username;
newAuthToken = body.auth;
return true;
})
.then(() => {
animates.map(item => {
queue.add(request.postAsync({
url: `http://api.bgm.tv/collection/${item}?source=onAir&sysusername=${origUid}&sysuid=${origUid}&auth=${origAuthToken}`,
}).then(resp => {
return { item, body: JSON.parse(resp.body) }
}).then(data => {
let body = data.body;
let item = data.item;
console.info(`GOT ${item}`);
return request.postAsync({
url: `http://bgm.tv/subject/${item}/interest/update?gh=自己查`,
form: {
referer: 'subject',
interest: 2,
rating: body.rating,
tags: '',
comment: '',
},
headers: {
Cookie: newCookie,
'User-Agent': '哈哈哈'
}
}).then(request.postAsync({
url: `http://bgm.tv/subject/set/watched/${item}`,
form: {
referer: 'subject',
watchedeps: body.ep_status
},
headers: {
Cookie: newCookie,
'User-Agent': '哈哈哈'
}
}));
}).then(() => {
console.log(`${item} succeed`)
}))
})
})
#1 - 2016-2-21 00:21
nops (I'm Angry)