octavianlee / barrage Goto Github PK
View Code? Open in Web Editor NEW一个开源的b站直播间弹幕助手,主播可以获取直播间内弹幕信息且可以进行发送弹幕功能。
License: MIT License
一个开源的b站直播间弹幕助手,主播可以获取直播间内弹幕信息且可以进行发送弹幕功能。
License: MIT License
Traceback (most recent call last):
File "main.py", line 6, in
hime = DanmakuHime()
File "/Users/JOE/Downloads/Barrage-master-2/danmaku/hime.py", line 19, in init
self.run()
File "/Users/JOE/Downloads/Barrage-master-2/danmaku/hime.py", line 39, in run
self.create_service(option, room_id)
File "/Users/JOE/Downloads/Barrage-master-2/danmaku/hime.py", line 57, in create_service
service.cmd_run()
File "/Users/JOE/Downloads/Barrage-master-2/danmaku/services/reciever.py", line 18, in cmd_run
run_recieve(self.room_id)
File "/Users/JOE/Downloads/Barrage-master-2/danmaku/cores/socket_process.py", line 69, in run_recieve
produce_danmaku.switch(sock, danmaku_queue, True)
File "/Users/JOE/Downloads/Barrage-master-2/danmaku/cores/produce_and_consume.py", line 49, in produce_danmaku
status = process_recieve_data(sock, danmaku_queue, data)
File "/Users/JOE/Downloads/Barrage-master-2/danmaku/cores/danmaku_process.py", line 40, in process_recieve_data
msg = ujson.loads(data)
ValueError: Unmatched ''"' when when decoding 'string'
目测是有人发了引号导致的。
晚上我尝试了许久没有试过的发送弹幕的代码,发现已经不能使用了,未来需要对这个功能进行重新修改,解决该问题。
在登录的时候请求失败。
提示requests.exceptions.TooManyRedirects: Exceeded 30 redirects.
输入代码$: python main.py
反馈如下:
Traceback (most recent call last):
File "main.py", line 3, in
from danmaku.hime import DanmakuHime
File "/Users/RunzeZhao/Downloads/Barrage-master/danmaku/hime.py", line 3, in
from services.sender import SenderService
File "/Users/RunzeZhao/Downloads/Barrage-master/danmaku/services/sender.py", line 5, in
import requests
ImportError: No module named requests
许久没有更新这个项目,能够使用就当作完成了。由于目前b站增加了新的功能,所以打算进行调整开发,不过目前要解决一下代码遗留下来的连接问题,包含:
这些问题的解决涉及到python socket深入的使用,预计代码后能提升整体稳定体验。
由于json中有中文字符,目前为了避免麻烦,临时reload,设置utf-8了,需要用json里面ensureFalse掉。
您所在直播间(Exit 退出助手):92075
请求服务器连接
Traceback (most recent call last):
File "main.py", line 6, in
hime = DanmakuHime()
File "/Users/JOE/Downloads/Barrage-master-2/danmaku/hime.py", line 19, in init
self.run()
File "/Users/JOE/Downloads/Barrage-master-2/danmaku/hime.py", line 39, in run
self.create_service(option, room_id)
File "/Users/JOE/Downloads/Barrage-master-2/danmaku/hime.py", line 57, in create_service
service.cmd_run()
File "/Users/JOE/Downloads/Barrage-master-2/danmaku/services/reciever.py", line 18, in cmd_run
run_recieve(self.room_id)
File "/Users/JOE/Downloads/Barrage-master-2/danmaku/cores/socket_process.py", line 68, in run_recieve
with generate_socket(room_id) as sock:
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/contextlib.py", line 17, in enter
return self.gen.next()
File "/Users/JOE/Downloads/Barrage-master-2/danmaku/cores/socket_process.py", line 31, in generate_socket
send_data = unhexlify(data)
TypeError: Odd-length string
测试其他房间的时候没问题,不知道这个房间的问题是什么。
B站对直播间的功能已经了延展推广,也可以赠送礼物等等,弹幕类型变多了。
现在的方法只是采用try..except做的一个临时性质的解决方案,需要针对新的弹幕结果来进行提取,作为一个新的功能更新。
弹幕姬基础功能库已经完成,为了开发的稳定性,需要编写相应的单元测试。
技术采用 nose+mock的方式编写测试。
目前没有争对处理KeybordError,因此需要添加进这个内容增强体验。
请输入你的选择(Exit 退出):1
您所在直播间(Exit 退出助手):324
请求服务器连接
服务器连接失败...
开始接收弹幕。(Ctrl + C 退出)
为了快速实现功能,仅仅是概念上的分成了生产者和消费者,目前是一种不安全的实现方法,会产生部分不安的状况。
对于接受弹幕部分,需要按照生产者消费者的方式重新编写这块的逻辑,让整个服务能够更加平滑。
大概8分钟会崩溃一次,如果有时间的话请调试
目前项目由于技术上困难,导致requests和urllib2并行使用,为了统一依赖环境,要纯粹依赖python原生的库进行开发,从而使项目变的简便可行。
困难点在于:
目前弹幕姬的基础功能在命令行下已经完成,现在急需做出界面来以便推广使用。
初步方案如下:
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.