|
|
@ -60,6 +60,7 @@ export async function Decrypt(file, raw_filename, raw_ext) {
|
|
|
|
const musicMeta = await musicMetadata.parseBlob(musicBlob);
|
|
|
|
const musicMeta = await musicMetadata.parseBlob(musicBlob);
|
|
|
|
for (let metaIdx in musicMeta.native) {
|
|
|
|
for (let metaIdx in musicMeta.native) {
|
|
|
|
if (musicMeta.native[metaIdx].some(item => item.id === "TCON" && item.value === "(12)")) {
|
|
|
|
if (musicMeta.native[metaIdx].some(item => item.id === "TCON" && item.value === "(12)")) {
|
|
|
|
|
|
|
|
console.log("The metadata is using gbk encoding")
|
|
|
|
musicMeta.common.artist = decode(musicMeta.common.artist, "gbk");
|
|
|
|
musicMeta.common.artist = decode(musicMeta.common.artist, "gbk");
|
|
|
|
musicMeta.common.title = decode(musicMeta.common.title, "gbk");
|
|
|
|
musicMeta.common.title = decode(musicMeta.common.title, "gbk");
|
|
|
|
musicMeta.common.album = decode(musicMeta.common.album, "gbk");
|
|
|
|
musicMeta.common.album = decode(musicMeta.common.album, "gbk");
|
|
|
@ -77,21 +78,25 @@ export async function Decrypt(file, raw_filename, raw_ext) {
|
|
|
|
const imageInfo = await GetWebImage(imgUrl);
|
|
|
|
const imageInfo = await GetWebImage(imgUrl);
|
|
|
|
if (imageInfo.url !== "") {
|
|
|
|
if (imageInfo.url !== "") {
|
|
|
|
imgUrl = imageInfo.url
|
|
|
|
imgUrl = imageInfo.url
|
|
|
|
if (ext === "mp3") {
|
|
|
|
try {
|
|
|
|
let writer = new ID3Writer(musicDecoded)
|
|
|
|
if (ext === "mp3") {
|
|
|
|
writer.setFrame('APIC', {
|
|
|
|
let writer = new ID3Writer(musicDecoded)
|
|
|
|
type: 3,
|
|
|
|
writer.setFrame('APIC', {
|
|
|
|
data: imageInfo.buffer,
|
|
|
|
type: 3,
|
|
|
|
description: "Cover",
|
|
|
|
data: imageInfo.buffer,
|
|
|
|
})
|
|
|
|
description: "Cover",
|
|
|
|
writer.addTag();
|
|
|
|
})
|
|
|
|
musicDecoded = writer.arrayBuffer
|
|
|
|
writer.addTag();
|
|
|
|
musicBlob = new Blob([musicDecoded], {type: mime});
|
|
|
|
musicDecoded = writer.arrayBuffer
|
|
|
|
} else if (ext === 'flac') {
|
|
|
|
musicBlob = new Blob([musicDecoded], {type: mime});
|
|
|
|
const writer = new MetaFlac(Buffer.from(musicDecoded))
|
|
|
|
} else if (ext === 'flac') {
|
|
|
|
writer.importPictureFromBuffer(Buffer.from(imageInfo.buffer))
|
|
|
|
const writer = new MetaFlac(Buffer.from(musicDecoded))
|
|
|
|
musicDecoded = writer.save()
|
|
|
|
writer.importPictureFromBuffer(Buffer.from(imageInfo.buffer))
|
|
|
|
musicBlob = new Blob([musicDecoded], {type: mime});
|
|
|
|
musicDecoded = writer.save()
|
|
|
|
|
|
|
|
musicBlob = new Blob([musicDecoded], {type: mime});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} catch (e) {
|
|
|
|
|
|
|
|
console.warn("Error while appending cover image to file " + e)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|