You've already forked Douyin_Web_Live
尝试大改,可读性有点差的版本,基本做到能实时处理弹幕
This commit is contained in:
6
output/DebugWriter.py
Normal file
6
output/DebugWriter.py
Normal file
@ -0,0 +1,6 @@
|
||||
from output import IOutput
|
||||
|
||||
|
||||
class DebugWriter(IOutput):
|
||||
def other_output(self, message_type: str, message_raw: bytes):
|
||||
print(message_type)
|
36
output/IOutput.py
Normal file
36
output/IOutput.py
Normal file
@ -0,0 +1,36 @@
|
||||
from messages.base import Base
|
||||
from messages.chat import ChatMessage
|
||||
from messages.gift import GiftMessage
|
||||
from messages.like import LikeMessage
|
||||
from messages.member import MemberMessage
|
||||
from messages.roomuserseq import RoomUserSeqMessage
|
||||
from messages.social import SocialMessage
|
||||
|
||||
|
||||
class IOutput():
|
||||
def output(self, message_type: str, message_obj: Base):
|
||||
...
|
||||
|
||||
def chat_output(self, message: ChatMessage):
|
||||
...
|
||||
|
||||
def like_output(self, message: LikeMessage):
|
||||
...
|
||||
|
||||
def member_output(self, message: MemberMessage):
|
||||
...
|
||||
|
||||
def social_output(self, message: SocialMessage):
|
||||
...
|
||||
|
||||
def gift_output(self, message: GiftMessage):
|
||||
...
|
||||
|
||||
def userseq_output(self, message: RoomUserSeqMessage):
|
||||
...
|
||||
|
||||
def other_output(self, message_type: str, message_raw: bytes):
|
||||
...
|
||||
|
||||
def error_output(self, exception: Exception):
|
||||
...
|
3
output/README.md
Normal file
3
output/README.md
Normal file
@ -0,0 +1,3 @@
|
||||
# 输出模块
|
||||
|
||||
主要放置输出模块,建议继承IOutput,解析模块中所有解析的内容均基于IOutput进行适配
|
6
output/__init__.py
Normal file
6
output/__init__.py
Normal file
@ -0,0 +1,6 @@
|
||||
from output.IOutput import IOutput
|
||||
from output.print import Print
|
||||
|
||||
OUTPUTER = [
|
||||
Print()
|
||||
]
|
33
output/print.py
Normal file
33
output/print.py
Normal file
@ -0,0 +1,33 @@
|
||||
from colorama import init, Fore
|
||||
|
||||
from output import IOutput
|
||||
|
||||
RED = Fore.RED
|
||||
GREEN = Fore.GREEN
|
||||
BLUE = Fore.BLUE
|
||||
CYAN = Fore.CYAN
|
||||
MAGENTA = Fore.MAGENTA
|
||||
YELLOW = Fore.YELLOW
|
||||
WHITE = Fore.WHITE
|
||||
RESET = Fore.RESET
|
||||
init()
|
||||
|
||||
|
||||
class Print(IOutput):
|
||||
def chat_output(self, msg):
|
||||
print(f"\n{BLUE}[+] {msg} {RESET}")
|
||||
|
||||
def like_output(self, msg):
|
||||
print(f"\n{CYAN}[+] {msg} {RESET}")
|
||||
|
||||
def member_output(self, msg):
|
||||
print(f"\n{RED}[+] {msg} {RESET}")
|
||||
|
||||
def social_output(self, msg):
|
||||
print(f"\n{GREEN}[+] {msg} {RESET}")
|
||||
|
||||
def gift_output(self, msg):
|
||||
print(f"\n{MAGENTA}[+] {msg} {RESET}")
|
||||
|
||||
def userseq_output(self, msg):
|
||||
print(f"\n{YELLOW}[+] {msg} {RESET}")
|
Reference in New Issue
Block a user