From 74c68a9c534c5a73505024dfcf942e2425bab34f Mon Sep 17 00:00:00 2001 From: foyou Date: Tue, 19 Mar 2024 16:29:05 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20code=20=E7=94=9F=E6=88=90?= =?UTF-8?q?=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/wilk/__init__.py | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/src/wilk/__init__.py b/src/wilk/__init__.py index cb4d2aa..3fa6539 100644 --- a/src/wilk/__init__.py +++ b/src/wilk/__init__.py @@ -2,7 +2,8 @@ import json import os -import time +import re +import subprocess from dataclasses import dataclass, field, asdict from pathlib import Path from typing import List, Tuple @@ -17,6 +18,24 @@ SOUNDS_PATH = '/storage/emulated/0/Android/data/com.tencent.mm/files/WechatXposed/sounds/' +# adb shell ls /storage/emulated/0/Android/data/com.tencent.mm/files/WechatXposed/sounds/ +START_CODE = None + + +def get_code(): + global START_CODE + if START_CODE is None: + a = subprocess.run('adb shell ls /storage/emulated/0/Android/data/com.tencent.mm/files/WechatXposed/sounds/', + capture_output=True) + b = a.stdout.decode('utf8').replace('\r', '').split('\n') + for i in b: + if re.match(r'sf_(\d+).json', i): + code = int(re.match(r'sf_(\d+).json', i).group(1)) + if START_CODE is None or code > START_CODE: + START_CODE = code + START_CODE += 1 + return START_CODE + @dataclass class Sound: @@ -99,7 +118,7 @@ def start(start_durations, files): silk_file = convert_to_silk(silk_file) print(silk_file) - code = time.time_ns() + code = get_code() # 4.2 获取分段数据及信息 duration = 0