From 4d1d1a631db3d30bfcee73ed9dc71a726388d018 Mon Sep 17 00:00:00 2001 From: shuaikangzhou <863909694@qq.com> Date: Wed, 6 Dec 2023 21:59:23 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=97=A0=E8=81=8A?= =?UTF-8?q?=E5=A4=A9=E6=95=B0=E6=8D=AE=E5=B9=B4=E5=BA=A6=E5=88=86=E6=9E=90?= =?UTF-8?q?=E6=8A=A5=E5=91=8A=E6=8A=A5=E9=94=99=E9=97=AE=E9=A2=98#72?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/analysis/analysis.py | 7 +++++++ app/web_ui/web.py | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/app/analysis/analysis.py b/app/analysis/analysis.py index 263eb48..56aba51 100644 --- a/app/analysis/analysis.py +++ b/app/analysis/analysis.py @@ -19,6 +19,13 @@ wordcloud_height = 720 def wordcloud(wxid): import jieba 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)) total_msg_len = len(text) # 使用jieba进行分词,并加入停用词 diff --git a/app/web_ui/web.py b/app/web_ui/web.py index 7ed6d70..5a5c7a6 100644 --- a/app/web_ui/web.py +++ b/app/web_ui/web.py @@ -43,7 +43,7 @@ def index0(): def home(): try: first_message, first_time = msg_db.get_first_time_of_message(contact.wxid) - except IndexError: + except TypeError: return set_text('咱就是说,一次都没聊过就别分析了') data = { 'sub_title': '二零二三年度报告', From db0277fbd7b398ca09af63d92c61b066dc8b0095 Mon Sep 17 00:00:00 2001 From: shuaikangzhou <863909694@qq.com> Date: Thu, 7 Dec 2023 00:19:16 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=AF=BC=E5=87=BA?= =?UTF-8?q?=E5=9B=BE=E7=89=87=E7=BC=BA=E5=A4=B1=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/DataBase/output_pc.py | 2 +- app/util/dat2pic.py | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/app/DataBase/output_pc.py b/app/DataBase/output_pc.py index 77f0adf..76dc719 100644 --- a/app/DataBase/output_pc.py +++ b/app/DataBase/output_pc.py @@ -890,7 +890,7 @@ const chatMessages = [ if match: continue 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('\\', '/') # print(f"tohtml:---{image_path}") if self.is_5_min(timestamp): diff --git a/app/util/dat2pic.py b/app/util/dat2pic.py index 9c7df78..7a36d9c 100644 --- a/app/util/dat2pic.py +++ b/app/util/dat2pic.py @@ -50,14 +50,15 @@ def decode_dat(file_path, out_path): if decode_code == -1: return + filename = os.path.basename(file_path) if file_type == 1: pic_name = os.path.basename(file_path)[:-4] + ".jpg" elif file_type == 3: - pic_name = file_path[:-4] + ".png" + pic_name = filename[:-4] + ".png" elif file_type == 5: - pic_name = file_path[:-4] + ".gif" + pic_name = filename[:-4] + ".gif" else: - pic_name = file_path[:-4] + ".jpg" + pic_name = filename[:-4] + ".jpg" file_outpath = os.path.join(out_path, pic_name) if os.path.exists(file_outpath): return file_outpath From 2efc52840ac0c3659e4cf2000ee27196fe961705 Mon Sep 17 00:00:00 2001 From: shuaikangzhou <863909694@qq.com> Date: Thu, 7 Dec 2023 00:44:51 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=90=88=E5=B9=B6?= =?UTF-8?q?=E5=90=8E=E7=9A=84=E8=81=8A=E5=A4=A9=E6=95=B0=E6=8D=AE=E5=BC=82?= =?UTF-8?q?=E5=B8=B8=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/DataBase/merge.py | 2 +- app/DataBase/msg.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/DataBase/merge.py b/app/DataBase/merge.py index 7679821..c3aa63a 100644 --- a/app/DataBase/merge.py +++ b/app/DataBase/merge.py @@ -13,7 +13,7 @@ def merge_databases(source_paths, target_path): if not os.path.exists(source_path): break db = sqlite3.connect(source_path) - db.text_factory = bytes + # db.text_factory = bytes cursor = db.cursor() sql = ''' SELECT TalkerId,MsgsvrID,Type,SubType,IsSender,CreateTime,Sequence,StrTalker,StrContent,DisplayContent,BytesExtra diff --git a/app/DataBase/msg.py b/app/DataBase/msg.py index a6bdc7e..1b03ce7 100644 --- a/app/DataBase/msg.py +++ b/app/DataBase/msg.py @@ -213,4 +213,4 @@ if __name__ == '__main__': pprint(msg.get_message_by_num('wxid_0o18ef858vnu22', local_id)) print(msg.get_messages_by_keyword(wxid, '干嘛')) 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'))