diff --git a/src/decrypt/common.js b/src/decrypt/common.js index 101a975..fcb4195 100644 --- a/src/decrypt/common.js +++ b/src/decrypt/common.js @@ -2,6 +2,7 @@ const NcmDecrypt = require("./ncm"); const QmcDecrypt = require("./qmc"); const RawDecrypt = require("./raw"); const MFlacDecrypt = require("./mflac"); +const TmDecrypt = require("./tm"); export {CommonDecrypt} @@ -16,9 +17,11 @@ async function CommonDecrypt(file) { case "mp3":// Raw Mp3 case "flac"://Raw Flac case "m4a":// todo: Raw M4A + rt_data = await RawDecrypt.Decrypt(file.raw, raw_filename, raw_ext); + break; case "tm0":// QQ Music IOS Mp3 case "tm3":// QQ Music IOS Mp3 - rt_data = await RawDecrypt.Decrypt(file.raw, raw_filename, raw_ext); + rt_data = await RawDecrypt.Decrypt(file.raw, raw_filename, "mp3"); break; case "qmc3"://QQ Music Android Mp3 case "qmc0"://QQ Music Android Mp3 @@ -31,7 +34,7 @@ async function CommonDecrypt(file) { break; case "tm2":// todo: QQ Music IOS M4A case "tm6":// todo: QQ Music IOS M4A - debugger; + rt_data = await TmDecrypt.Decrypt(file.raw, raw_filename); break; default: rt_data = {status: false, message: "不支持此文件格式",} diff --git a/src/decrypt/tm.js b/src/decrypt/tm.js new file mode 100644 index 0000000..185de44 --- /dev/null +++ b/src/decrypt/tm.js @@ -0,0 +1,14 @@ +const rawDecrypt = require("./raw"); +const util = require("./util"); +export {Decrypt} +const header = [0x00, 0x00, 0x00, 0x20, 0x66, 0x74, 0x79, 0x70]; + +async function Decrypt(file, raw_filename) { + const fileBuffer = await util.GetArrayBuffer(file); + const audioData = new Uint8Array(fileBuffer); + for (let cur = 0; cur < 8; ++cur) { + audioData[cur] = header[cur]; + } + const musicData = new Blob([audioData], {type: "audio/mp4"}); + return await rawDecrypt.Decrypt(musicData, raw_filename, "m4a") +}