|
@ -26,7 +26,7 @@ async function Decrypt(file, raw_filename, raw_ext) { |
|
|
if (!(raw_ext in OriginalExtMap)) { |
|
|
if (!(raw_ext in OriginalExtMap)) { |
|
|
return {status: false, message: "File type is incorrect!"} |
|
|
return {status: false, message: "File type is incorrect!"} |
|
|
} |
|
|
} |
|
|
let new_ext = OriginalExtMap[raw_ext]; |
|
|
const new_ext = OriginalExtMap[raw_ext]; |
|
|
const mime = util.AudioMimeType[new_ext]; |
|
|
const mime = util.AudioMimeType[new_ext]; |
|
|
// 读取文件
|
|
|
// 读取文件
|
|
|
const fileBuffer = await util.GetArrayBuffer(file); |
|
|
const fileBuffer = await util.GetArrayBuffer(file); |
|
@ -38,22 +38,19 @@ async function Decrypt(file, raw_filename, raw_ext) { |
|
|
} |
|
|
} |
|
|
// 导出
|
|
|
// 导出
|
|
|
const musicData = new Blob([audioData], {type: mime}); |
|
|
const musicData = new Blob([audioData], {type: mime}); |
|
|
const musicUrl = URL.createObjectURL(musicData); |
|
|
|
|
|
// 读取Meta
|
|
|
// 读取Meta
|
|
|
let tag = await musicMetadata.parseBlob(musicData); |
|
|
const tag = await musicMetadata.parseBlob(musicData); |
|
|
const info = util.GetFileInfo(tag.common.artist, tag.common.title, raw_filename, new_ext); |
|
|
const info = util.GetFileInfo(tag.common.artist, tag.common.title, raw_filename); |
|
|
let picUrl = util.GetCoverURL(tag); |
|
|
|
|
|
|
|
|
|
|
|
// 返回
|
|
|
// 返回
|
|
|
return { |
|
|
return { |
|
|
status: true, |
|
|
status: true, |
|
|
filename: info.filename, |
|
|
|
|
|
title: info.title, |
|
|
title: info.title, |
|
|
artist: info.artist, |
|
|
artist: info.artist, |
|
|
ext: new_ext, |
|
|
ext: new_ext, |
|
|
album: tag.common.album, |
|
|
album: tag.common.album, |
|
|
picture: picUrl, |
|
|
picture: util.GetCoverURL(tag), |
|
|
file: musicUrl, |
|
|
file: URL.createObjectURL(musicData), |
|
|
mime: mime |
|
|
mime: mime |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|