mirror of
https://github.com/LC044/WeChatMsg
synced 2025-02-21 18:12:18 +08:00
移除批量导出docx
This commit is contained in:
parent
7afa2b6846
commit
117f811d13
@ -7,7 +7,7 @@ from app.DataBase.output import ExporterBase
|
||||
|
||||
class CSVExporter(ExporterBase):
|
||||
def to_csv(self):
|
||||
print("【开始导出 CSV {self.contact.remark}】")
|
||||
print(f"【开始导出 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"
|
||||
|
@ -2,9 +2,10 @@ import binascii
|
||||
import os.path
|
||||
import sqlite3
|
||||
import threading
|
||||
import traceback
|
||||
import xml.etree.ElementTree as ET
|
||||
|
||||
from app.log import log
|
||||
from app.log import log, logger
|
||||
from app.util.protocbuf.msg_pb2 import MessageBytesExtra
|
||||
|
||||
image_db_lock = threading.Lock()
|
||||
@ -32,6 +33,13 @@ def get_md5_from_xml(content, type_="img"):
|
||||
|
||||
|
||||
def decodeExtraBuf(extra_buf_content: bytes):
|
||||
if not extra_buf_content:
|
||||
return {
|
||||
"region": ('', '', ''),
|
||||
"signature": '',
|
||||
"telephone": '',
|
||||
"gender": 0,
|
||||
}
|
||||
trunkName = {
|
||||
b"\x46\xCF\x10\xC4": "个性签名",
|
||||
b"\xA4\xD9\x02\x4A": "国家",
|
||||
@ -46,33 +54,42 @@ def decodeExtraBuf(extra_buf_content: bytes):
|
||||
}
|
||||
res = {"手机号": ""}
|
||||
off = 0
|
||||
for key in trunkName:
|
||||
trunk_head = trunkName[key]
|
||||
try:
|
||||
off = extra_buf_content.index(key) + 4
|
||||
except:
|
||||
pass
|
||||
char = extra_buf_content[off : off + 1]
|
||||
off += 1
|
||||
if char == b"\x04": # 四个字节的int,小端序
|
||||
intContent = extra_buf_content[off : off + 4]
|
||||
off += 4
|
||||
intContent = int.from_bytes(intContent, "little")
|
||||
res[trunk_head] = intContent
|
||||
elif char == b"\x18": # utf-16字符串
|
||||
lengthContent = extra_buf_content[off : off + 4]
|
||||
off += 4
|
||||
lengthContent = int.from_bytes(lengthContent, "little")
|
||||
strContent = extra_buf_content[off : off + lengthContent]
|
||||
off += lengthContent
|
||||
res[trunk_head] = strContent.decode("utf-16").rstrip("\x00")
|
||||
try:
|
||||
for key in trunkName:
|
||||
trunk_head = trunkName[key]
|
||||
try:
|
||||
off = extra_buf_content.index(key) + 4
|
||||
except:
|
||||
pass
|
||||
char = extra_buf_content[off : off + 1]
|
||||
off += 1
|
||||
if char == b"\x04": # 四个字节的int,小端序
|
||||
intContent = extra_buf_content[off : off + 4]
|
||||
off += 4
|
||||
intContent = int.from_bytes(intContent, "little")
|
||||
res[trunk_head] = intContent
|
||||
elif char == b"\x18": # utf-16字符串
|
||||
lengthContent = extra_buf_content[off : off + 4]
|
||||
off += 4
|
||||
lengthContent = int.from_bytes(lengthContent, "little")
|
||||
strContent = extra_buf_content[off : off + lengthContent]
|
||||
off += lengthContent
|
||||
res[trunk_head] = strContent.decode("utf-16").rstrip("\x00")
|
||||
return {
|
||||
"region": (res["国家"], res["省份"], res["市"]),
|
||||
"signature": res["个性签名"],
|
||||
"telephone": res["手机号"],
|
||||
"gender": res["性别"],
|
||||
}
|
||||
except:
|
||||
logger.error(f'联系人解析错误:\n{traceback.format_exc()}')
|
||||
return {
|
||||
"region": ('', '', ''),
|
||||
"signature": '',
|
||||
"telephone": '',
|
||||
"gender": 0,
|
||||
}
|
||||
|
||||
return {
|
||||
"region": (res["国家"], res["省份"], res["市"]),
|
||||
"signature": res["个性签名"],
|
||||
"telephone": res["手机号"],
|
||||
"gender": res["性别"],
|
||||
}
|
||||
|
||||
|
||||
def singleton(cls):
|
||||
|
@ -290,8 +290,9 @@ class MainWinController(QMainWindow, mainwindow.Ui_MainWindow, QCursorGif):
|
||||
|
||||
def close(self) -> bool:
|
||||
close_db()
|
||||
super().close()
|
||||
self.contact_window.close()
|
||||
|
||||
super().close()
|
||||
self.exitSignal.emit(True)
|
||||
|
||||
|
||||
|
@ -64,13 +64,15 @@ class ExportDialog(QDialog, Ui_Dialog):
|
||||
self.comboBox_time.activated.connect(self.set_export_date)
|
||||
# 下面将输出重定向到textBrowser中
|
||||
sys.stdout = EmittingStr(textWritten=self.outputWritten)
|
||||
sys.stderr = EmittingStr(textWritten=self.outputWritten)
|
||||
# sys.stderr = EmittingStr(textWritten=self.outputWritten)
|
||||
scroll_bar = ScrollBar()
|
||||
self.textBrowser.setVerticalScrollBar(scroll_bar)
|
||||
self.export_choices = {"文本": True, "图片": True, "语音": False, "视频": False, "表情包": False,
|
||||
'音乐与音频': False, '分享卡片': False, '文件': False,
|
||||
'拍一拍等系统消息': True} # 定义导出的数据类型,默认全部选择
|
||||
self.setWindowTitle(title)
|
||||
self.checkBox_word.setEnabled(False)
|
||||
self.checkBox_word.setText('Docx(暂时不可用)')
|
||||
self.resize(800, 600)
|
||||
self.worker = None # 导出线程
|
||||
for export_type, default_state in self.export_choices.items():
|
||||
|
@ -95,7 +95,7 @@ class Ui_Dialog(object):
|
||||
self.textBrowser.setObjectName("textBrowser")
|
||||
self.verticalLayout_3.addWidget(self.textBrowser)
|
||||
self.progressBar = QtWidgets.QProgressBar(Dialog)
|
||||
self.progressBar.setProperty("value", 24)
|
||||
self.progressBar.setProperty("value", 0)
|
||||
self.progressBar.setObjectName("progressBar")
|
||||
self.verticalLayout_3.addWidget(self.progressBar)
|
||||
self.horizontalLayout_4 = QtWidgets.QHBoxLayout()
|
||||
@ -127,7 +127,7 @@ class Ui_Dialog(object):
|
||||
def retranslateUi(self, Dialog):
|
||||
_translate = QtCore.QCoreApplication.translate
|
||||
Dialog.setWindowTitle(_translate("Dialog", "Dialog"))
|
||||
self.label_3.setText(_translate("Dialog", "导出过程中请不要退出"))
|
||||
self.label_3.setText(_translate("Dialog", "导出过程中请不要退出,为减少卡顿请尽量不要超过十个"))
|
||||
self.btn_select_all.setText(_translate("Dialog", "全选"))
|
||||
self.comboBox_time.setItemText(0, _translate("Dialog", "全部时间"))
|
||||
self.comboBox_time.setItemText(1, _translate("Dialog", "最近三个月"))
|
||||
|
@ -170,7 +170,7 @@ class Ui_Dialog(object):
|
||||
self.label_ready.setObjectName("label_ready")
|
||||
self.horizontalLayout.addWidget(self.label_ready)
|
||||
self.progressBar = QtWidgets.QProgressBar(Dialog)
|
||||
self.progressBar.setProperty("value", 50)
|
||||
self.progressBar.setProperty("value", 0)
|
||||
self.progressBar.setObjectName("progressBar")
|
||||
self.horizontalLayout.addWidget(self.progressBar)
|
||||
self.verticalLayout.addLayout(self.horizontalLayout)
|
||||
|
Loading…
Reference in New Issue
Block a user