
NCM 是网易云音乐的加密格式需要先解密。以下是个人开发的一个加密格式转换器把NCM格式的文件转化为MP3格式的歌曲## 使用前务必更改代码中的文件路径 NCM 批量转 MP3 脚本 用法: python ncm2mp3.py [目录路径] 不传参则默认处理 D:\CloudMusic\VipSongsDownload import os import sys import subprocess import glob NCMDUMP rC:\Users\Python\Python311\Scripts\ncmdump.exe def convert_dir(src_dir: str): if not os.path.isdir(src_dir): print(fDir not found: {src_dir}) return ncm_files glob.glob(os.path.join(src_dir, *.ncm)) if not ncm_files: print(fNo .ncm files found: {src_dir}) return total len(ncm_files) success, fail 0, 0 print(fFound {total} NCM files, converting...\n) for i, ncm_path in enumerate(ncm_files, 1): name os.path.basename(ncm_path) print(f[{i}/{total}] {name}, end ... ) result subprocess.run( [NCMDUMP, ncm_path], capture_outputTrue, textTrue, encodingutf-8, errorsreplace ) # ncmdump 成功时 exit code 为 0输出的 mp3 与 ncm 同目录同名 mp3_path os.path.splitext(ncm_path)[0] .mp3 if result.returncode 0 and os.path.isfile(mp3_path): size_mb os.path.getsize(mp3_path) / 1024 / 1024 print(f[OK] ({size_mb:.1f} MB)) success 1 else: err result.stderr.strip() or result.stdout.strip() or unknown error print(f[FAIL] {err}) fail 1 print(f\nDone: {success} ok, {fail} failed ({total} total)) if __name__ __main__: target sys.argv[1] if len(sys.argv) 1 else rD:\带转换的文件路径 convert_dir(target)