mirror of
https://github.com/LC044/WeChatMsg
synced 2024-11-14 22:01:54 +08:00
修改文件位置
This commit is contained in:
parent
b1a6f52148
commit
5916e55c1b
@ -80,20 +80,22 @@ class MediaMsg:
|
||||
try:
|
||||
# 调用系统上的 ffmpeg 可执行文件
|
||||
# 获取 FFmpeg 可执行文件的路径
|
||||
# ffmpeg_path = get_ffmpeg_path()
|
||||
ffmpeg_path = get_ffmpeg_path()
|
||||
# # 调用 FFmpeg
|
||||
# cmd = f'''{ffmpeg_path} -loglevel quiet -y -f s16le -i {pcm_path} -ar 44100 -ac 1 {mp3_path}'''
|
||||
# system(cmd)
|
||||
# 源码运行的时候下面的有效
|
||||
# 这里不知道怎么捕捉异常
|
||||
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)
|
||||
if os.path.exists(ffmpeg_path):
|
||||
cmd = f'''{ffmpeg_path} -loglevel quiet -y -f s16le -i {pcm_path} -ar 44100 -ac 1 {mp3_path}'''
|
||||
system(cmd)
|
||||
else:
|
||||
# 源码运行的时候下面的有效
|
||||
# 这里不知道怎么捕捉异常
|
||||
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)
|
||||
except subprocess.CalledProcessError as e:
|
||||
print(f"Error: {e}")
|
||||
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}')
|
||||
system(f'del {silk_path}')
|
||||
system(f'del {pcm_path}')
|
||||
print(mp3_path)
|
||||
return mp3_path
|
||||
def get_audio_path(self, reserved0, output_path):
|
||||
|
@ -1,19 +1,20 @@
|
||||
import csv
|
||||
import html
|
||||
import os
|
||||
import sys
|
||||
import traceback
|
||||
from re import findall
|
||||
from PyQt5.QtCore import pyqtSignal, QThread, QFile, QIODevice, QTextStream
|
||||
from PyQt5.QtCore import pyqtSignal, QThread
|
||||
from PyQt5.QtWidgets import QFileDialog
|
||||
# from eyed3 import load
|
||||
|
||||
from . import msg_db, micro_msg_db
|
||||
from .package_msg import PackageMsg
|
||||
from ..DataBase import hard_link_db
|
||||
from ..DataBase import media_msg_db
|
||||
from ..log import logger
|
||||
from ..person import MePC
|
||||
from ..util import path
|
||||
import shutil
|
||||
|
||||
from ..util.compress_content import parser_reply
|
||||
from ..util.emoji import get_emoji, get_emoji_path
|
||||
|
||||
@ -506,12 +507,12 @@ class ChildThread(QThread):
|
||||
else:
|
||||
messages = msg_db.get_messages(self.contact.wxid)
|
||||
filename = f"{os.path.abspath('.')}/data/聊天记录/{self.contact.remark}/{self.contact.remark}.html"
|
||||
file = QFile(':/data/template.html')
|
||||
if file.open(QIODevice.ReadOnly | QIODevice.Text):
|
||||
stream = QTextStream(file)
|
||||
stream.setCodec('utf-8')
|
||||
content = stream.readAll()
|
||||
file.close()
|
||||
file_path = './app/resources/template.html'
|
||||
if not os.path.exists(file_path):
|
||||
resource_dir = getattr(sys, '_MEIPASS', os.path.abspath(os.path.dirname(__file__)))
|
||||
file_path = os.path.join(resource_dir, 'app', 'resources', 'template.html')
|
||||
with open(file_path, "r", encoding="utf-8") as f:
|
||||
content = f.read()
|
||||
html_head, html_end = content.split('/*注意看这是分割线*/')
|
||||
f = open(filename, 'w', encoding='utf-8')
|
||||
f.write(html_head.replace("<title>Chat Records</title>", f"<title>{self.contact.remark}</title>"))
|
||||
@ -616,17 +617,20 @@ class OutputMedia(QThread):
|
||||
for message in messages:
|
||||
is_send = message[4]
|
||||
msgSvrId = message[9]
|
||||
audio_path = media_msg_db.get_audio(msgSvrId, output_path=origin_docx_path + "/voice")
|
||||
audio_path = audio_path.replace('/', '\\')
|
||||
if self.contact.is_chatroom:
|
||||
if is_send:
|
||||
displayname = MePC().name
|
||||
try:
|
||||
audio_path = media_msg_db.get_audio(msgSvrId, output_path=origin_docx_path + "/voice")
|
||||
audio_path = audio_path.replace('/', '\\')
|
||||
if self.contact.is_chatroom:
|
||||
if is_send:
|
||||
displayname = MePC().name
|
||||
else:
|
||||
displayname = message[12].remark
|
||||
else:
|
||||
displayname = message[12].remark
|
||||
else:
|
||||
displayname = MePC().name if is_send else self.contact.remark
|
||||
displayname = escape_js_and_html(displayname)
|
||||
modify_audio_metadata(audio_path, displayname)
|
||||
displayname = MePC().name if is_send else self.contact.remark
|
||||
displayname = escape_js_and_html(displayname)
|
||||
modify_audio_metadata(audio_path, displayname)
|
||||
except:
|
||||
logger.error(traceback.format_exc())
|
||||
# os.utime(audio_path, (timestamp, timestamp))
|
||||
self.progressSignal.emit(1)
|
||||
self.okSingal.emit(34)
|
||||
@ -645,6 +649,9 @@ class OutputEmoji(QThread):
|
||||
messages = msg_db.get_messages_by_type(self.contact.wxid, 47)
|
||||
for message in messages:
|
||||
str_content = message[7]
|
||||
emoji_path = get_emoji(str_content, thumb=True, output_path=origin_docx_path + '/emoji')
|
||||
try:
|
||||
emoji_path = get_emoji(str_content, thumb=True, output_path=origin_docx_path + '/emoji')
|
||||
except:
|
||||
logger.error(traceback.format_exc())
|
||||
self.progressSignal.emit(1)
|
||||
self.okSingal.emit(34)
|
||||
|
@ -1,3 +1,4 @@
|
||||
import os
|
||||
from collections import Counter
|
||||
|
||||
from PyQt5.QtCore import QFile, QTextStream, QIODevice
|
||||
@ -93,17 +94,17 @@ def wordcloud_christmas(wxid, year='2023'):
|
||||
stopwords_file = './app/data/stopwords.txt'
|
||||
with open(stopwords_file, "r", encoding="utf-8") as stopword_file:
|
||||
stopwords1 = set(stopword_file.read().splitlines())
|
||||
file = QFile(':/data/stopwords.txt')
|
||||
# 构建 FFmpeg 可执行文件的路径
|
||||
stopwords = set()
|
||||
if file.open(QIODevice.ReadOnly | QIODevice.Text):
|
||||
stream = QTextStream(file)
|
||||
stream.setCodec('utf-8')
|
||||
content = stream.readAll()
|
||||
file.close()
|
||||
stopwords = set(content.splitlines())
|
||||
stopwords_file = './app/resources/stopwords.txt'
|
||||
if not os.path.exists(stopwords_file):
|
||||
resource_dir = getattr(sys, '_MEIPASS', os.path.abspath(os.path.dirname(__file__)))
|
||||
stopwords_file = os.path.join(resource_dir, 'app', 'resources', 'stopwords.txt')
|
||||
with open(stopwords_file, "r", encoding="utf-8") as stopword_file:
|
||||
stopwords = set(stopword_file.read().splitlines())
|
||||
stopwords = stopwords.union(stopwords1)
|
||||
filtered_word_count = {word: count for word, count in word_count.items() if len(word) > 1 and word not in stopwords}
|
||||
|
||||
filtered_word_count = {word: count for word, count in word_count.items() if len(word) > 1 and word not in stopwords}
|
||||
# 转换为词云数据格式
|
||||
data = [(word, count) for word, count in filtered_word_count.items()]
|
||||
# text_data = data
|
||||
|
@ -30,8 +30,6 @@
|
||||
<file>icons/decrypt.svg</file>
|
||||
</qresource>
|
||||
<qresource prefix="/data">
|
||||
<file>version_list.json</file>
|
||||
<file>stopwords.txt</file>
|
||||
<file>template.html</file>
|
||||
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,5 +1,6 @@
|
||||
import json
|
||||
import os.path
|
||||
import sys
|
||||
import time
|
||||
import traceback
|
||||
|
||||
@ -49,14 +50,12 @@ class DecryptControl(QWidget, decryptUi.Ui_Dialog):
|
||||
# @log
|
||||
def get_info(self):
|
||||
try:
|
||||
file = QFile(':/data/version_list.json')
|
||||
if file.open(QIODevice.ReadOnly | QIODevice.Text):
|
||||
stream = QTextStream(file)
|
||||
content = stream.readAll()
|
||||
file.close()
|
||||
VERSION_LIST = json.loads(content)
|
||||
else:
|
||||
return
|
||||
file_path = './app/resources/version_list.json'
|
||||
if not os.path.exists(file_path):
|
||||
resource_dir = getattr(sys, '_MEIPASS', os.path.abspath(os.path.dirname(__file__)))
|
||||
file_path = os.path.join(resource_dir, 'app', 'resources', 'version_list.json')
|
||||
with open(file_path, "r", encoding="utf-8") as f:
|
||||
VERSION_LIST = json.loads(f.read())
|
||||
result = get_wx_info.get_info(VERSION_LIST)
|
||||
print(result)
|
||||
if result == -1:
|
||||
|
Loading…
Reference in New Issue
Block a user