Show Detail Info While Error Occurred
This commit is contained in:
parent
b68efea15b
commit
c71cb8ee85
11
src/App.vue
11
src/App.vue
@ -140,10 +140,13 @@
|
|||||||
data = await MFlacDecrypt.Decrypt(file.raw);
|
data = await MFlacDecrypt.Decrypt(file.raw);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
console.log("Not Supported File!");
|
data = {
|
||||||
|
status: false,
|
||||||
|
message: "不支持此文件格式",
|
||||||
|
};
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (null != data) {
|
if (data.status) {
|
||||||
this.tableData.push(data);
|
this.tableData.push(data);
|
||||||
this.$notify.success({
|
this.$notify.success({
|
||||||
title: '解锁成功',
|
title: '解锁成功',
|
||||||
@ -160,8 +163,8 @@
|
|||||||
window._paq.push(["trackEvent", "Unlock", "Success", JSON.stringify(_rp_data)]);
|
window._paq.push(["trackEvent", "Unlock", "Success", JSON.stringify(_rp_data)]);
|
||||||
} else {
|
} else {
|
||||||
this.$notify.error({
|
this.$notify.error({
|
||||||
title: '错误',
|
title: '出现问题',
|
||||||
message: '解析此文件时出现问题,请查看<a target="_blank" href="https://github.com/ix64/unlock-music/wiki/使用提示">使用提示</a>',
|
message: data.message + ',参考<a target="_blank" href="https://github.com/ix64/unlock-music/wiki/使用提示">使用提示</a>',
|
||||||
dangerouslyUseHTMLString: true
|
dangerouslyUseHTMLString: true
|
||||||
});
|
});
|
||||||
window._paq.push(["trackEvent", "Unlock", "Error", file.name]);
|
window._paq.push(["trackEvent", "Unlock", "Error", file.name]);
|
||||||
|
@ -4,7 +4,10 @@ export {Decrypt}
|
|||||||
async function Decrypt(file) {
|
async function Decrypt(file) {
|
||||||
// 获取扩展名
|
// 获取扩展名
|
||||||
let filename_ext = file.name.substring(file.name.lastIndexOf(".") + 1, file.name.length).toLowerCase();
|
let filename_ext = file.name.substring(file.name.lastIndexOf(".") + 1, file.name.length).toLowerCase();
|
||||||
if (filename_ext !== "mflac") return;
|
if (filename_ext !== "mflac") return {
|
||||||
|
status: false,
|
||||||
|
message: "File type is incorrect!",
|
||||||
|
};
|
||||||
// 读取文件
|
// 读取文件
|
||||||
const fileBuffer = await new Promise(resolve => {
|
const fileBuffer = await new Promise(resolve => {
|
||||||
const reader = new FileReader();
|
const reader = new FileReader();
|
||||||
@ -18,7 +21,10 @@ async function Decrypt(file) {
|
|||||||
|
|
||||||
// 转换数据
|
// 转换数据
|
||||||
const seed = new Mask();
|
const seed = new Mask();
|
||||||
if (!seed.DetectMask(audioData)) return;
|
if (!seed.DetectMask(audioData)) return{
|
||||||
|
status: false,
|
||||||
|
message: "此音乐无法解锁,目前mflac格式不提供完整支持",
|
||||||
|
};
|
||||||
for (let cur = 0; cur < audioDataLen; ++cur) {
|
for (let cur = 0; cur < audioDataLen; ++cur) {
|
||||||
audioData[cur] ^= seed.NextMask();
|
audioData[cur] ^= seed.NextMask();
|
||||||
}
|
}
|
||||||
@ -51,6 +57,8 @@ async function Decrypt(file) {
|
|||||||
}
|
}
|
||||||
// 返回*/
|
// 返回*/
|
||||||
return {
|
return {
|
||||||
|
status: true,
|
||||||
|
message: "",
|
||||||
filename: filename,
|
filename: filename,
|
||||||
title: title,
|
title: title,
|
||||||
artist: artist,
|
artist: artist,
|
||||||
|
@ -24,10 +24,10 @@ async function Decrypt(file) {
|
|||||||
|
|
||||||
if (dataView.getUint32(0, true) !== 0x4e455443 ||
|
if (dataView.getUint32(0, true) !== 0x4e455443 ||
|
||||||
dataView.getUint32(4, true) !== 0x4d414446
|
dataView.getUint32(4, true) !== 0x4d414446
|
||||||
) {
|
) return {
|
||||||
console.log({type: "error", data: "not ncm file"});
|
status: false,
|
||||||
return;
|
message: "此ncm文件已损坏",
|
||||||
}
|
};
|
||||||
|
|
||||||
let offset = 10;
|
let offset = 10;
|
||||||
|
|
||||||
@ -50,13 +50,12 @@ async function Decrypt(file) {
|
|||||||
|
|
||||||
const result = new Uint8Array(plainText.sigBytes);
|
const result = new Uint8Array(plainText.sigBytes);
|
||||||
|
|
||||||
{
|
|
||||||
const words = plainText.words;
|
const words = plainText.words;
|
||||||
const sigBytes = plainText.sigBytes;
|
const sigBytes = plainText.sigBytes;
|
||||||
for (let i = 0; i < sigBytes; i++) {
|
for (let i = 0; i < sigBytes; i++) {
|
||||||
result[i] = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
|
result[i] = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return result.slice(17);
|
return result.slice(17);
|
||||||
})();
|
})();
|
||||||
@ -130,13 +129,12 @@ async function Decrypt(file) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (musicMeta.format === undefined) {
|
if (musicMeta.format === undefined) {
|
||||||
musicMeta.format = (() => {
|
|
||||||
const [f, L, a, C] = audioData;
|
const [f, L, a, C] = audioData;
|
||||||
if (f === 0x66 && L === 0x4c && a === 0x61 && C === 0x43) {
|
if (f === 0x66 && L === 0x4c && a === 0x61 && C === 0x43) {
|
||||||
return "flac";
|
musicMeta.format = "flac";
|
||||||
|
} else {
|
||||||
|
musicMeta.format = "mp3";
|
||||||
}
|
}
|
||||||
return "mp3";
|
|
||||||
})();
|
|
||||||
}
|
}
|
||||||
const mime = audio_mime_type[musicMeta.format];
|
const mime = audio_mime_type[musicMeta.format];
|
||||||
|
|
||||||
|
@ -31,7 +31,10 @@ async function Decrypt(file) {
|
|||||||
new_ext = "flac";
|
new_ext = "flac";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return;
|
return {
|
||||||
|
status: false,
|
||||||
|
message: "File type is incorrect!",
|
||||||
|
};
|
||||||
}
|
}
|
||||||
const mime = audio_mime_type[new_ext];
|
const mime = audio_mime_type[new_ext];
|
||||||
// 读取文件
|
// 读取文件
|
||||||
|
Loading…
Reference in New Issue
Block a user