20230417
1、修复上次更新带来的mac bug; 2、提高抖音抓取消息的稳定性(注意使用说明);
This commit is contained in:
parent
d80543684a
commit
d405442e27
@ -197,7 +197,7 @@ python main.py
|
|||||||
|
|
||||||
### **使用说明**
|
### **使用说明**
|
||||||
|
|
||||||
+ 抖音虚拟主播:fay控制器(抖音输入源开启、展板播放关闭)+ 数字人 + 抖音伴侣;
|
+ 抖音虚拟主播:启动bin/Release_2.85/2.85.exe + fay控制器(抖音输入源开启、展板播放关闭)+ 数字人 + 抖音伴侣(测试时直接通过浏览器打开别人的直播间);
|
||||||
+ 现场推销货:fay控制器(展板播放关闭、填写商品信息)+ 数字人;
|
+ 现场推销货:fay控制器(展板播放关闭、填写商品信息)+ 数字人;
|
||||||
+ 商品导购:fay控制器(麦克风输入源开启、展板播放关闭、填写商品信息、填写商品Q&A)+ 数字人;
|
+ 商品导购:fay控制器(麦克风输入源开启、展板播放关闭、填写商品信息、填写商品Q&A)+ 数字人;
|
||||||
+ 语音助理:fay控制器(麦克风输入源开启、展板播放开启);
|
+ 语音助理:fay控制器(麦克风输入源开启、展板播放开启);
|
||||||
|
@ -10,9 +10,6 @@ from selenium.webdriver.support.ui import WebDriverWait
|
|||||||
from selenium.webdriver.support.expected_conditions import presence_of_element_located
|
from selenium.webdriver.support.expected_conditions import presence_of_element_located
|
||||||
import websocket
|
import websocket
|
||||||
import ssl
|
import ssl
|
||||||
import subprocess
|
|
||||||
import os
|
|
||||||
import winreg
|
|
||||||
|
|
||||||
from core.interact import Interact
|
from core.interact import Interact
|
||||||
from scheduler.thread_manager import MyThread
|
from scheduler.thread_manager import MyThread
|
||||||
@ -21,15 +18,19 @@ from utils import config_util, util
|
|||||||
USER_URL = 'https://www.douyin.com/user/'
|
USER_URL = 'https://www.douyin.com/user/'
|
||||||
|
|
||||||
interact_datas = []
|
interact_datas = []
|
||||||
|
import json
|
||||||
|
import time
|
||||||
|
import ssl
|
||||||
|
import websocket
|
||||||
|
|
||||||
class WS_Client:
|
class WS_Client:
|
||||||
def __init__(self, host):
|
def __init__(self, host):
|
||||||
self.__ws = None
|
self.__ws = None
|
||||||
self.__host = host
|
self.__host = host
|
||||||
self.__connect(host)
|
self.__connect(host)
|
||||||
|
|
||||||
|
|
||||||
# 收到websocket消息的处理
|
|
||||||
def on_message(self, ws, message):
|
def on_message(self, ws, message):
|
||||||
|
global interact_datas
|
||||||
try:
|
try:
|
||||||
|
|
||||||
data = json.loads(message)
|
data = json.loads(message)
|
||||||
@ -46,23 +47,33 @@ class WS_Client:
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# 收到websocket错误的处理
|
|
||||||
def on_close(self, ws, code, msg):
|
def on_close(self, ws, code, msg):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# 收到websocket错误的处理
|
|
||||||
def on_error(self, ws, error):
|
def on_error(self, ws, error):
|
||||||
|
util.log(1, "弹幕监听WebSocket error. Reconnecting...")
|
||||||
time.sleep(5)
|
time.sleep(5)
|
||||||
self.__connect(self.__host)
|
self.__connect(self.__host)
|
||||||
|
|
||||||
# 收到websocket连接建立的处理
|
|
||||||
def on_open(self, ws):
|
def on_open(self, ws):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def __connect(self, host):
|
def __connect(self, host):
|
||||||
websocket.enableTrace(False)
|
websocket.enableTrace(False)
|
||||||
self.__ws = websocket.WebSocketApp(host, on_message=self.on_message)
|
while True:
|
||||||
self.__ws.on_open = self.on_open
|
try:
|
||||||
self.__ws.run_forever(sslopt={"cert_reqs": ssl.CERT_NONE})
|
self.__ws = websocket.WebSocketApp(host,
|
||||||
|
on_message=self.on_message,
|
||||||
|
on_error=self.on_error,
|
||||||
|
on_close=self.on_close)
|
||||||
|
self.__ws.on_open = self.on_open
|
||||||
|
self.__ws.run_forever(sslopt={"cert_reqs": ssl.CERT_NONE})
|
||||||
|
util.log(1, "弹幕监听WebSocket success.")
|
||||||
|
break
|
||||||
|
except Exception as e:
|
||||||
|
util.log(1, f"Error connecting: {e}. Retrying in 5 seconds...")
|
||||||
|
time.sleep(5)
|
||||||
|
|
||||||
def close(self):
|
def close(self):
|
||||||
self.__ws.close()
|
self.__ws.close()
|
||||||
|
|
||||||
@ -126,15 +137,9 @@ class Viewer:
|
|||||||
MyThread(target=self.__get_package_listen_interact_runnable).start()
|
MyThread(target=self.__get_package_listen_interact_runnable).start()
|
||||||
|
|
||||||
def __run_dy_msg_ws(self):
|
def __run_dy_msg_ws(self):
|
||||||
exe_path = "./bin/Release_2.85/v2.85.exe"
|
# exe_path = "./bin/Release_2.85/v2.85.exe"
|
||||||
self.exe_process = subprocess.Popen([exe_path])
|
# self.exe_process = subprocess.Popen([exe_path])
|
||||||
while self.__running:
|
self.dy_msg_ws = WS_Client('ws://127.0.0.1:8888')
|
||||||
try:
|
|
||||||
self.dy_msg_ws = WS_Client('ws://127.0.0.1:8888')
|
|
||||||
except Exception as e:
|
|
||||||
print(e)
|
|
||||||
time.sleep(5)
|
|
||||||
|
|
||||||
|
|
||||||
def start(self):
|
def start(self):
|
||||||
MyThread(target=self.__start).start()
|
MyThread(target=self.__start).start()
|
||||||
@ -342,6 +347,7 @@ class Viewer:
|
|||||||
|
|
||||||
#TODO Add by xszyou on 20230412.通过抓包监测互动数据
|
#TODO Add by xszyou on 20230412.通过抓包监测互动数据
|
||||||
def __get_package_listen_interact_runnable(self):
|
def __get_package_listen_interact_runnable(self):
|
||||||
|
global interact_datas
|
||||||
while self.__running:
|
while self.__running:
|
||||||
if not self.live_started:
|
if not self.live_started:
|
||||||
continue
|
continue
|
||||||
@ -389,30 +395,31 @@ class Viewer:
|
|||||||
if self.dy_msg_ws:
|
if self.dy_msg_ws:
|
||||||
self.dy_msg_ws.close()
|
self.dy_msg_ws.close()
|
||||||
self.dy_msg_ws = None
|
self.dy_msg_ws = None
|
||||||
self.disable_windows_proxy()
|
# self.disable_windows_proxy()
|
||||||
subprocess.run(["taskkill", "/F", "/PID", str(self.exe_process.pid)])
|
# subprocess.run(["taskkill", "/F", "/PID", str(self.exe_process.pid)])
|
||||||
|
|
||||||
|
|
||||||
#关闭系统代理
|
#关闭系统代理
|
||||||
def disable_windows_proxy(self):
|
# def disable_windows_proxy(self):
|
||||||
settings_key = r'Software\Microsoft\Windows\CurrentVersion\Internet Settings'
|
# settings_key = r'Software\Microsoft\Windows\CurrentVersion\Internet Settings'
|
||||||
try:
|
# try:
|
||||||
registry = winreg.ConnectRegistry(None, winreg.HKEY_CURRENT_USER)
|
# registry = winreg.ConnectRegistry(None, winreg.HKEY_CURRENT_USER)
|
||||||
settings = winreg.OpenKey(registry, settings_key, 0, winreg.KEY_WRITE)
|
# settings = winreg.OpenKey(registry, settings_key, 0, winreg.KEY_WRITE)
|
||||||
|
|
||||||
# 设置代理启用值为0(禁用)
|
# # 设置代理启用值为0(禁用)
|
||||||
winreg.SetValueEx(settings, 'ProxyEnable', 0, winreg.REG_DWORD, 0)
|
# winreg.SetValueEx(settings, 'ProxyEnable', 0, winreg.REG_DWORD, 0)
|
||||||
|
|
||||||
# 清空代理服务器和代理覆盖设置
|
# # 清空代理服务器和代理覆盖设置
|
||||||
winreg.SetValueEx(settings, 'ProxyServer', 0, winreg.REG_SZ, '')
|
# winreg.SetValueEx(settings, 'ProxyServer', 0, winreg.REG_SZ, '')
|
||||||
winreg.SetValueEx(settings, 'ProxyOverride', 0, winreg.REG_SZ, '')
|
# winreg.SetValueEx(settings, 'ProxyOverride', 0, winreg.REG_SZ, '')
|
||||||
|
|
||||||
winreg.CloseKey(settings)
|
# winreg.CloseKey(settings)
|
||||||
winreg.CloseKey(registry)
|
# winreg.CloseKey(registry)
|
||||||
|
|
||||||
util.log(1, '系统代理已关闭。')
|
# util.log(1, '系统代理已关闭。')
|
||||||
except Exception as e:
|
# except Exception as e:
|
||||||
util.log(1, '关闭系统代理时出错:', e)
|
# print(e)
|
||||||
|
# util.log(1, '关闭系统代理时出错:', e)
|
||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
def on_interact(self, interact, event_time):
|
def on_interact(self, interact, event_time):
|
||||||
|
Loading…
Reference in New Issue
Block a user