1
0
forked from um/web

Fix Bugs & Add More Detailed Notifications

This commit is contained in:
xhacker-zzz 2022-11-22 01:53:22 +08:00
parent 21d6b3d90f
commit a5de3829db
2 changed files with 27 additions and 9 deletions

View File

@ -40,7 +40,7 @@ export async function extractQQMusicMeta(
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.warn('try using gbk encoding to decode meta'); console.warn('try using gbk encoding to decode meta');
musicMeta.common.artist = ''; musicMeta.common.artist = '';
if (musicMeta.common.artists) { if (!musicMeta.common.artists) {
musicMeta.common.artist = iconv.decode(new Buffer(musicMeta.common.artist ?? ''), 'gbk'); musicMeta.common.artist = iconv.decode(new Buffer(musicMeta.common.artist ?? ''), 'gbk');
} }
else { else {

View File

@ -153,6 +153,8 @@ export default {
this.editing_data.title = data.title; this.editing_data.title = data.title;
this.editing_data.artist = data.artist; this.editing_data.artist = data.artist;
this.editing_data.album = data.album; this.editing_data.album = data.album;
let writeSuccess = true;
let notifyMsg = '成功修改 ' + this.editing_data.title;
try { try {
const musicMeta = await metaParseBlob(new Blob([this.editing_data.blob], { type: mime })); const musicMeta = await metaParseBlob(new Blob([this.editing_data.blob], { type: mime }));
const imageInfo = await GetImageFromURL(this.editing_data.picture); const imageInfo = await GetImageFromURL(this.editing_data.picture);
@ -173,17 +175,33 @@ export default {
} else if (this.editing_data.ext === 'flac') { } else if (this.editing_data.ext === 'flac') {
this.editing_data.blob = new Blob([RewriteMetaToFlac(buffer, newMeta, musicMeta)], { type: mime }); this.editing_data.blob = new Blob([RewriteMetaToFlac(buffer, newMeta, musicMeta)], { type: mime });
} else { } else {
console.info('writing metadata for ' + info.ext + ' is not being supported for now'); writeSuccess = undefined;
notifyMsg = info.ext + '类型文件暂时不支持修改音乐标签';
} }
} catch (e) { } catch (e) {
console.warn('Error while appending cover image to file ' + e); writeSuccess = false;
notifyMsg = '修改' + this.editing_data.title + '未能完成。在写入新的元数据时发生错误:' + e;
} }
this.editing_data.file = URL.createObjectURL(this.editing_data.blob);/**/ this.editing_data.file = URL.createObjectURL(this.editing_data.blob);
if (writeSuccess === true) {
this.$notify.success({ this.$notify.success({
title: '修改成功', title: '修改成功',
message: '成功修改 ' + this.editing_data.title, message: notifyMsg,
duration: 3000, duration: 3000,
}); });
} else if (writeSuccess === false) {
this.$notify.error({
title: '修改失败',
message: notifyMsg,
duration: 3000,
});
} else {
this.$notify.warning({
title: '修改取消',
message: notifyMsg,
duration: 3000,
});
}
}, },
async editFile(data) { async editFile(data) {