mirror of
https://github.com/LC044/WeChatMsg
synced 2025-02-21 01:52:35 +08:00
添加更详细的运行过程输出,可用于...
可用于判断程序是在缓慢处理中还是卡了,对于特别多的对话记录,ui进度条是几乎不动的
This commit is contained in:
parent
20bededea8
commit
c89ae94f64
@ -7,6 +7,7 @@ from app.DataBase.output import ExporterBase
|
||||
|
||||
class CSVExporter(ExporterBase):
|
||||
def to_csv(self):
|
||||
print("【开始导出 CSV {self.contact.remark}】")
|
||||
origin_docx_path = f"{os.path.abspath('.')}/data/聊天记录/{self.contact.remark}"
|
||||
os.makedirs(origin_docx_path, exist_ok=True)
|
||||
filename = f"{os.path.abspath('.')}/data/聊天记录/{self.contact.remark}/{self.contact.remark}_utf8.csv"
|
||||
@ -23,6 +24,7 @@ class CSVExporter(ExporterBase):
|
||||
for msg in messages:
|
||||
other_data = [msg[12].remark, msg[12].nickName, msg[12].wxid] if self.contact.is_chatroom else []
|
||||
writer.writerow([*msg[:9], *other_data])
|
||||
print("【完成导出 CSV {self.contact.remark}】")
|
||||
self.okSignal.emit(1)
|
||||
|
||||
def run(self):
|
||||
|
@ -282,7 +282,7 @@ class DocxExporter(ExporterBase):
|
||||
middle_new_docx.save(origin_docx_path + '/' + filename)
|
||||
|
||||
def export(self):
|
||||
print('导出docx')
|
||||
print(f"【开始导出 DOCX {self.contact.remark}】")
|
||||
origin_docx_path = f"{os.path.abspath('.')}/data/聊天记录/{self.contact.remark}"
|
||||
filename = os.path.join(origin_docx_path, f"{self.contact.remark}.docx")
|
||||
doc = docx.Document()
|
||||
@ -327,9 +327,11 @@ class DocxExporter(ExporterBase):
|
||||
self.refermsg(doc, message)
|
||||
elif type_ == 49 and sub_type == 6 and self.message_types.get(4906):
|
||||
self.file(doc, message)
|
||||
print(f"【导出 DOCX {self.contact.remark}】{index}/{len(messages)}")
|
||||
try:
|
||||
doc.save(filename)
|
||||
except PermissionError:
|
||||
filename = filename[:-5] + f'{time.time()}' + '.docx'
|
||||
doc.save(filename)
|
||||
print(f"【完成导出 DOCX {self.contact.remark}】")
|
||||
self.okSignal.emit(1)
|
||||
|
@ -275,6 +275,7 @@ class HtmlExporter(ExporterBase):
|
||||
)
|
||||
|
||||
def export(self):
|
||||
print(f"【开始导出 HTML {self.contact.remark}】")
|
||||
messages = msg_db.get_messages(self.contact.wxid, time_range=self.time_range)
|
||||
filename = f"{os.path.abspath('.')}/data/聊天记录/{self.contact.remark}/{self.contact.remark}.html"
|
||||
file_path = './app/resources/data/template.html'
|
||||
@ -318,8 +319,11 @@ class HtmlExporter(ExporterBase):
|
||||
self.music_share(f, message)
|
||||
elif type_ == 49 and sub_type == 5 and self.message_types.get(4905):
|
||||
self.share_card(f, message)
|
||||
if index % 2000 == 0:
|
||||
print(f"【导出 HTML {self.contact.remark}】{index}/{len(messages)}")
|
||||
f.write(html_end)
|
||||
f.close()
|
||||
print(f"【完成导出 HTML {self.contact.remark}】{len(messages)}")
|
||||
self.count_finish_num(1)
|
||||
|
||||
def count_finish_num(self, num):
|
||||
|
@ -110,6 +110,7 @@ class TxtExporter(ExporterBase):
|
||||
|
||||
def export(self):
|
||||
# 实现导出为txt的逻辑
|
||||
print("【开始导出 TXT {self.contact.remark}】")
|
||||
origin_docx_path = f"{os.path.abspath('.')}/data/聊天记录/{self.contact.remark}"
|
||||
os.makedirs(origin_docx_path, exist_ok=True)
|
||||
filename = f"{os.path.abspath('.')}/data/聊天记录/{self.contact.remark}/{self.contact.remark}.txt"
|
||||
@ -140,4 +141,5 @@ class TxtExporter(ExporterBase):
|
||||
self.music_share(f, message)
|
||||
elif type_ == 49 and sub_type == 5 and self.message_types.get(4905):
|
||||
self.share_card(f, message)
|
||||
print("【完成导出 TXT {self.contact.remark}】")
|
||||
self.okSignal.emit(1)
|
Loading…
Reference in New Issue
Block a user