|
|
@ -39,25 +39,30 @@ export async function Decrypt(file, raw_filename, raw_ext) {
|
|
|
|
if (artists.length === 0) artists.push(info.artist);
|
|
|
|
if (artists.length === 0) artists.push(info.artist);
|
|
|
|
|
|
|
|
|
|
|
|
if (musicMeta.format === undefined) musicMeta.format = DetectAudioExt(audioData, "mp3");
|
|
|
|
if (musicMeta.format === undefined) musicMeta.format = DetectAudioExt(audioData, "mp3");
|
|
|
|
|
|
|
|
console.log(musicMeta)
|
|
|
|
|
|
|
|
|
|
|
|
const imageInfo = await GetWebImage(musicMeta.albumPic);
|
|
|
|
const imageInfo = await GetWebImage(musicMeta.albumPic);
|
|
|
|
|
|
|
|
console.log(imageInfo)
|
|
|
|
|
|
|
|
try {
|
|
|
|
if (musicMeta.format === "mp3") {
|
|
|
|
if (musicMeta.format === "mp3") {
|
|
|
|
audioData = await WriteMp3Meta(
|
|
|
|
audioData = await WriteMp3Meta(
|
|
|
|
audioData, artists, info.title, musicMeta.album, imageInfo.buffer, musicMeta.albumPic);
|
|
|
|
audioData, artists, info.title, musicMeta.album, imageInfo.buffer, musicMeta.albumPic);
|
|
|
|
} else if (musicMeta.format === "flac") {
|
|
|
|
} else if (musicMeta.format === "flac") {
|
|
|
|
const writer = new MetaFlac(Buffer.from(audioData))
|
|
|
|
const writer = new MetaFlac(Buffer.from(audioData))
|
|
|
|
writer.setTag("TITLE=" + info.title);
|
|
|
|
//writer.setTag("TITLE=" + info.title);
|
|
|
|
writer.setTag("ALBUM=" + musicMeta.album);
|
|
|
|
//writer.setTag("ALBUM=" + musicMeta.album);
|
|
|
|
artists.forEach(artist => writer.setTag("ARTIST=" + artist));
|
|
|
|
//artists.forEach(artist => writer.setTag("ARTIST=" + artist));
|
|
|
|
writer.importPictureFromBuffer(Buffer.from(imageInfo.buffer))
|
|
|
|
writer.importPictureFromBuffer(Buffer.from(imageInfo.buffer))
|
|
|
|
audioData = writer.save()
|
|
|
|
audioData = writer.save()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
console.log(imageInfo)
|
|
|
|
} catch (e) {
|
|
|
|
|
|
|
|
console.warn("Error while appending cover image to file " + e)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const mime = AudioMimeType[musicMeta.format];
|
|
|
|
const mime = AudioMimeType[musicMeta.format];
|
|
|
|
const musicData = new Blob([audioData], {type: mime});
|
|
|
|
const musicData = new Blob([audioData], {type: mime});
|
|
|
|
|
|
|
|
|
|
|
|
let x = {
|
|
|
|
return {
|
|
|
|
status: true,
|
|
|
|
status: true,
|
|
|
|
title: info.title,
|
|
|
|
title: info.title,
|
|
|
|
artist: info.artist,
|
|
|
|
artist: info.artist,
|
|
|
@ -67,8 +72,6 @@ export async function Decrypt(file, raw_filename, raw_ext) {
|
|
|
|
file: URL.createObjectURL(musicData),
|
|
|
|
file: URL.createObjectURL(musicData),
|
|
|
|
mime: mime
|
|
|
|
mime: mime
|
|
|
|
};
|
|
|
|
};
|
|
|
|
console.log(x)
|
|
|
|
|
|
|
|
return x;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|