LyzenX / DouyinLiveRecorder

一个自动监测和录制抖音直播的工具,支持录制弹幕,以GUI或命令行形式运行,支持linux,无需设置cookie,不使用selenium,开箱即用。
646 stars 104 forks source link

添加礼物录制(damu_recorder.py) #52

Open minmin0516 opened 2 months ago

minmin0516 commented 2 months ago

添加如下代码即可添加礼物录制 ` if msg.method == 'WebcastGiftMessage': chatMessage = ChatMessage() chatMessage.ParseFromString(msg.payload) data = json_format.MessageToDict(chatMessage, preserving_proto_field_name=True) now = time.time() second = now - self.start_time_t self.danmu_amount += 1 self.last_danmu_time = now giftInfo = data['common']['describe'] createTime = data['common']['createTime'] if(len(createTime) == 13):

写入单条数据

                with open(self.giftfilename, 'a', encoding='UTF-8') as file:
                    file.write(f"  <d p=\"{round(second, 2)},1,25,16777215,"
                               f"{int(now * 1000)},0,1602022773,0\" user=\"{giftInfo.split(':')[0]}\">{giftInfo}</d>\n")`
dfrrk commented 2 weeks ago

感谢!很有用!!++1