Skip to content

Commit

Permalink
new version number
Browse files Browse the repository at this point in the history
  • Loading branch information
axe-me committed May 21, 2016
1 parent f9c0c7a commit 929c183
Show file tree
Hide file tree
Showing 3 changed files with 99 additions and 104 deletions.
2 changes: 1 addition & 1 deletion app/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Fishbone",
"version": "0.1.2",
"version": "1.0.0",
"description": "Fishbone--DouyuTv Danmu Helper",
"main": "main.js",
"author": "[email protected]",
Expand Down
199 changes: 97 additions & 102 deletions build/scripts/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@

function chatService(
util,
md5,
lodash,
$http,
$interval,
Expand All @@ -79,6 +78,7 @@
var danmuClient;
var rollType;
var rollKey;
var roomInfoApiRoot = 'http://open.douyucdn.cn/api/RoomApi/room/';

$rootScope.$on('abortCurrConn', function () {
console.log('ending client...');
Expand Down Expand Up @@ -129,45 +129,36 @@
}

function updateRoomInfo (roomID) {
var baseURL = "http://capi.douyucdn.cn/api/v1/room/" + roomID;
var urlMid = "?aid=android&client_sys=android&time=";
var time = Math.ceil(Date.now()/1000);
var auth = md5.createHash("room/"+roomID+urlMid+time+"1231");
var requestURL = baseURL + urlMid + time + "&auth=" + auth

$http.get(requestURL)
$http.get(roomInfoApiRoot+roomID)
.then(function (response) {
var rInfo = response.data.data;
service.roomInfo.roomName = rInfo.room_name;
service.roomInfo.spectator = rInfo.online;
service.roomInfo.isLive = parseInt(rInfo.room_status);
}, function (err) {
console.log(err);
})
}

function getRoomInfo (roomAddr) {
var html;
var roomRegex = /var\s\$ROOM\s=\s({.*})/;
var authServerRegex = /server_config":"(.*)",/;
var giftConfigRegex =/ROOM.giftBatterConfig = (.*);/;
var roomID = roomAddr.split('/')[3];

util.showMsg("开始获取房间信息");
http.get(roomAddr, function (res) {
var html = "";
util.showMsg("获取房间信息中...");
res.on("data", function(data) {
html += data;
});

res.on('end', function () {
var roomObj = angular.fromJson(roomRegex.exec(html)[1]);
$http.get(roomInfoApiRoot+roomID)
.then(function (response) {
var roomInfo = response.data.data;
console.log(roomInfo);
util.giftConfig=roomInfo.gift;

util.giftConfig=angular.fromJson(giftConfigRegex.exec(html)[1]);
service.roomInfo.anchor = roomInfo.owner_name;
service.roomInfo.roomName = roomInfo.room_name;
service.roomInfo.roomID = roomInfo.room_id;
service.roomInfo.spectator = roomInfo.online;
service.roomInfo.isLive = parseInt(roomInfo.room_status); // live:1 offline:2

service.roomInfo.anchor = roomObj.owner_name;
service.roomInfo.roomName = roomObj.room_name;
service.roomInfo.roomID = roomObj.room_id;
service.roomInfo.isLive = roomObj.show_status; // live:1 offline:2
console.log(service.roomInfo);

//run one time here to get number of online
service.updateRoomInfo(service.roomInfo.roomID);
Expand All @@ -177,12 +168,10 @@
service.roomInfoStatus.isReady = true;

connDanmuServ(service.roomInfo.roomID);

util.showMsg('获取房间信息成功!');
}, function (e) {
util.showMsg('获取房间信息失败!');
});
}).on('error', function (e) {
util.showMsg('获取房间信息失败!');
});
}

function connDanmuServ (roomID) {
Expand Down Expand Up @@ -292,105 +281,107 @@
element.scrollTop = element.scrollHeight + 20;
}

function deserialize (rawData) {
var rawToString = rawData.substring(rawData.indexOf('type@=')).trim();
var dataArr = rawToString.split('/');
var dataObj = {}

var kv = "";
var v;
for (var i = 0; i < dataArr.length-1; i++) {
kv = dataArr[i].split('@=');
v = kv[1];
v = v.replace(/@S/g, '/');
v = v.replace(/@A/g, '@');
dataObj[kv[0]] = v;
};

if (dataObj.type === "bc_buy_deserve") {
console.log(rawData);
dataArr = dataObj.sui.split('/');
dataObj.sui = {};
for (var i = 0; i < dataArr.length-1; i++) {
kv = dataArr[i].split('@=');
v = kv[1];
v = v.replace(/@S/g, '/');
v = v.replace(/@A/g, '@');
dataObj.sui[kv[0]] = v;
};
};
console.log(dataObj);
return dataObj;
}

function parseReadable (rawData) {
var item = {};
var dataObj = deserialize(rawData);

//console.log(rawData.substring(rawData.indexOf('type'),rawData.length-2));

if (rawData.indexOf('chatmessage') > -1 || rawData.indexOf('chatmsg') > -1) { // chat message
if (dataObj.type === 'chatmsg') {
item.type = 'msg';
var nameRegexResult = /\/snick@=(.+?)\//.exec(rawData);
var contentRegexResult = /\/content@=(.+?)\//.exec(rawData);

if (nameRegexResult!==null)
item.userName = nameRegexResult[1];
else{
item.userName = /\/nn@=(.+?)\//.exec(rawData)[1];
}
if (contentRegexResult!==null)
item.content = contentRegexResult[1] || "[斗鱼服务器抽风发了不可识别数据]";
else {
item.content = /\/txt@=(.+?)\//.exec(rawData)[1] || "[斗鱼服务器抽风发了不可识别数据]";
}
item.str = item.userName + ': ' + item.content;
} else if (rawData.indexOf('userenter') > -1 || rawData.indexOf('uenter') > -1) { //user enter
item.userName = dataObj.nn;
item.content = dataObj.txt;
} else if (dataObj.type === 'uenter') {
item.type = 'userEnter';
if (rawData.indexOf('userenter') > -1) {
item.userName = /nick@A=(.+?)@/.exec(rawData)[1];
} else{
item.userName = /nn@=(.+?)\//.exec(rawData)[1];
}

item.str = item.userName + ' 进入直播间';
} else if (rawData.indexOf('dgn') > -1 || rawData.indexOf('dgb') > -1) { // gift
item.userName = dataObj.nn;
} else if (dataObj.type === 'dgb') {
item.type = 'gift';
if (rawData.indexOf('dgn') > -1) {
item.userName = /\/src_ncnm@=(.+?)\//.exec(rawData)[1];
item.hits = /\/hits@=(.+?)\//.exec(rawData)[1];
} else{
item.userName = /\/nn@=(.+?)\//.exec(rawData)[1];
var hitRegexMatch = /hits@=(.+?)\//.exec(rawData);
item.hits = hitRegexMatch===null?1:hitRegexMatch[1];
}
var giftID = /gfid@=(\d+)/.exec(rawData)[1];
var giftInfo = service.giftConfig[giftID];

item.giftValue=giftInfo.pc;
item.userName = dataObj.nn;
item.hits = dataObj.hits;

var giftInfo = {};

for (var i = 0; i < service.giftConfig.length; i++) {
if (service.giftConfig[i].id == dataObj.gfid) {
giftInfo = service.giftConfig[i];
break;
}
};
item.giftValue=giftInfo.gx;

if (giftInfo.type===1) {
if (giftInfo.type==="1") {
if (giftInfo.name!=='100鱼丸')
item.giftName = giftInfo.name+'('+giftInfo.pc+' 鱼丸)';
else
item.giftName = giftInfo.pc+' 鱼丸';
} else {
if (giftInfo.pc === 10) {item.giftValue=100};
item.giftName = giftInfo.name+'('+giftInfo.pc/100+' 鱼翅)';
item.giftName = giftInfo.name+'('+giftInfo.pc+' 鱼翅)';
}

item.icon = giftInfo.cimg;
item.icon = giftInfo.mimg;

item.str = item.userName + '赠送礼物 x' + item.hits;
} else if (rawData.indexOf('blackres') > -1) {
item.type = 'blackList';
item.managerName = /snick@=(.*)\/dnick/.exec(rawData)[1];
item.userName = /dnick@=(.*)\//.exec(rawData)[1];
item.time = /limittime@=(.\d+)/.exec(rawData)[1] / 3600;
} else if (rawData.indexOf('keeplive') > -1) {
//do nothing
item.type = 'keeplive';
} else if (rawData.indexOf('bc_buy_deserve') > -1) {
} else if (dataObj.type === 'bc_buy_deserve') {
item.type = 'gift';
item.userName = /Snick@A=(.*)@Srg/.exec(rawData)[1];
item.hits = /hits@=(\d)/.exec(rawData)[1];
console.log(dataObj);
item.userName = dataObj.sui.nick;
item.hits = dataObj.hits;

var lvl = /lev@=(\d)/.exec(rawData)[1];
var lvl = dataObj.lev;
if (lvl==1) {
item.giftName = "初级酬勤";
item.giftValue = 15000;
item.giftValue = 150;
};
if (lvl==2) {
item.giftName = "中级酬勤";
item.giftValue = 30000;
item.giftValue = 300;
};
if (lvl==3) {
item.giftName = "高级酬勤";
item.giftValue = 50000;
item.giftValue = 500;
};
} else { //__________ other
console.log(rawData);
/********************
* type@=bc_buy_deserve/level@=3/lev@=3/rid@=138286/gid@=80/cnt@=1/hits@=4/sid@=1895348/sui@=id@A=1895348@Sname@A=qq_GtBWGI1K@Snick@A=Leslie最爱雷同学@Srg@A=1@Spg@A=1@Srt@A=1408094829@Sbg@A=0@Sweight@A=500@Sstrength@A=12700@Scps_id@A=0@Sps@A=1@Ses@A=1@Sver@A=20150929@Sm_deserve_lev@A=3@Scq_cnt@A=1@Sbest_dlev@A=0@Sglobal_ban_lev@A=0@Sexp@A=12700@Slevel@A=3@Scurr_exp@A=7200@Sup_need@A=1800@Sgt@A=0@S/
* type@=donateres/rid@=138286/gid@=88/ms@=100/sb@=208/src_strength@=10100/dst_weight@=439625822/hc@=1/r@=0/gfid@=1/gfcnt@=0/sui@=id@A=13782391@Srg@A=1@Snick@A=2860641930@Scur_lev@A=0@Scq_cnt@A=0@Sbest_dlev@A=0@Slevel@A=4@S/
* Known unknown data
* 别房间的火箭 type@=spbc/sn@=点赞哥/dn@=環妹你好/gn@=火箭/gc@=1/drid@=170587/gs@=6/gb@=1/es@=1/gfid@=59/eid@=7/rid@=20360/gid@=74/
* 用户升级 type@=upgrade/uid@=34667344/rid@=52/gid@=262/nn@=小不懂之魑魅魍魉/level@=4/ douyuMsg.service.js:41
* 房管封人 snick是房管 type@=blackres/rescode@=0/rid@=532152/gid@=80/blacktype@=2/userid@=21706780/limittime@=356400/snick@=周子建建建/dnick@=金色幻想/douyuMsg.service.js:41
* 获得在线酬勤鱼丸 type@=onlinegift/rid@=532152/uid@=5889567/gid@=89/sil@=251/if@=6/ct@=0/nn@=rafeenia/ur@=1/level@=6/
*/
} else if (dataObj.type === 'blackres') {
console.log(dataObj);
item.type = 'blackList';
item.managerName = dataObj.snick;
item.userName = dataObj.dnick;
item.time = parseInt(dataObj.limittime) / 3600;
} else if (dataObj.type === 'keeplive') {
//do nothing
item.type = 'keeplive';
} else {
console.log(dataObj);
item.type = 'unknown';
item.str = 'unknown';

}
};

return item;
}
Expand Down Expand Up @@ -425,7 +416,7 @@ function ChatController($scope, $rootScope, chatService, $interval, util) {

angular.extend($scope, {
isOpenDial: false,
roomAddr: "http://www.douyu.com/chuan967",
roomAddr: "http://www.douyu.com/276506",
startGetMsg: startGetMsg,
roomInfoStatus: chatService.roomInfoStatus,
roomInfo: chatService.roomInfo,
Expand All @@ -443,7 +434,8 @@ function ChatController($scope, $rootScope, chatService, $interval, util) {
openSearchBar: false,
disableScroll: disableScroll,
clearFilter: clearFilter,
getRoomStatusStr: getRoomStatusStr
getRoomStatusStr: getRoomStatusStr,
getRoomStatusClass: getRoomStatusClass
});

$scope.$on('newMsgArrive', function () {
Expand All @@ -452,7 +444,10 @@ function ChatController($scope, $rootScope, chatService, $interval, util) {
});

function getRoomStatusStr () {
return chatService.roomInfo.isLive===1?["直播中","online"]:["未直播","offline"];
return chatService.roomInfo.isLive===1?"直播中":"未直播";
}
function getRoomStatusClass () {
return chatService.roomInfo.isLive===1?"online":"offline";
}

function clearFilter () {
Expand Down
2 changes: 1 addition & 1 deletion build/scripts/chat_room/chat-room.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<div class="room-info-row"
layout="row"
layout-align="space-between center">
<div ng-class="getRoomStatusStr()[1]">{{getRoomStatusStr()[0]}}</div>
<div ng-class="getRoomStatusClass()">{{getRoomStatusStr()}}</div>
<div ng-if="roomInfo.spectator">人气: {{roomInfo.spectator}}</div>
</div>
</div>
Expand Down

0 comments on commit 929c183

Please sign in to comment.