mirror of
https://github.com/LC044/WeChatMsg
synced 2025-02-22 19:02:17 +08:00
Merge branch 'LC044:master' into master
This commit is contained in:
commit
542c09e9c0
@ -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):
|
||||
|
@ -203,10 +203,16 @@ class Msg:
|
||||
for dialog in temp:
|
||||
msg1 = dialog[0]
|
||||
msg2 = dialog[1]
|
||||
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'):
|
||||
|
@ -319,9 +319,20 @@ class ChildThread(QThread):
|
||||
)
|
||||
elif self.output_type==Output.TXT:
|
||||
name = '你' if is_send else self.contact.remark
|
||||
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]
|
||||
|
@ -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)
|
||||
|
BIN
app/resources/ffmpeg.exe
Normal file
BIN
app/resources/ffmpeg.exe
Normal file
Binary file not shown.
@ -63,22 +63,22 @@
|
||||
<iframe src="/home" frameborder="0" height="100%" width="100%" class="if00"></iframe>
|
||||
</div>
|
||||
<div id="page2" class="page">
|
||||
<iframe src="/wordcloud" frameborder="0" height="100%" width="100%" class="if00"></iframe>
|
||||
<iframe src="/wordcloud/1" frameborder="0" height="100%" width="100%" class="if00"></iframe>
|
||||
</div>
|
||||
<div style="background-color: #8a6d3b" id="page3" class="page">
|
||||
<div id="page3" class="page">
|
||||
<iframe src="/wordcloud/0" frameborder="0" height="100%" width="100%" class="if00"></iframe>
|
||||
</div>
|
||||
<div style="background-color: #8a6d3b" id="page4" class="page">
|
||||
<iframe src="/test" frameborder="0" id="iframe0" height="100%" width="100%" class="if00"></iframe>
|
||||
</div>
|
||||
<div style="background-color: #337ab7" id="page4" class="page">
|
||||
<div style="background-color: #337ab7" id="page5" class="page">
|
||||
<iframe src="test" frameborder="0" id="iframe3" height="100%" width="100%" class="if00"></iframe>
|
||||
</div>
|
||||
<div style="background-color: #337ab7" id="page5" class="page">
|
||||
<div style="background-color: #337ab7" id="page6" class="page">
|
||||
<iframe src="test" frameborder="0" id="iframe4" height="100%" width="100%" class="if00"></iframe>
|
||||
</div>
|
||||
<div style="background-color: #337ab7" id="page6" class="page">
|
||||
<iframe src="test" frameborder="0" id="iframe5" height="100%" width="100%" class="if00"></iframe>
|
||||
</div>
|
||||
<div style="background-color: #337ab7" id="page7" class="page">
|
||||
<iframe src="test" frameborder="0" id="iframe6" height="100%" width="100%" class="if00"></iframe>
|
||||
<iframe src="test" frameborder="0" id="iframe5" height="100%" width="100%" class="if00"></iframe>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -32,7 +32,7 @@
|
||||
<div class="bg f-page"></div>
|
||||
<div class="tt f-animOpac" style="font-size:30px !important">
|
||||
<h1>二零二三</h1>
|
||||
<h1>你说的最多的是</h1></div>
|
||||
<h1>{{ who }}说的最多的是</h1></div>
|
||||
<div class="ckeywords j-anim01 z-anim">
|
||||
<div class="hands">
|
||||
<div class="hand2"></div>
|
||||
|
@ -34,15 +34,17 @@ def home():
|
||||
return render_template('home.html', **data)
|
||||
|
||||
|
||||
@app.route('/wordcloud')
|
||||
def one():
|
||||
@app.route('/wordcloud/<who>/')
|
||||
def one(who):
|
||||
wxid = contact.wxid
|
||||
# wxid = 'wxid_lltzaezg38so22'
|
||||
world_cloud_data = analysis.wordcloud(wxid)
|
||||
|
||||
# print('wxid:'+wxid)
|
||||
world_cloud_data = analysis.wordcloud(wxid,who=who) # 获取与Ta的对话数据
|
||||
# print(world_cloud_data)
|
||||
who = "你" if who == '1' else "TA"
|
||||
with open('wordcloud.html', 'w', encoding='utf-8') as f:
|
||||
f.write(render_template('wordcloud.html', **world_cloud_data))
|
||||
return render_template('wordcloud.html', **world_cloud_data)
|
||||
return render_template('wordcloud.html', **world_cloud_data,who=who)
|
||||
|
||||
|
||||
def set_text(text):
|
||||
|
@ -16,4 +16,4 @@ google==3.0.0
|
||||
protobuf==4.25.1
|
||||
soupsieve==2.5
|
||||
lz4==4.3.2
|
||||
pilk
|
||||
pilk==0.2.4
|
Loading…
Reference in New Issue
Block a user