这是一个用 Python 编写的命令行工具,用于解码酷狗音乐加密/混淆的音乐文件(如 .kgm、.vpr 或缓存文件)。
这是 Rust 项目 ghtz08/kuguo-kgm-decoder 的 Python 移植版。解码原理基于原项目 README 中记录的发现,主要来自孤心浪子的博客文章和 ix64 的 unlock-music 项目。
注意: 本项目大部分代码逻辑都是借鉴自 ghtz08/kugou-kgm-decoder,仅将其移植到 Python 环境。
感谢 ix64 提供的用于解码的公钥。
- Python 3.3+(使用内置的
lzma和argparse) kugou_key.xz文件(必须放置在kgm_decoder/assets/目录中)
- 克隆此仓库。
- 确保原始 Rust 项目
src/assets目录中的kugou_key.xz文件被复制到本 Python 项目的kgm_decoder/assets/目录中。 - (可选)创建虚拟环境:
python -m venv venv source venv/bin/activate # 在 Windows 上使用 `venv\Scripts\activate`
您可以直接使用 main.py 脚本运行解码器:
python -m kgm_decoder.main <参数>如果您设置了入口点(例如,使用 setup.py),您可能会安装它并将其作为命令运行。
示例:
-
解码单个文件:
python -m kgm_decoder.main /path/to/your/song.kgm
-
解码目录中的所有文件(非递归):
python -m kgm_decoder.main /path/to/your/music_folder/
-
递归解码目录及其子目录中的所有文件:
python -m kgm_decoder.main -r /path/to/your/music_folder/
命令行选项:
| 参数 | 简写 | 描述 |
|---|---|---|
target |
要处理的目标文件或文件夹 | |
--recursive |
-r |
递归处理文件和目录 |
--keep-file |
-k |
解码后保留原始加密文件 |
--help |
-h |
显示帮助信息并退出 |
--version |
显示程序版本号并退出 |
注意: 解码后的输出文件将具有
.mp3扩展名,但根据原始源,实际的音频格式可能会有所不同(例如,M4A、FLAC 等)。未来的改进可能涉及检测实际格式。
A command-line tool, written in Python, to decode encrypted/obfuscated Kugou music files (like .kgm, .vpr, or cache files).
This is a Python port of the Rust project ghtz08/kuguo-kgm-decoder. The decoding principles are based on the findings documented in the original project's README, primarily from 孤心浪子's blog post and the unlock-music project by ix64.
Note: Most of the code logic in this project is adapted from ghtz08/kugou-kgm-decoder, ported to Python environment.
Thanks to ix64 for the public key used in decoding.
- Python 3.3+ (uses built-in
lzmaandargparse) - The
kugou_key.xzfile (must be placed inkgm_decoder/assets/)
- Clone this repository.
- Ensure the
kugou_key.xzfile from the original Rust project'ssrc/assetsdirectory is copied into thekgm_decoder/assets/directory within this Python project. - (Optional) Create a virtual environment:
python -m venv venv source venv/bin/activate # On Windows use `venv\Scripts\activate`
You can run the decoder directly using the main.py script:
python -m kgm_decoder.main <arguments>Or, if you set up entry points (e.g., using setup.py), you might install it and run it as a command.
Examples:
-
Decode a single file:
python -m kgm_decoder.main /path/to/your/song.kgm
-
Decode all files in a directory (non-recursive):
python -m kgm_decoder.main /path/to/your/music_folder/
-
Decode all files in a directory and its subdirectories:
python -m kgm_decoder.main -r /path/to/your/music_folder/
Command-line Options:
| Argument | Short | Description |
|---|---|---|
target |
The target file or folder to be processed | |
--recursive |
-r |
Process files and directories recursively |
--keep-file |
-k |
Keep the original encrypted file after decoding |
--help |
-h |
Show the help message and exit |
--version |
Show program's version number and exit |
Note: The decoded output file will have a
.mp3extension, but the actual audio format inside might vary (e.g., M4A, FLAC, etc.) depending on the original source. Future improvements could involve detecting the actual format.
Contributions are welcome! Here are some ways you can contribute:
- Report bugs or request features by opening issues
- Submit pull requests to fix issues or add new features
- Improve documentation
- Share the project with others who might find it useful