Skip to content

Commit bd9af7a

Browse files
committed
更新 sounds 路径
1 parent 9d2d4a2 commit bd9af7a

1 file changed

Lines changed: 7 additions & 22 deletions

File tree

src/wilk/__init__.py

Lines changed: 7 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import json
44
import os
5-
import subprocess
5+
import time
66
from dataclasses import dataclass, field, asdict
77
from pathlib import Path
88
from typing import List, Tuple
@@ -15,6 +15,8 @@
1515
# 需要手动设置的参数,超过 3000 按 3000 计算
1616
silk_time: int = 3000 # 3000 指代 60s,300 则是 6s
1717

18+
SOUNDS_PATH = '/storage/emulated/0/Android/data/com.tencent.mm/files/WechatXposed/sounds/'
19+
1820

1921
@dataclass
2022
class Sound:
@@ -85,24 +87,6 @@ def adjust_duration(duration):
8587
return duration
8688

8789

88-
def get_code() -> int:
89-
"""wxposed 语音存储方式改变,不在存储在 sounds_db 中
90-
91-
获取最大的语音序号
92-
"""
93-
subp = subprocess.run(['adb', 'shell', 'ls', '/sdcard/WechatXposed/sounds/sf_*.json'], capture_output=True)
94-
assert subp.returncode == 0, 'adb shell ls /sdcard/WechatXposed/sounds/ 失败'
95-
output = subp.stdout.decode('utf8')
96-
code = 0
97-
for i in output.splitlines():
98-
i = i.split('/')[-1] # sf_80.json
99-
i = i.split('_')[-1] # 80.json
100-
i = i.split('.')[0] # 80
101-
i = int(i)
102-
code = max(code, i)
103-
return code
104-
105-
10690
def start(start_durations, files):
10791
"""添加silk文件"""
10892

@@ -115,7 +99,7 @@ def start(start_durations, files):
11599
silk_file = convert_to_silk(silk_file)
116100
print(silk_file)
117101

118-
code = get_code() + 1
102+
code = time.time_ns()
119103

120104
# 4.2 获取分段数据及信息
121105
duration = 0
@@ -130,7 +114,7 @@ def start(start_durations, files):
130114
f.write(item[2])
131115
if not DEBUG:
132116
os.system(
133-
f'adb push "{os.path.abspath(sf_file)}" /sdcard/WechatXposed/sounds/sf_{code}_p{sf_index}_amr')
117+
f'adb push "{os.path.abspath(sf_file)}" {SOUNDS_PATH}sf_{code}_p{sf_index}_amr')
134118
os.remove(sf_file)
135119
sf_index += 1
136120

@@ -144,7 +128,8 @@ def start(start_durations, files):
144128
os.remove(silk_file)
145129

146130
if not DEBUG:
147-
os.system(f'adb push "{sf_json_name}" /sdcard/WechatXposed/sounds/')
131+
os.system(
132+
f'adb push "{sf_json_name}" {SOUNDS_PATH}')
148133
os.remove(sf_json_name)
149134

150135

0 commit comments

Comments
 (0)