喜马拉雅xm音频解码

github

https://github.com/Diaoxiaozhang/Ximalaya-XM-Decrypt

pip install python-magic
pip install mutagen
pip install wasmer
pip install wasmer_compiler_cranelift
pip install python-magic-bin

报错 ImportError: failed to find libmagic. Check your installation

import magic
def find_ext(data):
    exts = ["m4a", "mp3", "flac", "wav"]
    value = magic.from_buffer(data).lower()
    for ext in exts:
        if ext in value:
            return ext
    raise Exception(f"unexpected format {value}")
def decrypt_xm_file(from_file, output_path='./output'):
    print(f"正在解密{from_file}")
    data = read_file(from_file)
    info, audio_data = xm_decrypt(data)
    output = f"{output_path}/{replace_invalid_chars(info.album)}/{replace_invalid_chars(info.title)}.{find_ext(audio_data[:0xff])}"
   

magic只是为了用来检测下载文件的文件类型,但是我下载的文件都是音频 m4a 或者mp3, 可以下载几条验证一下,我用m4a类型保存看着比较正常,直接写死的m4a

output = f"{output_path}/{replace_invalid_chars(info.album)}/{replace_invalid_chars(info.title)}.m4a"

libmagic报错windows系统不好解决,绕过不解决了。

https://github.com/ahupp/python-magic#dependencies
https://segmentfault.com/q/1010000043254750
https://github.com/pidydx/libmagicwin64
https://www.saoniuhuo.com/question/detail-2221718.html
https://blog.csdn.net/RelaxTech/article/details/131447227

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值