使用 Python 编写的加密音乐解锁工具
Project description
Takiyasha
Takiyasha 是用来解锁被加密的音乐文件的工具,支持多种加密格式。
Takiyasha 项目是以学习和技术研究的初衷创建的,修改、再分发时请遵循 License。
Takiyasha 解锁部分加密格式文件的能力,来源于此项目:Unlock Music Project - CLI Edition
如果你只想快点体验,查看安装方法
也可以看看:此项目位于 Notabug 上的备份
特性
- 使用 Python 3 编写
- 跨平台:只要系统上可以运行 Python 3 和使用 pip,就可以安装和使用
- 支持多种加密格式
- 可自动识别并解锁没有扩展名的加密文件
- 支持为解锁后的文件补全元数据(包括封面,仅限
.ncm
/.qmc*
/.mflac*
/.mgg*
)
支持的加密格式
- 文件扩展名中含有
.qmc
、.mflac
、.mgg
、.ncm
、.kgm
、.vpr
字样的文件。- 可在安装后使用
takiyasha --formats
查看所有支持的加密格式。
- 可在安装后使用
- 目前(截至2022-04-07)不支持解锁以下来源的加密文件:
- 版本 1857 及以上的 QQ 音乐 PC 客户端(
.mflac*
、.mgg*
) - 版本 11.55 及以上的 QQ 音乐 Android 客户端(
.mflac*
、.mgg*
) - Apple Music/Spotify 等流媒体平台(在可预见的未来没有可能支持)
- 版本 1857 及以上的 QQ 音乐 PC 客户端(
适用群体
- 经常批量下载和解锁加密格式的用户
- 重视结果大于重视过程的用户
- 受限于 Python 的语言特性,解锁过程很慢
- 我们的测试结果表明,在 Pyston 环境下,平均解锁速度提高了36%。因此,如果有条件,可以使用 Pyston 替代 Python 以加速解锁
- 想要研究算法和提升自己技术水平的开发者
如何安装
- 所需运行环境
- Python 版本:大于或等于 3.8
- 所需依赖
- Python 包:click - 提供命令行界面
- Python 包:mutagen - 向输出文件写入歌曲信息
- Python 包:pycryptodomex - 部分加密格式的解锁支持
- Python 包:requests - 为缺失封面的已解锁文件下载封面
(推荐)从 Pypi 安装
使用命令:pip install -U takiyasha
通过已发布的 wheel (.whl) 包文件安装
(不推荐)直接从仓库安装
使用命令:
Github: pip install -U git+https://github.com/nukemiko/takiyasha
Notabug: pip install -U git+https://notabug.org/MiketsuSmasher/takiyasha
需要你先安装git
。
如何使用
命令行(CMD/Powershell/Terminal 等)
Takiyasha 提供了 3 个命令入口:
takiyasha
unlocker
takiyasha-unlocker
它们只存在命令长度上的区别。
- 直接执行命令:
takiyasha file1 file2 dir1 ...
unlocker file3 file4 dir2 ...
- 直接运行模块:
python -m takiyasha file5 file6 dir3 dir4 ...
无论怎样运行,都可以使用 -h/--help
选项获得更多帮助信息。
作为 Python 模块导入使用
-
创建一个 Decoder 对象:
from takiyasha import new_decoder qmcflac_dec = new_decoder('test.qmcflac') mflac_dec = new_decoder('test.mflac') ncm_dec = new_decoder('test.ncm') noop_dec = new_decoder('test.kv2') # “test.kv2”是扩展名为“kv2”的 mp3 文件 print(qmcflac_dec, mflac_dec, ncm_dec, noop_dec, end='\n')
输出:
<QMCFormatDecoder at 0x7fdbf2057760 name='test.qmcflac'> # QMCv1 加密 <QMCFormatDecoder at 0x7fdbf2ac1090 name='test.mflac'> # QMCv2 加密 <NCMFormatDecoder at 0x7fdbf15622f0 name='test.ncm'> # NCM 加密 <NoOperationDecoder at 0x7fdbf1563400 name='test.kv2'> # 无需解锁操作
-
执行解锁操作并保存到文件:
save_filename = f'test{idx}.{audio_format}' with open(save_filename, 'wb') as f: for block in decoder: f.write(block) print('Saved:', save_filename)
输出:
Saved: test0.flac Saved: test1.flac Saved: test2.flac Saved: test3.mp3
使用
file
命令验证输出文件是否正确:> file test0.flac test1.flac test2.flac test3.mp3 test0.flac: FLAC audio bitstream data, 16 bit, stereo, 44.1 kHz, 13379940 samples test1.flac: FLAC audio bitstream data, 16 bit, stereo, 44.1 kHz, 16585716 samples test2.flac: FLAC audio bitstream data, 16 bit, stereo, 44.1 kHz, 10222154 samples test3.mp3: Audio file with ID3 version 2.4.0, contains: MPEG ADTS, layer III, v1, 320 kbps, 44.1 kHz, Stereo
-
针对一些内嵌封面等元数据的加密格式(例如 NCM),还可将其嵌入解锁后的文件:
from takiyasha import new_tag with open('text2.flac', 'rb') as ncmfile: tag = new_tag(ncm_decrypted_file) # 上文中的 NCMFormatDecoder 对象已经储存了找到的元数据 tag.title = ncm_dec.music_title tag.artist = ncm_dec.music_artists tag.album = ncm_dec.music_album tag.comment = ncm_dec.music_identifier tag.cover = ncm_dec.music_cover_data ncm_decrypted_file.seek(0, 0) tag.save(ncm_decrypted_file)
常见问题、提示和错误信息
请查看相关 Wiki 页面:问题解决
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
takiyasha-0.4.2.tar.gz
(130.0 kB
view hashes)
Built Distribution
takiyasha-0.4.2-py3-none-any.whl
(133.7 kB
view hashes)
Close
Hashes for takiyasha-0.4.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c7c545268c380f5ee044e71cb9560357c0a61a81b3d1b2ae2701c9f9286eff5c |
|
MD5 | dcd88601548bdb3859ec097e078b801d |
|
BLAKE2b-256 | 22e696c1f901252b4c2aed48d61aaed6afe0ae82eb4a2ec34791172b2976d14a |