diff --git a/app/DataBase/media_msg.py b/app/DataBase/media_msg.py index b188f8e..8e07183 100644 --- a/app/DataBase/media_msg.py +++ b/app/DataBase/media_msg.py @@ -55,17 +55,20 @@ class MediaMsg: silk_path = f"{output_path}\\{reserved0}.silk" pcm_path = f"{output_path}\\{reserved0}.pcm" mp3_path = f"{output_path}\\{reserved0}.mp3" - slik_path = silk_path.replace("/", "\\") + silk_path = silk_path.replace("/", "\\") pcm_path = pcm_path.replace("/", "\\") mp3_path = mp3_path.replace("/", "\\") - print(mp3_path) if os.path.exists(mp3_path): return mp3_path - open(silk_path, "wb").write(buf) + with open(silk_path, "wb") as f: + f.write(buf) + # open(silk_path, "wb").write() decode(silk_path, pcm_path, 44100) - system(f'ffmpeg.exe -loglevel quiet -y -f s16le -i "{pcm_path}" -ar 44100 -ac 1 "{mp3_path}"') - system(f'del "{silk_path}"') - system(f'del "{pcm_path}"') + cmd = f'''{os.path.join(os.getcwd(),'app','resources','ffmpeg.exe')} -loglevel quiet -y -f s16le -i {pcm_path} -ar 44100 -ac 1 {mp3_path}''' + system(cmd) + system(f'del {silk_path}') + system(f'del {pcm_path}') + print(mp3_path) return mp3_path def get_audio_text(self, content): diff --git a/app/DataBase/msg.py b/app/DataBase/msg.py index a3edea3..0f4dea4 100644 --- a/app/DataBase/msg.py +++ b/app/DataBase/msg.py @@ -203,10 +203,16 @@ class Msg: for dialog in temp: msg1 = dialog[0] msg2 = dialog[1] - res.append(( - (msg1[4], msg1[5], msg1[7].split(keyword), msg1[8]), - (msg2[4], msg2[5], msg2[7], msg2[8]) - )) + try: + res.append(( + (msg1[4], msg1[5], msg1[7].split(keyword), msg1[8]), + (msg2[4], msg2[5], msg2[7], msg2[8]) + )) + except TypeError: + res.append(( + ('', '', ['', ''], ''), + ('', '', '', '') + )) return res def get_messages_by_days(self, username_, is_Annual_report_=False, year_='2023'): diff --git a/app/DataBase/output_pc.py b/app/DataBase/output_pc.py index 24de94f..a509740 100644 --- a/app/DataBase/output_pc.py +++ b/app/DataBase/output_pc.py @@ -319,9 +319,20 @@ class ChildThread(QThread): ) elif self.output_type==Output.TXT: name = '你' if is_send else self.contact.remark - doc.write( - f'''{str_time} {name}\n{content.get('title')}\n引用:{refer_msg.get('displayname')}:{refer_msg.get('content')}\n\n''' - ) + if refer_msg: + referText = f"{refer_msg.get('displayname')}:{refer_msg.get('content')}" + emojiText = findall(r"(\[.+?\])", referText) + for emoji_text in emojiText: + if emoji_text in emoji: + referText = referText.replace(emoji_text, emoji[emoji_text]) + doc.write( + f'''{str_time} {name}\n{content.get('title')}\n引用:{refer_msg.get('displayname')}:{refer_msg.get('content')}\n\n''' + ) + else: + doc.write( + f'''{str_time} {name}\n{content.get('title')}\n引用:未知\n\n''' + ) + def system_msg(self, doc, message): str_content = message[7] diff --git a/app/analysis/analysis.py b/app/analysis/analysis.py index 430179d..5eb13fe 100644 --- a/app/analysis/analysis.py +++ b/app/analysis/analysis.py @@ -17,7 +17,7 @@ wordcloud_width = 780 wordcloud_height = 720 -def wordcloud(wxid, is_Annual_report=False, year='2023'): +def wordcloud(wxid, is_Annual_report=False, year='2023', who='1'): import jieba txt_messages = msg_db.get_messages_by_type(wxid, MsgType.TEXT, is_Annual_report, year) if not txt_messages: @@ -27,7 +27,9 @@ def wordcloud(wxid, is_Annual_report=False, year='2023'): 'max_num': "0", 'dialogs': [] } - text = ''.join(map(lambda x: x[7], txt_messages)) + # text = ''.join(map(lambda x: x[7], txt_messages)) + text = ''.join(map(lambda x: x[7] if x[4] == int(who) else '', txt_messages)) # 1“我”说的话,0“Ta”说的话 + total_msg_len = len(text) # 使用jieba进行分词,并加入停用词 words = jieba.cut(text) diff --git a/app/resources/ffmpeg.exe b/app/resources/ffmpeg.exe new file mode 100644 index 0000000..e576a7c Binary files /dev/null and b/app/resources/ffmpeg.exe differ diff --git a/app/web_ui/templates/index.html b/app/web_ui/templates/index.html index 6fcb123..4507f9d 100644 --- a/app/web_ui/templates/index.html +++ b/app/web_ui/templates/index.html @@ -63,22 +63,22 @@