File tree Expand file tree Collapse file tree 5 files changed +25
-8
lines changed Expand file tree Collapse file tree 5 files changed +25
-8
lines changed Original file line number Diff line number Diff line change 100
100
101
101
102
102
.idea /
103
+ private /
Original file line number Diff line number Diff line change 1
- # danmu
1
+ # danmu-abc
2
2
3
- 获取[ 哔哩哔哩] ( https://live.bilibili.com ) 、[ 斗鱼] ( https://www.douyu.com ) 、[ 虎牙] ( https://www.huya.com ) 以及 [ YjMonitor] ( https://github.com/yjqiang/YjMonitor ) 项目自定义的弹幕推送 。可选用 websocket 协议与 tcp 协议,其中 websocket 协议 [ aiohttp] ( https://github.com/aio-libs/aiohttp ) 的 api 很方便,但是 tcp 的性能非常好,内存占用很低 。
3
+ 获取[ 哔哩哔哩] ( https://live.bilibili.com ) 、[ 斗鱼] ( https://www.douyu.com ) 、[ 虎牙] ( https://www.huya.com ) 以及 [ 个人项目 YjMonitor] ( https://github.com/yjqiang/YjMonitor ) 自定义的弹幕推送 。可选用 websocket 协议与 tcp 协议,其中 websocket 协议使用了 [ aiohttp] ( https://github.com/aio-libs/aiohttp ) 的 api。
4
4
5
5
## 接口:
6
6
1 . [ run_forever] ( https://github.com/yjqiang/danmu/blob/9dc40b556709b895cbfc690e37d0b8e3fe57ffe2/client.py#L78 ) 是程序核心,使用一个 ` while ` 循环实现掉线的自动重连(掉线后,` close ` 掉现在的连接,重开一个新的)。每次的连接分三步,建立并 [ ` OAUTH ` (即 \_ one_hello)] ( https://github.com/yjqiang/danmu/blob/9dc40b556709b895cbfc690e37d0b8e3fe57ffe2/client.py#L41 ) 、[ 心跳] ( https://github.com/yjqiang/danmu/blob/9dc40b556709b895cbfc690e37d0b8e3fe57ffe2/client.py#L45 ) 和[ 接受] ( https://github.com/yjqiang/danmu/blob/9dc40b556709b895cbfc690e37d0b8e3fe57ffe2/client.py#L60 ) 部分启动并永久执行直到异常或主动关闭、异常或主动关闭后的[ 清理工作] ( https://github.com/yjqiang/danmu/blob/9dc40b556709b895cbfc690e37d0b8e3fe57ffe2/client.py#L102-L111 ) 。清理完后,重新开启新的连接。
7
7
1 . [ close_and_clean] ( https://github.com/yjqiang/danmu/blob/9dc40b556709b895cbfc690e37d0b8e3fe57ffe2/client.py#L128 ) 用于永久地关闭连接。
8
8
1 . [ pause] ( https://github.com/yjqiang/danmu/blob/9dc40b556709b895cbfc690e37d0b8e3fe57ffe2/client.py#L119 ) 用于暂停连接,暂停后,连接是[ 断开] ( https://github.com/yjqiang/danmu/blob/9dc40b556709b895cbfc690e37d0b8e3fe57ffe2/client.py#L84 ) 的。直到 [ resume] ( https://github.com/yjqiang/danmu/blob/9dc40b556709b895cbfc690e37d0b8e3fe57ffe2/client.py#L123 ) 唤醒。
9
9
10
-
11
10
## 版权问题:
12
- 1 . 本代码 fork 自 [ blivedm] ( https://github.com/xfgryujk/blivedm ) ,由于与作者一些观点不同 ,并未走向一致,后由于一些原因,在与原作者 [ 协商] ( https://github.com/xfgryujk/blivedm/issues/9 ) 后切断 fork 关系。LICENSE 也进行相应变动。
11
+ 1 . 本代码 fork 自 [ blivedm] ( https://github.com/xfgryujk/blivedm ) ,由于与原作者一些观点不同 ,并未走向一致,后由于一些原因,在于原作者 [ 协商] ( https://github.com/xfgryujk/blivedm ) 后切断 fork 关系。LICENSE 也进行相应变动。
Original file line number Diff line number Diff line change 1
- __version__ = '0.1.2 '
1
+ __version__ = '0.1.3 '
2
2
3
3
from .client import Client as Client
4
4
from .conn import WsConn as WsConn
Original file line number Diff line number Diff line change @@ -88,8 +88,9 @@ async def send_bytes(self, bytes_data: bytes) -> bool:
88
88
async def read_bytes (
89
89
self ,
90
90
n : Optional [int ] = None ) -> Optional [bytes ]:
91
+ # 不支持的原因是,tcp 会切数据,自己拼装过于复杂
91
92
if n is None or n <= 0 :
92
- return b''
93
+ return None
93
94
try :
94
95
bytes_data = await asyncio .wait_for (
95
96
self ._reader .readexactly (n ), timeout = self ._receive_timeout )
Original file line number Diff line number Diff line change
1
+ import re
2
+ import pathlib
3
+
1
4
from setuptools import setup
2
5
3
- VERSION = '0.1.2'
6
+
7
+ HERE = pathlib .Path (__file__ ).parent
8
+
9
+ txt = (HERE / 'danmu_abc' / '__init__.py' ).read_text ('utf-8' )
10
+ try :
11
+ version = re .findall (r"^__version__ = '([^']+)'\r?$" , txt , re .M )[0 ]
12
+ except IndexError :
13
+ raise RuntimeError ('Unable to determine the version.' )
14
+
15
+
16
+ def read (f ):
17
+ return (HERE / f ).read_text ('utf-8' ).strip ()
4
18
5
19
6
20
setup (
7
21
name = 'danmu_abc' ,
8
22
packages = ['danmu_abc' ],
9
- version = VERSION ,
23
+ version = version ,
10
24
description = 'Danmu for humans.' ,
25
+ long_description = read ('README.md' ),
26
+ long_description_content_type = 'text/markdown' ,
11
27
license = 'MIT' ,
12
28
author = 'yjqang' ,
13
29
You can’t perform that action at this time.
0 commit comments