某鱼弹幕

[复制链接]
作者: samdam | 时间: 2021-6-10 13:20:37 | python源码分享|
1 88
发表于 2021-6-10 13:20:37| 显示全部楼层 |阅读模式
import asyncio
import logging
from aiowebsocket.converses import AioWebSocket

async def starup(url,roomID):
    async with AioWebSocket(url) as aws:
        converse=aws.manipulator
        str = 'type@=loginreq/roomid@='+roomID+'/dfl@=sn@AA=106@ASss@AA=1@Ssn@AA=107@ASss@AA=1@Ssn@AA=108@ASss@AA=1@Ssn@AA=105@ASss@AA=1@Ssn@AA=110@ASss@AA=1@Ssn@AA=undefined@ASss@AA=1/username@=auto_EAwjDnGRtL/password@=/ltkid@=39670780/biz@=1/stk@=93f56068b5260f1a/devid@=f5ff75871cf977cbe2f02b7100041501/ct@=0/pt@=2/cvr@=0/tvr@=7/apd@=/rt@=1623125597/vk@=503a77fd8b20dd3ffdf73dcfbc980944/ver@=20190610/aver@=218101901/dmbt@=chrome/dmbv@=77/er@=1/'
        bytes = b'\xb7\x01\x00\x00\xb7\x01\x00\x00\xb1\x02\x00\x00' + str.encode('gbk') + b'\x00'
        await converse.send(bytes)
        str='type@=joingroup/rid@='+roomID+'/gid@=1/'
        bytes=b'\x2c\x00\x00\x00\x2c\x00\x00\x00\xb1\x02\x00\x00'+str.encode('gbk')+b'\00'
        await converse.send(bytes)
        str = 'type@=mrkl/'
        bytes = b'\x14\x00\x00\x00\x14\x00\x00\x00\xb1\x02\x00\x00' + str.encode('gbk') + b'\00'
        await converse.send(bytes)
        num=0
        while True:
            num+=1
            if num%60==0:
                str = 'type@=mrkl/'
                bytes = b'\x14\x00\x00\x00\x14\x00\x00\x00\xb1\x02\x00\x00' + str.encode('gbk') + b'\00'
                await converse.send(bytes)
            try:
                receive=await converse.receive()
                if len(receive)>=26:
                    #print(receive[8:12])  # 接受
                    if receive[8:12] == b'\xb2\x02\x00\x00':
                        if receive[12:26] == b'type@=chatmsg/':
                            bytes = receive[26:-1]
                            c=bytes.split(b'rid@=')
                            c = c[1].split(b'/')
                            str=c[0]
                            room=str.decode()
                            c = bytes.split(b'nn@=')
                            c = c[1].split(b'/txt@=')
                            str = (c[0])
                            name = str.decode()
                            c = c[1].split(b'/cid@=')
                            str = (c[0])
                            speak = str.decode()
                            print('roomID:'+room+'   '+name + ': ' + speak)
            except:
                pass
if __name__=='__main__':
    remote='wss://danmuproxy.douyu.com:8506/'

    try:
        asyncio.get_event_loop().run_until_complete(starup(remote,'312212'))
    except KeyboardInterrupt as exc:
        logging.info('Quit.')

签到天数: 19 天

发表于 2021-6-10 18:00:33| 显示全部楼层
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

!jz_fbzt! 快速回复 !jz_sctz! !jz_fhlb! 按钮
快速回复 返回列表 返回顶部