突然发现淘宝88vip到期后,网易云音乐的下载音乐是ncm格式的,不能播放,做一下转换

发布时间 2023-11-23 14:29:07作者: 吃了上顿吃下顿

ncm 转换 为mp3, pip3 install ncmdump

from ncmdump import dump
import os
import fnmatch

print("如留空,默认: D:\\CloudMusic\\\VipSongsDownload\\")
download_folder = input("下载路径:") or "D:\\CloudMusic\\\VipSongsDownload\\"
os.system('cls')
waiting = True
print("当前下载路径:" + download_folder)
print("等待转换...")


def all_files(root, patterns='*', single_level=False, yield_folder=False):
    patterns = patterns.split(';')
    for path, subdirs, files in os.walk(root):
        if yield_folder:
            files.extend(subdirs)
        files.sort()
        for fname in files:
            for pt in patterns:
                if fnmatch.fnmatch(fname, pt):
                    yield os.path.join(path, fname)
                    break
        if single_level:
            break


while 1:
    thefile = list(all_files(download_folder, '*.ncm'))
    print(thefile)
    for item in thefile:
        if (waiting == True):
            waiting = False
            os.system('cls')
        print(item, dump(item), "转换成功!")
        delete = os.remove(item)
    break
View Code

python main.py, 转换完成了, 想备份原来的ncm文件的,提前手动备份