Merge branch 'LC044:master' into master

This commit is contained in:
Kang 2023-12-07 10:23:24 +08:00 committed by GitHub
commit 2baee9ec39
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 15 additions and 7 deletions

View File

@ -13,7 +13,7 @@ def merge_databases(source_paths, target_path):
if not os.path.exists(source_path): if not os.path.exists(source_path):
break break
db = sqlite3.connect(source_path) db = sqlite3.connect(source_path)
db.text_factory = bytes # db.text_factory = bytes
cursor = db.cursor() cursor = db.cursor()
sql = ''' sql = '''
SELECT TalkerId,MsgsvrID,Type,SubType,IsSender,CreateTime,Sequence,StrTalker,StrContent,DisplayContent,BytesExtra SELECT TalkerId,MsgsvrID,Type,SubType,IsSender,CreateTime,Sequence,StrTalker,StrContent,DisplayContent,BytesExtra

View File

@ -231,4 +231,4 @@ if __name__ == '__main__':
pprint(msg.get_message_by_num('wxid_0o18ef858vnu22', local_id)) pprint(msg.get_message_by_num('wxid_0o18ef858vnu22', local_id))
print(msg.get_messages_by_keyword(wxid, '干嘛')) print(msg.get_messages_by_keyword(wxid, '干嘛'))
pprint(msg.get_messages_by_keyword(wxid, '干嘛')[0]) pprint(msg.get_messages_by_keyword(wxid, '干嘛')[0])
print(msg.get_first_time_of_message('wxid_0o18ef858vnu22')) print(msg.get_first_time_of_message('wxid_fervbwign7m822'))

View File

@ -890,7 +890,7 @@ const chatMessages = [
if match: if match:
continue continue
image_path = hard_link_db.get_image(content=str_content, thumb=False) image_path = hard_link_db.get_image(content=str_content, thumb=False)
image_path = path.get_relative_path(image_path, base_path=f'./data/聊天记录/{self.contact.remark}/image') image_path = path.get_relative_path(image_path, base_path=f'/data/聊天记录/{self.contact.remark}/image')
image_path = image_path.replace('\\', '/') image_path = image_path.replace('\\', '/')
# print(f"tohtml:---{image_path}") # print(f"tohtml:---{image_path}")
if self.is_5_min(timestamp): if self.is_5_min(timestamp):

View File

@ -19,6 +19,13 @@ wordcloud_height = 720
def wordcloud(wxid): def wordcloud(wxid):
import jieba import jieba
txt_messages = msg_db.get_messages_by_type(wxid, MsgType.TEXT) txt_messages = msg_db.get_messages_by_type(wxid, MsgType.TEXT)
if not txt_messages:
return {
'chart_data': None,
'keyword': "没有聊天你想分析啥",
'max_num': "0",
'dialogs': []
}
text = ''.join(map(lambda x: x[7], txt_messages)) text = ''.join(map(lambda x: x[7], txt_messages))
total_msg_len = len(text) total_msg_len = len(text)
# 使用jieba进行分词并加入停用词 # 使用jieba进行分词并加入停用词

View File

@ -50,14 +50,15 @@ def decode_dat(file_path, out_path):
if decode_code == -1: if decode_code == -1:
return return
filename = os.path.basename(file_path)
if file_type == 1: if file_type == 1:
pic_name = os.path.basename(file_path)[:-4] + ".jpg" pic_name = os.path.basename(file_path)[:-4] + ".jpg"
elif file_type == 3: elif file_type == 3:
pic_name = file_path[:-4] + ".png" pic_name = filename[:-4] + ".png"
elif file_type == 5: elif file_type == 5:
pic_name = file_path[:-4] + ".gif" pic_name = filename[:-4] + ".gif"
else: else:
pic_name = file_path[:-4] + ".jpg" pic_name = filename[:-4] + ".jpg"
file_outpath = os.path.join(out_path, pic_name) file_outpath = os.path.join(out_path, pic_name)
if os.path.exists(file_outpath): if os.path.exists(file_outpath):
return file_outpath return file_outpath

View File

@ -43,7 +43,7 @@ def index0():
def home(): def home():
try: try:
first_message, first_time = msg_db.get_first_time_of_message(contact.wxid) first_message, first_time = msg_db.get_first_time_of_message(contact.wxid)
except IndexError: except TypeError:
return set_text('咱就是说,一次都没聊过就别分析了') return set_text('咱就是说,一次都没聊过就别分析了')
data = { data = {
'sub_title': '二零二三年度报告', 'sub_title': '二零二三年度报告',