Skip to content

Commit

Permalink
remove: 移除web支持
Browse files Browse the repository at this point in the history
  • Loading branch information
flxxyz committed Jan 3, 2021
1 parent bed0713 commit 6ecc6b1
Show file tree
Hide file tree
Showing 18 changed files with 37 additions and 7,359 deletions.
67 changes: 14 additions & 53 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,91 +1,51 @@
# douyudanmu
实时获取斗鱼弹幕
# douyudm

基于websocket实时获取斗鱼弹幕

<a href="https://npmcharts.com/compare/vue?minimal=true"><img src="https://img.shields.io/npm/dm/douyudm.svg?sanitize=true" alt="Downloads" /></a>
<a href="https://www.npmjs.com/package/douyudm"><img src="https://img.shields.io/npm/v/douyudm.svg?sanitize=true" alt="Version" /></a>
<a href="https://www.npmjs.com/package/douyudm"><img src="https://img.shields.io/npm/l/douyudm.svg?sanitize=true" alt="License" /></a>

> \>= 1.1.1 支持所有消息输出到文件
> \>= 2.0.0 不再支持**WEB**引用
## 安装(命令行)

```shell
npm i -g douyudm
or
yarn global add douyudm
```

## 使用(命令行)

通过命令行监听,默认显示,`--debug`开启输出到文件,默认保存当前运行目录

```shell
douyudm -i 房间号
```
更多命令查看 `douyudm --help`

## 安装(WEB)
建议在html顶部位置引入js文件
```
<script src="https://flxxyz.github.io/douyudm/dist/douyudanmaku.min.js"></script>
```

## 使用(WEB)
挂载在window下,可通过 `douyudanmaku`, `danmaku`调用
```
<script>
window.onload = function() {
var room = new danmaku(roomId, {
debug: false, //存储到indexedDB
})
//系统事件
room.on('connect', function() {
console.log('[connect] roomId=%s', this.roomId)
})
room.on('disconnect', function() {
console.log('[disconnect] roomId=%s', this.roomId)
})
room.on('error', function(err) {
console.log('[error] roomId=%s', this.roomId)
})
//消息事件
room.on('chatmsg', function(res) {
console.log('[chatmsg]', `<lv ${res.level}> [${res.nn}] ${res.txt}`)
})
room.on('loginres', function(res) {
console.log('[loginres]', '登录成功')
})
room.on('uenter', function(res) {
console.log('[uenter]', `${res.nn}进入房间`)
})
//开始监听
room.run()
//导出日志(不传入房间号默认为所有)
room.logger.export(房间号)
//清除日志(不传入房间号默认为所有)
room.logger.clear(房间号)
}
</script>
```
更多命令查看 `douyudm --help`

## 安装(API)

```shell
npm i douyudm
or
yarn add douyudm
```

## 使用(API)

通过库调用自行封装

```javascript
//引入类库
const douyu = require('douyudm')

//设置房间号,初始化
const roomId = 102965
const opts = {
debug: false,
logfile: `/自定义路径/${roomId}.log`, //默认保存到当前运行目录,格式: 房间号.log
debug: true, // 默认关闭 false
}
const room = new douyu(roomId, opts)

Expand Down Expand Up @@ -116,6 +76,7 @@ room.run()
```

## 事件列表

| 系统事件 | 描述 |
|:----------:|:--------:|
| connect | 连接 |
Expand Down Expand Up @@ -167,7 +128,6 @@ room.run()
| configscreen | 估计是全屏广播显示礼物 |
| rnewbc | 未知的消息事件 |


## 斗鱼STT序列化反序列化库

STT序列化规定如下:
Expand All @@ -186,12 +146,13 @@ yarn test:stt
```

## 后话

坑太多了,github上的库大部分都是不能使用的,如果近期更新的可以判断使用的新接口,review了几乎所有相关的库,都是依据斗鱼自己官方平台的方法发起tcp连接?但根本连不上,一直拒绝...

看了下能使用的库,都是通过websocket建立的连接,立马修改,不出片刻撸完,发现发送数据的格式有点难搞,虽说示意图挺清楚的,但是用Buffer传输死活没有相应的消息,调试太磨人心性了,玛德,直接去把斗鱼网页上的方法扒下来。

通过webpack打包混淆代码乍一眼看去很混乱,其实仔细观察还是有规律寻找的。

文档中编码的几个固定参数均为数字,在webpack中数字的混淆我还没见过,按这个思路精准的找到这段代码。经过我十几分钟的理解,提取出 [**bufferCoder.js**](src/bufferCoder.js)
文档中编码的几个固定参数均为数字,在webpack中数字的混淆我还没见过,按这个思路精准的找到这段代码。经过我十几分钟的理解,提取出 [**bufferCoder.js**](test/old/bufferCoder.js)

斗鱼自有的序列化,反序列化方法可以查看 [**stt.js**](src/stt.js)
1 change: 0 additions & 1 deletion build/.gitignore

This file was deleted.

10 changes: 0 additions & 10 deletions build/config/dev.js

This file was deleted.

58 changes: 0 additions & 58 deletions build/config/index.js

This file was deleted.

10 changes: 0 additions & 10 deletions build/config/prod.js

This file was deleted.

5 changes: 0 additions & 5 deletions build/index.js

This file was deleted.

28 changes: 0 additions & 28 deletions build/package.json

This file was deleted.

Loading

0 comments on commit 6ecc6b1

Please sign in to comment.