22import subprocess
33from os import environ
44from pathlib import Path
5- from typing import List
5+ from typing import List , Optional
66
77from ansi import Color
88
@@ -11,33 +11,54 @@ def main():
1111 # Parse arguments
1212 parser = argparse .ArgumentParser ()
1313 parser .add_argument ('--input' , '-i' , required = True )
14+ parser .add_argument ('--symbols' , '-s' )
1415 args = parser .parse_args ()
1516
1617 input_arg : str = args .input
18+ symbols_arg : Optional [str ] = args .symbols
1719
1820 temp_dir = Path ('./temp' )
1921 temp_dir .mkdir (exist_ok = True )
2022
2123 # Pull the debug library from the device
22- process = subprocess .run ([
23- 'adb' ,
24- 'pull' ,
25- '/sdcard/ModData/com.beatgames.beatsaber/Modloader/mods/libspotify-search.so' ,
26- ], cwd = temp_dir , stderr = subprocess .STDOUT )
27-
28- # Pull the logs from the device
29- log_file_dir = Path ('/sdcard/ModData/com.beatgames.beatsaber/logs2' )
30- log_file_paths = [
31- log_file_dir / 'spotify-search.log' ,
32- log_file_dir / 'spotify-search.1.log'
33- ]
34- for path in log_file_paths :
24+ if not symbols_arg :
25+ print (Color .CYAN ('Pulling libraries from device...' ))
3526 process = subprocess .run ([
3627 'adb' ,
3728 'pull' ,
38- path . as_posix () ,
29+ '/sdcard/ModData/com.beatgames.beatsaber/Modloader/mods/libspotify-search.so' ,
3930 ], cwd = temp_dir , stderr = subprocess .STDOUT )
4031
32+ total_paths : List [Path ] = []
33+
34+ match input_arg :
35+ case 'logs' :
36+ # Pull the logs from the device
37+ log_file_dir = Path ('/sdcard/ModData/com.beatgames.beatsaber/logs2' )
38+ log_file_paths = [
39+ log_file_dir / 'spotify-search.log' ,
40+ log_file_dir / 'spotify-search.1.log'
41+ ]
42+ for path in log_file_paths :
43+ process = subprocess .run ([
44+ 'adb' ,
45+ 'pull' ,
46+ path .as_posix (),
47+ ], cwd = temp_dir , stderr = subprocess .STDOUT )
48+ total_paths .append (temp_dir / path .name )
49+ case 'logcat' :
50+ # Get logcat output
51+ logcat_output_path = temp_dir / 'logcat.txt'
52+ with open (logcat_output_path , 'w' ) as file :
53+ process = subprocess .run ([
54+ 'adb' ,
55+ 'shell' ,
56+ 'logcat -d *:F'
57+ ], cwd = temp_dir , stdout = file )
58+ total_paths .append (logcat_output_path )
59+ case _:
60+ total_paths .append (Path (input_arg ))
61+
4162 ndk_path = Path (environ .get ('ANDROID_NDK_HOME' ))
4263 ndk_stack_exe = ndk_path / 'ndk-stack.cmd'
4364
@@ -47,24 +68,7 @@ def main():
4768 symbol_dir = temp_dir
4869 print (ndk_stack_exe )
4970
50- # Get logcat output
51- logcat_output_path = temp_dir / 'logcat.txt'
52- with open (logcat_output_path , 'w' ) as file :
53- process = subprocess .run ([
54- 'adb' ,
55- 'shell' ,
56- 'logcat -d *:F'
57- ], cwd = temp_dir , stdout = file )
58-
59- input_paths : List [Path ] = [
60- * [
61- temp_dir / p .name for p in log_file_paths
62- ],
63- Path (input_arg ),
64- logcat_output_path
65- ]
66-
67- for path in input_paths :
71+ for path in total_paths :
6872 print (Color .CYAN (f'Decoding: { path } ' ))
6973 process = subprocess .run ([
7074 str (ndk_stack_exe .absolute ()),
0 commit comments