Skip to content

Commit 7a75bcf

Browse files
committed
bump version
fix;pypi 完善;readme 修改
1 parent eb0d616 commit 7a75bcf

File tree

5 files changed

+25
-8
lines changed

5 files changed

+25
-8
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,3 +100,4 @@ ENV/
100100

101101

102102
.idea/
103+
private/

README.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
# danmu
1+
# danmu-abc
22

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。
44

55
## 接口:
66
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)。清理完后,重新开启新的连接。
77
1. [close_and_clean](https://github.com/yjqiang/danmu/blob/9dc40b556709b895cbfc690e37d0b8e3fe57ffe2/client.py#L128) 用于永久地关闭连接。
88
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) 唤醒。
99

10-
1110
## 版权问题:
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 也进行相应变动。

danmu_abc/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__version__ = '0.1.2'
1+
__version__ = '0.1.3'
22

33
from .client import Client as Client
44
from .conn import WsConn as WsConn

danmu_abc/conn.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,9 @@ async def send_bytes(self, bytes_data: bytes) -> bool:
8888
async def read_bytes(
8989
self,
9090
n: Optional[int] = None) -> Optional[bytes]:
91+
# 不支持的原因是,tcp 会切数据,自己拼装过于复杂
9192
if n is None or n <= 0:
92-
return b''
93+
return None
9394
try:
9495
bytes_data = await asyncio.wait_for(
9596
self._reader.readexactly(n), timeout=self._receive_timeout)

setup.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,29 @@
1+
import re
2+
import pathlib
3+
14
from setuptools import setup
25

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()
418

519

620
setup(
721
name='danmu_abc',
822
packages=['danmu_abc'],
9-
version=VERSION,
23+
version=version,
1024
description='Danmu for humans.',
25+
long_description=read('README.md'),
26+
long_description_content_type='text/markdown',
1127
license='MIT',
1228
author='yjqang',
1329
author_email='[email protected]',

0 commit comments

Comments
 (0)