Skip to content

Commit

Permalink
解决由于引用消息解析失败导致的闪退问题
Browse files Browse the repository at this point in the history
  • Loading branch information
LC044 committed Dec 13, 2023
1 parent 9ca75c7 commit 5cab0e7
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 18 deletions.
7 changes: 5 additions & 2 deletions app/DataBase/media_msg.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,11 @@ def get_audio(self, reserved0, output_path):
# 获取 FFmpeg 可执行文件的路径
ffmpeg_path = get_ffmpeg_path()
# 调用 FFmpeg
# subprocess.run([ffmpeg_path, f'''-loglevel quiet -y -f s16le -i {pcm_path} -ar 44100 -ac 1 {mp3_path}'''], check=True)
cmd = f'''{get_ffmpeg_path()} -loglevel quiet -y -f s16le -i {pcm_path} -ar 44100 -ac 1 {mp3_path}'''
cmd = f'''{ffmpeg_path} -loglevel quiet -y -f s16le -i {pcm_path} -ar 44100 -ac 1 {mp3_path}'''
system(cmd)
# 源码运行的时候下面的有效
# 这里不知道怎么捕捉异常
cmd = f'''{os.path.join(os.getcwd(), 'app', 'resources', 'ffmpeg.exe')} -loglevel quiet -y -f s16le -i {pcm_path} -ar 44100 -ac 1 {mp3_path}'''
system(cmd)
except subprocess.CalledProcessError as e:
print(f"Error: {e}")
Expand Down
3 changes: 3 additions & 0 deletions app/ui/contact/export_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ def __init__(self, contact=None, title="选择导出的类型", file_type="csv",
layout.addWidget(checkbox)
layout.addWidget(self.progress_bar)
layout.addWidget(self.progress_label)
self.notice_label = QLabel(self)
self.notice_label.setText("注意:导出HTML时选择图片、视频、语音、表情包(特别是表情包)\n会导致大大影响导出速度,请合理选择导出的类型")
layout.addWidget(self.notice_label)
hlayout = QHBoxLayout(self)
self.export_button = QPushButton("导出")
self.export_button.clicked.connect(self.export_data)
Expand Down
2 changes: 1 addition & 1 deletion app/ui/tool/pc_decrypt/pc_decrypt.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ def btnExitClicked(self):
# 音频数据库文件
target_database = "app/DataBase/Msg/MediaMSG.db"
# 源数据库文件列表
source_databases = [f"app/DataBase/Msg/MediaMSG{i}.db" for i in range(1, 20)]
source_databases = [f"app/DataBase/Msg/MediaMSG{i}.db" for i in range(1, 200)]
shutil.copy2("app/DataBase/Msg/MediaMSG0.db", target_database) # 使用一个数据库文件作为模板
# 合并数据库
try:
Expand Down
41 changes: 26 additions & 15 deletions app/util/compress_content.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,19 +48,30 @@ def parser_reply(data: bytes):
'displayname': '用户名',
}
}
root = ET.XML(xml_content)
appmsg = root.find('appmsg')
msg_type = int(appmsg.find('type').text)
title = appmsg.find('title').text
refermsg_content = appmsg.find('refermsg').find('content').text
refermsg_type = int(appmsg.find('refermsg').find('type').text)
refermsg_displayname = appmsg.find('refermsg').find('displayname').text
return {
'type': msg_type,
'title': escape_js_and_html(title),
'refer': None if refermsg_type != 1 else {
'type': refermsg_type,
'content': escape_js_and_html(refermsg_content),
'displayname': escape_js_and_html(refermsg_displayname),
try :
root = ET.XML(xml_content)
appmsg = root.find('appmsg')
msg_type = int(appmsg.find('type').text)
title = appmsg.find('title').text
refermsg_content = appmsg.find('refermsg').find('content').text
refermsg_type = int(appmsg.find('refermsg').find('type').text)
refermsg_displayname = appmsg.find('refermsg').find('displayname').text
return {
'type': msg_type,
'title': escape_js_and_html(title),
'refer': None if refermsg_type != 1 else {
'type': refermsg_type,
'content': escape_js_and_html(refermsg_content),
'displayname': escape_js_and_html(refermsg_displayname),
}
}
except:
return {
'type': 57,
'title': "发生错误",
'refer': {
'type': '1',
'content': '引用错误',
'displayname': '用户名',
}
}
}

0 comments on commit 5cab0e7

Please sign in to comment.