Browse Source

Remove Useless Information

20230320
MengYX 5 years ago
parent
commit
0c0299d63a
No known key found for this signature in database GPG Key ID: E63F9C7303E8F604
  1. 2
      src/App.vue
  2. 4
      src/component/util.js
  3. 9
      src/decrypt/mflac.js
  4. 5
      src/decrypt/ncm.js
  5. 13
      src/decrypt/qmc.js
  6. 17
      src/decrypt/raw.js
  7. 5
      src/decrypt/util.js

2
src/App.vue

@ -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) {

4
src/component/util.js

@ -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();

9
src/decrypt/mflac.js

@ -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"
}
}

5
src/decrypt/ncm.js

@ -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
};
}

13
src/decrypt/qmc.js

@ -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
}
}

17
src/decrypt/raw.js

@ -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]
}
}

5
src/decrypt/util.js

@ -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};
}
/**

Loading…
Cancel
Save