File size: 1,188 Bytes
88aba71
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import os
import argparse
from pywxdump.db import MediaHandler

def main():
    parser = argparse.ArgumentParser(description="Extract audio from WeChat database")
    parser.add_argument("--db-path", type=str, required=True,
                        help="Path to WeChat database file")
    parser.add_argument("--MsgSvrID", type=str, required=True,
                        help="Message server ID of the audio")
    parser.add_argument("--save-path", type=str,
                        default=os.path.join(os.path.dirname(__file__), "sample.wav"),
                        help="Path to save the audio file (default: sample.wav in script directory)")
    parser.add_argument("--rate", type=int, default=24000,
                        help="Sample rate for audio conversion (default: 24000)")

    args = parser.parse_args()

    config = {
        "key": "test1",
        "type": "sqlite",
        "path": args.db_path,
    }

    t1 = MediaHandler(config)
    t1.get_audio(
        MsgSvrID=args.MsgSvrID,
        is_play=True,
        is_wave=True,
        save_path=args.save_path,
        rate=args.rate,
    )

if __name__ == "__main__":
    main()