Skip to content

Commit

Permalink
fix cli
Browse files Browse the repository at this point in the history
  • Loading branch information
xaoyaoo committed Aug 4, 2024
1 parent a27f95f commit 5e34b58
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 13 deletions.
8 changes: 4 additions & 4 deletions pywxdump/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,19 +155,19 @@ def init_parses(self, parser):
# 添加 'wx_db_path' 子命令解析器
parser.add_argument("-r", "--db_types", type=str,
help="(可选)需要的数据库名称(eg: -r MediaMSG;MicroMsg;FTSMSG;MSG;Sns;Emotion )",
default="all", metavar="")
default=None, metavar="")
parser.add_argument("-wf", "--wx_files", type=str, help="(可选)'WeChat Files'路径", default=None,
metavar="")
parser.add_argument("-id", "--wxid", type=str, help="(可选)wxid_,用于确认用户文件夹",
default=None, metavar="")
return parser

def run(self, args):
print(f"[*] PyWxDump v{pywxdump.__version__}")
# 从命令行参数获取值
db_types = args.require_list
db_types = args.db_types
msg_dir = args.wx_files
wxid = args.wxid

ret = get_wx_db(msg_dir=msg_dir, db_types=db_types, wxids=wxid)
for i in ret: print(i)
return ret
Expand Down Expand Up @@ -243,7 +243,7 @@ def run(self, args):
print(f"[+] 创建输出文件夹:{out_path}")

print(f"[*] 合并中...(用时较久,耐心等待)")

dbpaths = [{"db_path": i} for i in dbpaths if os.path.exists(i)] # 去除不存在的路径
result = merge_db(dbpaths, out_path)

print(f"[+] 合并完成:{result}")
Expand Down
22 changes: 15 additions & 7 deletions pywxdump/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ def start_falsk(merge_path="", wx_path="", key="", my_wxid="", port=5000, online
print(f"[+] 创建临时文件夹:{work_path}")

conf_auto_file = os.path.join(work_path, "conf_auto.json") # 用于存放各种基础信息
at = "auto_setting"

from flask import Flask, g
from flask_cors import CORS
Expand Down Expand Up @@ -85,14 +86,21 @@ def changeHeader(response):
def before_request():
g.work_path = work_path # 临时文件夹,用于存放图片等-新版本
g.caf = conf_auto_file # 用于存放各种基础信息-新版本
g.at = "auto_setting" # 用于默认设置-新版本

if merge_path: set_conf(conf_auto_file, g.at, "merge_path", merge_path)
if wx_path: set_conf(conf_auto_file, g.at, "wx_path", wx_path)
if key: set_conf(conf_auto_file, g.at, "key", key)
if my_wxid: set_conf(conf_auto_file, g.at, "my_wxid", my_wxid)
g.at = at # 用于默认设置-新版本

if merge_path:
set_conf(conf_auto_file, at, "merge_path", merge_path)
db_config = {
"key": "merge_all",
"type": "sqlite",
"path": "D:\\_code\\py_code\\pywxdumpProject\\z_test\\wxdump_work\\wxid_zh12s67kxsqs22\\merge_all.db"
}
set_conf(conf_auto_file, at, "db_config", db_config)
if wx_path: set_conf(conf_auto_file, at, "wx_path", wx_path)
if key: set_conf(conf_auto_file, at, "key", key)
if my_wxid: set_conf(conf_auto_file, at, "my_wxid", my_wxid)
if not os.path.exists(conf_auto_file):
set_conf(conf_auto_file, g.at, "last", my_wxid)
set_conf(conf_auto_file, at, "last", my_wxid)

app.register_blueprint(rs_api)
app.register_blueprint(ls_api)
Expand Down
4 changes: 2 additions & 2 deletions pywxdump/wx_core/wx_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -384,12 +384,12 @@ def get_wx_db(msg_dir: str = None,
wxids = wxids.split(";") if isinstance(wxids, str) else wxids
if not isinstance(wxids, list) or len(wxids) <= 0:
wxids = None
db_types = db_types.split(";") if isinstance(db_types, str) else db_types
db_types = db_types.split(";") if isinstance(db_types, str) and db_types else db_types
if not isinstance(db_types, list) or len(db_types) <= 0:
db_types = None

wxid_dirs = {} # wx用户目录
if "All Users"in os.listdir(msg_dir) or "Applet"in os.listdir(msg_dir) or "WMPF"in os.listdir(msg_dir):
if "All Users" in os.listdir(msg_dir) or "Applet" in os.listdir(msg_dir) or "WMPF" in os.listdir(msg_dir):
for sub_dir in os.listdir(msg_dir):
if os.path.isdir(os.path.join(msg_dir, sub_dir)) and sub_dir not in ["All Users", "Applet", "WMPF"]:
wxid_dirs[os.path.basename(sub_dir)] = os.path.join(msg_dir, sub_dir)
Expand Down

0 comments on commit 5e34b58

Please sign in to comment.