1
0
forked from um/web

Remove Useless Information

This commit is contained in:
MengYX 2020-02-06 16:18:40 +08:00
parent 3ee9f5d2d1
commit 0c0299d63a
No known key found for this signature in database
GPG Key ID: E63F9C7303E8F604
7 changed files with 19 additions and 38 deletions

View File

@ -98,7 +98,7 @@
let _rp_data = [data.title, data.artist, data.album];
window._paq.push(["trackEvent", "Unlock", data.rawExt + "," + data.mime, JSON.stringify(_rp_data)]);
} else {
this.showFail(data.message, data.rawFilename)
this.showFail(data.message, data.rawFilename + "." + data.rawExt)
}
},
showFail(errInfo, filename) {

View File

@ -5,15 +5,13 @@ export function DownloadBlobMusic(data, format) {
case "1":
a.download = data.title + "." + data.ext;
break;
default:
case "2":
a.download = data.artist + " - " + data.title + "." + data.ext;
break;
case "3":
a.download = data.title + " - " + data.artist + "." + data.ext;
break;
default:
a.download = data.filename;
break;
}
document.body.append(a);
a.click();

View File

@ -25,22 +25,19 @@ async function Decrypt(file, raw_filename, raw_ext) {
}
// 导出
const musicData = new Blob([audioData], {type: "audio/flac"});
const musicUrl = URL.createObjectURL(musicData);
// 读取Meta
let tag = await musicMetadata.parseBlob(musicData);
const info = util.GetFileInfo(tag.common.artist, tag.common.title, raw_filename, "flac");
let picUrl = util.GetCoverURL(tag);
const info = util.GetFileInfo(tag.common.artist, tag.common.title, raw_filename);
// 返回
return {
status: true,
filename: info.filename,
title: info.title,
artist: info.artist,
ext: 'flac',
album: tag.common.album,
picture: picUrl,
file: musicUrl,
picture: util.GetCoverURL(tag),
file: URL.createObjectURL(musicData),
mime: "audio/flac"
}
}

View File

@ -49,17 +49,14 @@ async function Decrypt(file) {
}
const musicData = new Blob([audioData], {type: mime});
const musicUrl = URL.createObjectURL(musicData);
const filename = artists.join(" & ") + " - " + musicMeta.musicName + "." + musicMeta.format;
return {
status: true,
filename: filename,
title: musicMeta.musicName,
artist: artists.join(" & "),
ext: musicMeta.format,
album: musicMeta.album,
picture: musicMeta.albumPic,
file: musicUrl,
file: URL.createObjectURL(musicData),
mime: mime
};
}

View File

@ -26,7 +26,7 @@ async function Decrypt(file, raw_filename, raw_ext) {
if (!(raw_ext in OriginalExtMap)) {
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 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 musicUrl = URL.createObjectURL(musicData);
// 读取Meta
let tag = await musicMetadata.parseBlob(musicData);
const info = util.GetFileInfo(tag.common.artist, tag.common.title, raw_filename, new_ext);
let picUrl = util.GetCoverURL(tag);
const tag = await musicMetadata.parseBlob(musicData);
const info = util.GetFileInfo(tag.common.artist, tag.common.title, raw_filename);
// 返回
return {
status: true,
filename: info.filename,
title: info.title,
artist: info.artist,
ext: new_ext,
album: tag.common.album,
picture: picUrl,
file: musicUrl,
picture: util.GetCoverURL(tag),
file: URL.createObjectURL(musicData),
mime: mime
}
}

View File

@ -4,23 +4,16 @@ export {Decrypt}
async function Decrypt(file, raw_filename, raw_ext) {
let tag = await musicMetadata.parseBlob(file);
let fileUrl = URL.createObjectURL(file);
const picUrl = util.GetCoverURL(tag);
const mime = util.AudioMimeType[raw_ext];
const info = util.GetFileInfo(tag.common.artist, tag.common.title, raw_filename, raw_ext);
const tag = await musicMetadata.parseBlob(file);
const info = util.GetFileInfo(tag.common.artist, tag.common.title, raw_filename);
return {
status: true,
filename: info.filename,
title: info.title,
artist: info.artist,
ext: raw_ext,
album: tag.common.album,
picture: picUrl,
file: fileUrl,
mime: mime
picture: util.GetCoverURL(tag),
file: URL.createObjectURL(file),
mime: util.AudioMimeType[raw_ext]
}
}

View File

@ -18,7 +18,7 @@ const AudioMimeType = {
ogg: "audio/ogg"
};
function GetFileInfo(artist, title, filenameNoExt, ext) {
function GetFileInfo(artist, title, filenameNoExt) {
let newArtist = "", newTitle = "";
let filenameArray = filenameNoExt.split("-");
if (filenameArray.length > 1) {
@ -34,8 +34,7 @@ function GetFileInfo(artist, title, filenameNoExt, ext) {
if (typeof title == "string" && title !== "") {
newTitle = title;
}
let newFilename = newArtist + " - " + newTitle + "." + ext;
return {artist: newArtist, title: newTitle, filename: newFilename};
return {artist: newArtist, title: newTitle};
}
/**
@ -48,4 +47,4 @@ function GetCoverURL(metadata) {
pic_url = URL.createObjectURL(pic);
}
return pic_url;
}
}