Ai
1 Star 0 Fork 3

花屠/mac-wechat

forked from 5fa0/mac-wechat 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
init_db.py 1.46 KB
一键复制 编辑 原始数据 按行查看 历史
戴艺森 提交于 2022-11-16 10:42 +08:00 . 补充
import os
import shutil
from app.config import wechat_root, source_dbs_path, decrypt_dbs_path, key, message_temp_path
from app.db.encrypt_db import EncryptDb
from app.utils import check_path
def copy_db_files():
# 复制源文件,避免对源文件操作
dirs = ['Message', 'Group', 'Contact', 'Group', 'Session']
if not os.path.exists(source_dbs_path):
print("正在拷贝数据库文件(避免对源文件操作),请稍等...")
check_path(source_dbs_path)
for d in dirs:
for f in os.listdir(os.path.join(wechat_root, d)):
if 'backup' in f or not 'db' in f: continue
shutil.copyfile(os.path.join(wechat_root, d, f), os.path.join(source_dbs_path, f))
def decrypt_db_file():
# 解密db 文件
if not os.path.exists(decrypt_dbs_path):
print("正在解密数据库文件,请稍等...")
check_path(decrypt_dbs_path)
for file in os.listdir(source_dbs_path):
if ".db" == file[-3:]:
encrypt_db = EncryptDb(source_dbs_path, file, decrypt_dbs_path, key)
encrypt_db.decrypt_db()
def main():
shutil.rmtree("static/wxdata")
# 拷贝数据库文件
copy_db_files()
# 解密
decrypt_db_file()
if not os.path.exists(message_temp_path):
print("正在拷贝静态文件,该过程需等待数分钟,请稍等...")
shutil.copytree(wechat_root + "Message/MessageTemp", message_temp_path)
main()
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/hwatu/mac-wechat.git
git@gitee.com:hwatu/mac-wechat.git
hwatu
mac-wechat
mac-wechat
master

搜索帮助