From 48c89a6bdeeeb60c8b0b0dfe6195d04d65a0cc15 Mon Sep 17 00:00:00 2001 From: wbt5 Date: Thu, 18 Jun 2020 10:22:14 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=BB=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- danmu/main.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 danmu/main.py diff --git a/danmu/main.py b/danmu/main.py new file mode 100644 index 0000000..aeeab8d --- /dev/null +++ b/danmu/main.py @@ -0,0 +1,29 @@ +# 部分弹幕功能代码来自项目:https://github.com/IsoaSFlus/danmaku,感谢大佬 +# 快手弹幕代码来源及思路:https://github.com/py-wuhao/ks_barrage,感谢大佬 +# 仅抓取用户弹幕,不包括入场提醒、礼物赠送等。 + +import asyncio +import danmaku + + +async def printer(q): + while True: + m = await q.get() + if m['msg_type'] == 'danmaku': + print(f'{m["name"]}:{m["content"]}') + + +async def main(url): + q = asyncio.Queue() + dmc = danmaku.DanmakuClient(url, q) + asyncio.create_task(printer(q)) + await dmc.start() + + +a = input('请输入直播间地址:\n') +asyncio.run(main(a)) + +# 虎牙:https://www.huya.com/11352915 +# 斗鱼:https://www.douyu.com/85894 +# B站:https://live.bilibili.com/70155 +# 快手:https://live.kuaishou.com/u/jjworld126