fix AND MicroMsg实时数据库 #82

This commit is contained in:
xaoyaoo 2024-03-15 09:38:20 +08:00
parent 2c5e08a33b
commit 62ffe4080e
6 changed files with 16 additions and 5 deletions

View File

@ -89,8 +89,8 @@ qq交流群[276392799](https://s.xaoyo.top/gOLUDl) or [276392799](https://s.x
* 常见问题请参考[FAQ](https://github.com/xaoyaoo/PyWxDump/tree/master/doc/FAQ.md),更新日志请参考[CHANGELOG](https://github.com/xaoyaoo/PyWxDump/tree/master/doc/CHANGELOG.md) * 常见问题请参考[FAQ](https://github.com/xaoyaoo/PyWxDump/tree/master/doc/FAQ.md),更新日志请参考[CHANGELOG](https://github.com/xaoyaoo/PyWxDump/tree/master/doc/CHANGELOG.md)
* Web UI的仓库位置 [wxdump_web](https://github.com/xaoyaoo/wxdump_web) * Web UI的仓库位置 [wxdump_web](https://github.com/xaoyaoo/wxdump_web)
* 如果对wxdump实现原理感兴趣请关注公众号`逍遥之芯`,回复:`原理` 获取原理解析。 * 如果对wxdump实现原理感兴趣请关注公众号`逍遥之芯`,回复:`原理` 获取原理解析。
* [:sparkling\_heart: Support Me](https://github.com/xaoyaoo/xaoyaoo/blob/main/donate.md) * [:sparkling\_heart: Support Me](https://github.com/xaoyaoo/xaoyaoo/blob/main/donate.md)
* 私有化定制开发请关注公众号:`逍遥之芯`,回复:`私有化定制` 。
## 5. Star History ## 5. Star History

View File

@ -25,4 +25,4 @@ except:
PYWXDUMP_ROOT_PATH = os.path.dirname(__file__) PYWXDUMP_ROOT_PATH = os.path.dirname(__file__)
__version__ = "2.4.56" __version__ = "2.4.57"

View File

@ -206,8 +206,11 @@ def read_audio(MsgSvrID, is_play=False, is_wave=False, DB_PATH: str = "", rate=2
if len(DBdata) == 0: if len(DBdata) == 0:
return False return False
data = DBdata[0][0] # [1:] + b'\xFF\xFF' data = DBdata[0][0] # [1:] + b'\xFF\xFF'
pcm_data = read_audio_buf(data, is_play, is_wave, rate) try:
return pcm_data pcm_data = read_audio_buf(data, is_play, is_wave, rate)
return pcm_data
except Exception as e:
return False
def wordcloud_generator(text, out_path="", is_show=False, img_path="", font="C:\Windows\Fonts\simhei.ttf"): def wordcloud_generator(text, out_path="", is_show=False, img_path="", font="C:\Windows\Fonts\simhei.ttf"):

View File

@ -309,6 +309,7 @@ def get_real_time_msg():
""" """
save_msg_path = read_session(g.sf, "msg_path") save_msg_path = read_session(g.sf, "msg_path")
save_media_path = read_session(g.sf, "media_path") save_media_path = read_session(g.sf, "media_path")
save_micro_path = read_session(g.sf, "micro_path")
wx_path = read_session(g.sf, "wx_path") wx_path = read_session(g.sf, "wx_path")
key = read_session(g.sf, "key") key = read_session(g.sf, "key")
@ -316,15 +317,19 @@ def get_real_time_msg():
return ReJson(1002, body="msg_path or media_path or wx_path or key is required") return ReJson(1002, body="msg_path or media_path or wx_path or key is required")
media_paths = get_core_db(wx_path, ["MediaMSG"]) media_paths = get_core_db(wx_path, ["MediaMSG"])
msg_paths = get_core_db(wx_path, ["MSG"]) msg_paths = get_core_db(wx_path, ["MSG"])
micro_paths = get_core_db(wx_path, ["MicroMsg"])
if not media_paths[0] or not msg_paths[0]: if not media_paths[0] or not msg_paths[0] or not micro_paths[0]:
return ReJson(1001, body="media_paths or msg_paths is required") return ReJson(1001, body="media_paths or msg_paths is required")
media_paths = media_paths[1] media_paths = media_paths[1]
media_paths.sort() media_paths.sort()
msg_paths = msg_paths[1] msg_paths = msg_paths[1]
msg_paths.sort() msg_paths.sort()
micro_paths = micro_paths[1]
micro_paths.sort()
merge_real_time_db(key=key, db_path=media_paths[-1], merge_path=save_media_path) merge_real_time_db(key=key, db_path=media_paths[-1], merge_path=save_media_path)
merge_real_time_db(key=key, db_path=msg_paths[-1], merge_path=save_msg_path) merge_real_time_db(key=key, db_path=msg_paths[-1], merge_path=save_msg_path)
merge_real_time_db(key=key, db_path=micro_paths[-1], merge_path=save_micro_path)
return ReJson(0, "success") return ReJson(0, "success")

View File

@ -356,6 +356,9 @@ def merge_real_time_db(key, db_path: str, merge_path: str, CreateTime: int = 0,
if not os.path.exists(db_path): if not os.path.exists(db_path):
raise FileNotFoundError("数据库不存在") raise FileNotFoundError("数据库不存在")
if "MSG" not in db_path and "MicroMsg" not in db_path and "MediaMSG" not in db_path:
raise FileNotFoundError("数据库不是消息数据库") # MicroMsg实时数据库
out_path = "tmp_" + ''.join( out_path = "tmp_" + ''.join(
random.choices('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789', k=6)) + ".db" random.choices('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789', k=6)) + ".db"
merge_path_base = os.path.dirname(merge_path) # 合并后的数据库路径 merge_path_base = os.path.dirname(merge_path) # 合并后的数据库路径

Binary file not shown.