新增加载动画

This commit is contained in:
shuaikangzhou 2023-12-23 19:07:15 +08:00
parent a21e2d657a
commit 4110dd0de9
7 changed files with 6256 additions and 5356 deletions

View File

@ -10,6 +10,7 @@ from pilk import decode
lock = threading.Lock()
db_path = "./app/Database/Msg/MediaMSG.db"
def get_ffmpeg_path():
# 获取打包后的资源目录
resource_dir = getattr(sys, '_MEIPASS', os.path.abspath(os.path.dirname(__file__)))
@ -18,6 +19,8 @@ def get_ffmpeg_path():
ffmpeg_path = os.path.join(resource_dir, 'app', 'resources', 'ffmpeg.exe')
return ffmpeg_path
def singleton(cls):
_instance = {}
@ -28,6 +31,7 @@ def singleton(cls):
return inner
@singleton
class MediaMsg:
def __init__(self):
@ -76,8 +80,8 @@ class MediaMsg:
with open(silk_path, "wb") as f:
f.write(buf)
# open(silk_path, "wb").write()
decode(silk_path, pcm_path, 44100)
try:
decode(silk_path, pcm_path, 44100)
# 调用系统上的 ffmpeg 可执行文件
# 获取 FFmpeg 可执行文件的路径
ffmpeg_path = get_ffmpeg_path()
@ -90,18 +94,20 @@ class MediaMsg:
# 这里不知道怎么捕捉异常
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:
except Exception 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}'''
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_path(self, reserved0, output_path):
mp3_path = f"{output_path}\\{reserved0}.mp3"
mp3_path = mp3_path.replace("/", "\\")
return mp3_path
def get_audio_text(self, content):
try:
root = ET.fromstring(content)
@ -109,6 +115,7 @@ class MediaMsg:
return transtext
except:
return ""
def close(self):
if self.open_flag:
try:
@ -121,6 +128,7 @@ class MediaMsg:
def __del__(self):
self.close()
if __name__ == '__main__':
db_path = './Msg/MediaMSG.db'
media_msg_db = MediaMsg()

View File

@ -1,6 +1,7 @@
import os
import sqlite3
def merge_MediaMSG_databases(source_paths, target_path):
# 创建目标数据库连接
target_conn = sqlite3.connect(target_path)
@ -19,7 +20,6 @@ def merge_MediaMSG_databases(source_paths, target_path):
sql = '''SELECT Key,Reserved0,Buf,Reserved1,Reserved2 FROM Media;'''
cursor.execute(sql)
result = cursor.fetchall()
target_cursor.executemany(
"INSERT INTO Media (Key,Reserved0,Buf,Reserved1,Reserved2)"
"VALUES(?,?,?,?,?)",
@ -42,6 +42,7 @@ def merge_MediaMSG_databases(source_paths, target_path):
# 关闭目标数据库连接
target_conn.close()
def merge_databases(source_paths, target_path):
# 创建目标数据库连接
target_conn = sqlite3.connect(target_path)
@ -55,19 +56,22 @@ def merge_databases(source_paths, target_path):
db = sqlite3.connect(source_path)
db.text_factory = str
cursor = db.cursor()
sql = '''
SELECT TalkerId,MsgsvrID,Type,SubType,IsSender,CreateTime,Sequence,StrTalker,StrContent,DisplayContent,BytesExtra,CompressContent
FROM MSG;
'''
cursor.execute(sql)
result = cursor.fetchall()
# 附加源数据库
target_cursor.executemany(
"INSERT INTO MSG "
"(TalkerId,MsgsvrID,Type,SubType,IsSender,CreateTime,Sequence,StrTalker,StrContent,DisplayContent,"
"BytesExtra,CompressContent)"
"VALUES(?,?,?,?,?,?,?,?,?,?,?,?)",
result)
try:
sql = '''
SELECT TalkerId,MsgsvrID,Type,SubType,IsSender,CreateTime,Sequence,StrTalker,StrContent,DisplayContent,BytesExtra,CompressContent
FROM MSG;
'''
cursor.execute(sql)
result = cursor.fetchall()
# 附加源数据库
target_cursor.executemany(
"INSERT INTO MSG "
"(TalkerId,MsgsvrID,Type,SubType,IsSender,CreateTime,Sequence,StrTalker,StrContent,DisplayContent,"
"BytesExtra,CompressContent)"
"VALUES(?,?,?,?,?,?,?,?,?,?,?,?)",
result)
except:
pass
cursor.close()
db.close()
# 提交事务

View File

@ -28,6 +28,14 @@
<file>icons/folder.svg</file>
<file>icons/start.svg</file>
<file>icons/decrypt.svg</file>
<file>icons/Cursors/0.png</file>
<file>icons/Cursors/1.png</file>
<file>icons/Cursors/2.png</file>
<file>icons/Cursors/3.png</file>
<file>icons/Cursors/4.png</file>
<file>icons/Cursors/5.png</file>
<file>icons/Cursors/6.png</file>
<file>icons/Cursors/7.png</file>
</qresource>
<qresource prefix="/data">

File diff suppressed because it is too large Load Diff

View File

@ -22,6 +22,7 @@ from .chat import ChatWindow
from .contact import ContactWindow
from .tool.tool_window import ToolWindow
from ..DataBase.output_pc import Output
from ..components.QCursorGif import QCursorGif
from ..person import MePC
# 美化样式表
@ -69,7 +70,7 @@ HistoryPanel::item:hover {
"""
class MainWinController(QMainWindow, mainwindow.Ui_MainWindow):
class MainWinController(QMainWindow, mainwindow.Ui_MainWindow,QCursorGif):
exitSignal = pyqtSignal(bool)
okSignal = pyqtSignal(bool)
@ -79,6 +80,10 @@ class MainWinController(QMainWindow, mainwindow.Ui_MainWindow):
self.outputThread0 = None
self.outputThread = None
self.setupUi(self)
# 设置忙碌光标图片数组
self.initCursor([':/icons/icons/Cursors/%d.png' %
i for i in range(8)], self)
self.setCursorTimeout(100)
# self.setWindowIcon(Icon.MainWindow_Icon)
pixmap = QPixmap(Icon.logo_ico_path)
icon = QIcon(pixmap)
@ -208,6 +213,7 @@ class MainWinController(QMainWindow, mainwindow.Ui_MainWindow):
self.stackedWidget.setCurrentIndex(0)
def output(self):
self.startBusy()
if self.sender() == self.action_output_CSV:
self.outputThread = Output(None, type_=Output.CSV_ALL)
self.outputThread.okSignal.connect(
@ -220,6 +226,7 @@ class MainWinController(QMainWindow, mainwindow.Ui_MainWindow):
self.outputThread.start()
def message(self, msg):
self.stopBusy()
QMessageBox.about(self, "提醒", msg)
def about(self):

View File

@ -3,13 +3,15 @@ import os.path
import sys
import time
import traceback
from typing import List
from PyQt5.QtCore import pyqtSignal, QThread, QUrl, QFile, QIODevice, QTextStream
from PyQt5.QtCore import pyqtSignal, QThread, QUrl
from PyQt5.QtGui import QDesktopServices
from PyQt5.QtWidgets import QWidget, QMessageBox, QFileDialog
from app.DataBase import msg_db, misc_db, media_msg_db, close_db
from app.DataBase import msg_db, misc_db, close_db
from app.DataBase.merge import merge_databases, merge_MediaMSG_databases
from app.components.QCursorGif import QCursorGif
from app.decrypt import get_wx_info, decrypt
from app.log import logger
from app.util import path
@ -17,14 +19,17 @@ from . import decryptUi
from ...Icon import Icon
class DecryptControl(QWidget, decryptUi.Ui_Dialog):
class DecryptControl(QWidget, decryptUi.Ui_Dialog, QCursorGif):
DecryptSignal = pyqtSignal(bool)
get_wxidSignal = pyqtSignal(str)
def __init__(self, parent=None):
super(DecryptControl, self).__init__(parent)
self.setupUi(self)
# 设置忙碌光标图片数组
self.initCursor([':/icons/icons/Cursors/%d.png' %
i for i in range(8)], self)
self.setCursorTimeout(100)
self.btn_start.clicked.connect(self.decrypt)
self.btn_getinfo.clicked.connect(self.get_info)
self.btn_db_dir.clicked.connect(self.select_db_dir)
@ -49,46 +54,44 @@ class DecryptControl(QWidget, decryptUi.Ui_Dialog):
# @log
def get_info(self):
try:
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:
QMessageBox.critical(self, "错误", "请登录微信")
elif result == -2:
QMessageBox.critical(self, "错误", "微信版本不匹配\n请更新微信版本为:3.9.8.15")
elif result == -3:
QMessageBox.critical(self, "错误", "WeChat WeChatWin.dll Not Found")
else:
self.startBusy()
self.get_info_thread = MyThread()
self.get_info_thread.signal.connect(self.set_info)
self.get_info_thread.start()
def set_info(self, result):
# print(result)
if result[0] == -1:
QMessageBox.critical(self, "错误", "请登录微信")
elif result[0] == -2:
QMessageBox.critical(self, "错误", "微信版本不匹配\n请更新微信版本为:3.9.8.25")
elif result[0] == -3:
QMessageBox.critical(self, "错误", "WeChat WeChatWin.dll Not Found")
elif result[0] == -10086:
QMessageBox.critical(self, "错误", "未知错误,请收集错误信息")
else:
self.ready = True
self.info = result[0]
self.label_key.setText(self.info['key'])
self.lineEdit.setText(self.info['wxid'])
self.label_name.setText(self.info['name'])
self.label_phone.setText(self.info['mobile'])
self.label_pid.setText(str(self.info['pid']))
self.label_version.setText(self.info['version'])
self.lineEdit.setFocus()
self.checkBox.setChecked(True)
self.get_wxidSignal.emit(self.info['wxid'])
directory = os.path.join(path.wx_path(), self.info['wxid'])
if os.path.exists(directory):
self.label_db_dir.setText(directory)
self.wx_dir = directory
self.checkBox_2.setChecked(True)
self.ready = True
self.info = result[0]
self.label_key.setText(self.info['key'])
self.lineEdit.setText(self.info['wxid'])
self.label_name.setText(self.info['name'])
self.label_phone.setText(self.info['mobile'])
self.label_pid.setText(str(self.info['pid']))
self.label_version.setText(self.info['version'])
self.lineEdit.setFocus()
self.checkBox.setChecked(True)
self.get_wxidSignal.emit(self.info['wxid'])
directory = os.path.join(path.wx_path(), self.info['wxid'])
if os.path.exists(directory):
self.label_db_dir.setText(directory)
self.wx_dir = directory
self.checkBox_2.setChecked(True)
self.ready = True
if self.ready:
self.label_ready.setText('已就绪')
if self.wx_dir and os.path.exists(os.path.join(self.wx_dir)):
self.label_ready.setText('已就绪')
except Exception as e:
QMessageBox.critical(self, "未知错误", "请收集报错信息发起issue解决问题")
logger.error(traceback.format_exc())
if self.ready:
self.label_ready.setText('已就绪')
if self.wx_dir and os.path.exists(os.path.join(self.wx_dir)):
self.label_ready.setText('已就绪')
self.stopBusy()
def set_wxid_(self):
self.info['wxid'] = self.lineEdit.text()
@ -129,7 +132,8 @@ class DecryptControl(QWidget, decryptUi.Ui_Dialog):
QMessageBox.critical(self, "错误", "文件夹选择错误\n一般以wxid_xxx结尾")
return
if self.info.get('key') == 'None':
QMessageBox.critical(self, "错误", "密钥错误\n将软件放在桌面上试试\n如果还不可以的话我也我能为力,您可以等待后续版本解决该问题")
QMessageBox.critical(self, "错误",
"密钥错误\n将软件放在桌面上试试\n如果还不可以的话我也我能为力,您可以等待后续版本解决该问题")
close_db()
self.label_tip.setVisible(True)
self.label_tip.setText('点我之后没有反应那就多等儿吧,不要再点了')
@ -179,32 +183,6 @@ class DecryptControl(QWidget, decryptUi.Ui_Dialog):
except:
with open('./info.json', 'w', encoding='utf-8') as f:
f.write(json.dumps(dic))
# 目标数据库文件
target_database = "app/DataBase/Msg/MSG.db"
# 源数据库文件列表
source_databases = [f"app/DataBase/Msg/MSG{i}.db" for i in range(1, 200)]
import shutil
if os.path.exists(target_database):
os.remove(target_database)
shutil.copy2("app/DataBase/Msg/MSG0.db", target_database) # 使用一个数据库文件作为模板
# 合并数据库
try:
merge_databases(source_databases, target_database)
except FileNotFoundError:
QMessageBox.critical(self, "错误", "数据库不存在\n请检查微信版本是否为最新")
# 音频数据库文件
target_database = "app/DataBase/Msg/MediaMSG.db"
# 源数据库文件列表
if os.path.exists(target_database):
os.remove(target_database)
source_databases = [f"app/DataBase/Msg/MediaMSG{i}.db" for i in range(1, 200)]
shutil.copy2("app/DataBase/Msg/MediaMSG0.db", target_database) # 使用一个数据库文件作为模板
# 合并数据库
try:
merge_MediaMSG_databases(source_databases, target_database)
except FileNotFoundError:
QMessageBox.critical(self, "错误", "数据库不存在\n请检查微信版本是否为最新")
self.DecryptSignal.emit(True)
self.close()
@ -249,12 +227,38 @@ class DecryptThread(QThread):
self.errorSignal.emit(True)
self.signal.emit(str(i))
# print(self.db_path)
# 目标数据库文件
target_database = "app/DataBase/Msg/MSG.db"
# 源数据库文件列表
source_databases = [f"app/DataBase/Msg/MSG{i}.db" for i in range(1, 200)]
import shutil
if os.path.exists(target_database):
os.remove(target_database)
shutil.copy2("app/DataBase/Msg/MSG0.db", target_database) # 使用一个数据库文件作为模板
# 合并数据库
try:
merge_databases(source_databases, target_database)
except FileNotFoundError:
QMessageBox.critical("错误", "数据库不存在\n请检查微信版本是否为最新")
# 音频数据库文件
target_database = "app/DataBase/Msg/MediaMSG.db"
# 源数据库文件列表
if os.path.exists(target_database):
os.remove(target_database)
source_databases = [f"app/DataBase/Msg/MediaMSG{i}.db" for i in range(1, 200)]
shutil.copy2("app/DataBase/Msg/MediaMSG0.db", target_database) # 使用一个数据库文件作为模板
# 合并数据库
try:
merge_MediaMSG_databases(source_databases, target_database)
except FileNotFoundError:
QMessageBox.critical("错误", "数据库不存在\n请检查微信版本是否为最新")
self.okSignal.emit('ok')
# self.signal.emit('100')
class MyThread(QThread):
signal = pyqtSignal(str)
signal = pyqtSignal(list)
def __init__(self):
super(MyThread, self).__init__()
@ -263,6 +267,21 @@ class MyThread(QThread):
pass
def run(self):
for i in range(100):
self.signal.emit(str(i))
time.sleep(0.1)
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())
try:
result = get_wx_info.get_info(VERSION_LIST)
if result == -1:
result = [result]
elif result == -2:
result = [result]
elif result == -3:
result = [result]
except:
logger.error(traceback.format_exc())
result = [-10086]
self.signal.emit(result)

View File

@ -62,6 +62,9 @@ class ViewController(QWidget):
if __name__ == '__main__':
import cgitb
cgitb.enable(format='text')
app = QApplication(sys.argv)
font = QFont('微软雅黑', 12) # 使用 Times New Roman 字体,字体大小为 14
app.setFont(font)