导出聊天记录
This commit is contained in:
parent
9e3ddceab4
commit
118bd10418
@ -233,7 +233,6 @@ def export_csv(username, outpath, MSG_ALL_db_path, page_size=5000):
|
||||
data = get_msg_list(MSG_ALL_db_path, username, start_index, page_size)
|
||||
if len(data) == 0:
|
||||
return False, "没有聊天记录"
|
||||
break
|
||||
save_path = os.path.join(outpath, f"{username}_{i}_{i + page_size}.csv")
|
||||
with open(save_path, "w", encoding="utf-8", newline='') as f:
|
||||
csv_writer = csv.writer(f, quoting=csv.QUOTE_MINIMAL)
|
||||
|
@ -214,6 +214,21 @@ def export():
|
||||
chat_type_tups += tup
|
||||
if not chat_type_tups:
|
||||
return ReJson(1002)
|
||||
|
||||
# 导出路径
|
||||
outpath = os.path.join(g.tmp_path, "export")
|
||||
if not os.path.exists(outpath):
|
||||
os.makedirs(outpath)
|
||||
|
||||
if export_type == "csv":
|
||||
# 导出聊天记录
|
||||
outpath = os.path.join(outpath, "csv")
|
||||
if not os.path.exists(outpath):
|
||||
os.makedirs(outpath)
|
||||
code, ret = analyzer.export_csv(username, outpath, g.msg_path)
|
||||
if code:
|
||||
return ReJson(0, ret)
|
||||
|
||||
return ReJson(0, "")
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user