Merge pull request #2 from ix64/pull/1

Fix bugs after using music-metadata-browser
This commit is contained in:
MengYX 2019-09-08 14:50:39 +08:00 committed by GitHub
commit 82e4ec6312
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 51 additions and 51 deletions

86
package-lock.json generated
View File

@ -2501,7 +2501,7 @@
},
"chainsaw": {
"version": "0.0.9",
"resolved": "https://registry.npmjs.org/chainsaw/-/chainsaw-0.0.9.tgz",
"resolved": "https://registry.npm.taobao.org/chainsaw/download/chainsaw-0.0.9.tgz",
"integrity": "sha1-EaBRAtHEx4W20EFdM21aOhYSkT4=",
"requires": {
"traverse": ">=0.3.0 <0.4"
@ -3872,9 +3872,9 @@
"dev": true
},
"element-ui": {
"version": "2.11.1",
"resolved": "https://registry.npm.taobao.org/element-ui/download/element-ui-2.11.1.tgz",
"integrity": "sha1-K2f57uPtouaISHPBxYnL4w2anWA=",
"version": "2.12.0",
"resolved": "https://registry.npm.taobao.org/element-ui/download/element-ui-2.12.0.tgz",
"integrity": "sha1-qJO8Ea5Pfbt+nVQWBvI+ZD8THuQ=",
"requires": {
"async-validator": "~1.8.1",
"babel-helper-vue-jsx-merge-props": "^2.0.0",
@ -3995,7 +3995,7 @@
},
"es6-object-assign": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/es6-object-assign/-/es6-object-assign-1.1.0.tgz",
"resolved": "https://registry.npm.taobao.org/es6-object-assign/download/es6-object-assign-1.1.0.tgz",
"integrity": "sha1-wsNYJlYkfDnqEHyx5mUrb58kUjw="
},
"escape-html": {
@ -4373,8 +4373,8 @@
},
"file-type": {
"version": "12.3.0",
"resolved": "https://registry.npmjs.org/file-type/-/file-type-12.3.0.tgz",
"integrity": "sha512-4E4Esq9KLwjYCY32E7qSmd0h7LefcniZHX+XcdJ4Wfx1uGJX7QCigiqw/U0yT7WOslm28yhxl87DJ0wHYv0RAA=="
"resolved": "https://registry.npm.taobao.org/file-type/download/file-type-12.3.0.tgz?cache=0&sync_timestamp=1567527306315&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Ffile-type%2Fdownload%2Ffile-type-12.3.0.tgz",
"integrity": "sha1-dNdV5dycXLx+5vGCUptFOQasiMI="
},
"filesize": {
"version": "3.6.1",
@ -5382,7 +5382,7 @@
},
"hashish": {
"version": "0.0.4",
"resolved": "https://registry.npmjs.org/hashish/-/hashish-0.0.4.tgz",
"resolved": "https://registry.npm.taobao.org/hashish/download/hashish-0.0.4.tgz",
"integrity": "sha1-bWC8b/r3Ebav1g5CbQd5iAFOZVQ=",
"requires": {
"traverse": ">=0.2.4"
@ -5861,8 +5861,8 @@
},
"is-arguments": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/is-arguments/-/is-arguments-1.0.4.tgz",
"integrity": "sha512-xPh0Rmt8NE65sNzvyUmWgI1tz3mKq74lGA0mL8LYZcoIzKOzDh6HmrYm3d18k60nHerC8A9Km8kYu87zfSFnLA=="
"resolved": "https://registry.npm.taobao.org/is-arguments/download/is-arguments-1.0.4.tgz",
"integrity": "sha1-P6+WbHy6D/Q3+zH2JQCC/PBEjPM="
},
"is-arrayish": {
"version": "0.2.1",
@ -5974,8 +5974,8 @@
},
"is-generator-function": {
"version": "1.0.7",
"resolved": "https://registry.npmjs.org/is-generator-function/-/is-generator-function-1.0.7.tgz",
"integrity": "sha512-YZc5EwyO4f2kWCax7oegfuSr9mFz1ZvieNYBEjmukLxgXfBUbxAWGVF7GZf0zidYtoBl3WvC07YK0wT76a+Rtw=="
"resolved": "https://registry.npm.taobao.org/is-generator-function/download/is-generator-function-1.0.7.tgz",
"integrity": "sha1-0hMuUpuwAAp/gHlNS99c1eWBNSI="
},
"is-glob": {
"version": "4.0.1",
@ -5988,7 +5988,7 @@
},
"is-nan": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/is-nan/-/is-nan-1.2.1.tgz",
"resolved": "https://registry.npm.taobao.org/is-nan/download/is-nan-1.2.1.tgz",
"integrity": "sha1-n69ltvttskt/XAYoR16nH5iEAeI=",
"requires": {
"define-properties": "^1.1.1"
@ -6819,8 +6819,8 @@
},
"music-metadata": {
"version": "4.5.2",
"resolved": "https://registry.npmjs.org/music-metadata/-/music-metadata-4.5.2.tgz",
"integrity": "sha512-uZuNeY1oY67QOFkaPiNDJ4ALtDLIEXr/B+E1HBBlc3Jub9kqdABgggJX5GQIo8E95fD8vZtXEyqZ5NMm1LM3IA==",
"resolved": "https://registry.npm.taobao.org/music-metadata/download/music-metadata-4.5.2.tgz",
"integrity": "sha1-FWEtLF3tALu0TxCPxuwCFop3t7c=",
"requires": {
"content-type": "^1.0.4",
"debug": "^4.1.0",
@ -6832,15 +6832,15 @@
"dependencies": {
"media-typer": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/media-typer/-/media-typer-1.1.0.tgz",
"integrity": "sha512-aisnrDP4GNe06UcKFnV5bfMNPBUw4jsLGaWwWfnH3v02GnBuXX2MCVn5RbrWo0j3pczUilYblq7fQ7Nw2t5XKw=="
"resolved": "https://registry.npm.taobao.org/media-typer/download/media-typer-1.1.0.tgz",
"integrity": "sha1-ardLjy0zIPIGSyqHo455Mf86VWE="
}
}
},
"music-metadata-browser": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/music-metadata-browser/-/music-metadata-browser-1.3.0.tgz",
"integrity": "sha512-4w3rzlLaJoDthtPkzd9GyBzWzgWs1zJ7iOeIFoxJ7NDpOCS3iXRDBLSFv8mKjdn1jl77ASgvousBaw/MGtmxUA==",
"resolved": "https://registry.npm.taobao.org/music-metadata-browser/download/music-metadata-browser-1.3.0.tgz",
"integrity": "sha1-1wC+m7IL3C/AiMkvmh7EA/tT4bo=",
"requires": {
"assert": "^2.0.0",
"buffer": "^5.2.1",
@ -6854,8 +6854,8 @@
"dependencies": {
"assert": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/assert/-/assert-2.0.0.tgz",
"integrity": "sha512-se5Cd+js9dXJnu6Ag2JFc00t+HmHOen+8Q+L7O9zI0PqQXr20uk2J0XQqMxZEeo5U50o8Nvmmx7dZrl+Ufr35A==",
"resolved": "https://registry.npm.taobao.org/assert/download/assert-2.0.0.tgz",
"integrity": "sha1-lfwcYW1IcTUQaA8ury0Q3SLgLTI=",
"requires": {
"es6-object-assign": "^1.1.0",
"is-nan": "^1.2.1",
@ -6865,8 +6865,8 @@
},
"buffer": {
"version": "5.4.2",
"resolved": "https://registry.npmjs.org/buffer/-/buffer-5.4.2.tgz",
"integrity": "sha512-iy9koArjAFCzGnx3ZvNA6Z0clIbbFgbdWQ0mKD3hO0krOrZh8UgA6qMKcZvwLJxS+D6iVR76+5/pV56yMNYTag==",
"resolved": "https://registry.npm.taobao.org/buffer/download/buffer-5.4.2.tgz",
"integrity": "sha1-IBKHJ3YgYYJIDsyywPul9nKi7+8=",
"requires": {
"base64-js": "^1.0.2",
"ieee754": "^1.1.4"
@ -6874,8 +6874,8 @@
},
"readable-stream": {
"version": "3.4.0",
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.4.0.tgz",
"integrity": "sha512-jItXPLmrSR8jmTRmRWJXCnGJsfy85mB3Wd/uINMXA65yrnFo0cPClFIUWzo2najVNSl+mx7/4W8ttlLWJe99pQ==",
"resolved": "https://registry.npm.taobao.org/readable-stream/download/readable-stream-3.4.0.tgz",
"integrity": "sha1-pRwmdUZY4KPCHb9ZFjvUW6b0R/w=",
"requires": {
"inherits": "^2.0.3",
"string_decoder": "^1.1.1",
@ -6884,8 +6884,8 @@
},
"util": {
"version": "0.12.1",
"resolved": "https://registry.npmjs.org/util/-/util-0.12.1.tgz",
"integrity": "sha512-MREAtYOp+GTt9/+kwf00IYoHZyjM8VU4aVrkzUlejyqaIjd2GztVl5V9hGXKlvBKE3gENn/FMfHE5v6hElXGcQ==",
"resolved": "https://registry.npm.taobao.org/util/download/util-0.12.1.tgz",
"integrity": "sha1-+QjntjPnOWx2TmlN0U5xYlbOit4=",
"requires": {
"inherits": "^2.0.3",
"is-arguments": "^1.0.4",
@ -7135,7 +7135,7 @@
},
"object-is": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/object-is/-/object-is-1.0.1.tgz",
"resolved": "https://registry.npm.taobao.org/object-is/download/object-is-1.0.1.tgz",
"integrity": "sha1-CqYOyZiaCz7Xlc9NBvYs8a1lObY="
},
"object-keys": {
@ -7166,8 +7166,8 @@
},
"object.entries": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/object.entries/-/object.entries-1.1.0.tgz",
"integrity": "sha512-l+H6EQ8qzGRxbkHOd5I/aHRhHDKoQXQ8g0BYt4uSweQU1/J6dZUOyWh9a2Vky35YCKjzmgxOzta2hH6kf9HuXA==",
"resolved": "https://registry.npm.taobao.org/object.entries/download/object.entries-1.1.0.tgz",
"integrity": "sha1-ICT8bWuiRq7ji9sP/Vz7zzcbdRk=",
"requires": {
"define-properties": "^1.1.3",
"es-abstract": "^1.12.0",
@ -8400,8 +8400,8 @@
},
"readable-web-to-node-stream": {
"version": "1.1.4",
"resolved": "https://registry.npmjs.org/readable-web-to-node-stream/-/readable-web-to-node-stream-1.1.4.tgz",
"integrity": "sha512-DfwzynATtPmyLSMETPMlgVAB4b/0NNPePAEFEjSzw8VkqUZfx75gjNkaSqa0fP6iul2TL+jheLn2np0SWtW4iw=="
"resolved": "https://registry.npm.taobao.org/readable-web-to-node-stream/download/readable-web-to-node-stream-1.1.4.tgz",
"integrity": "sha1-WFfTL7n3kdHEyjwpf/AorLQSGMY="
},
"readdirp": {
"version": "2.2.1",
@ -8510,7 +8510,7 @@
},
"remove": {
"version": "0.1.5",
"resolved": "https://registry.npmjs.org/remove/-/remove-0.1.5.tgz",
"resolved": "https://registry.npm.taobao.org/remove/download/remove-0.1.5.tgz",
"integrity": "sha1-CV/9gn1lyfQa2X0z5BanWBEHmVU=",
"requires": {
"seq": ">= 0.3.5"
@ -8867,7 +8867,7 @@
},
"seq": {
"version": "0.3.5",
"resolved": "https://registry.npmjs.org/seq/-/seq-0.3.5.tgz",
"resolved": "https://registry.npm.taobao.org/seq/download/seq-0.3.5.tgz",
"integrity": "sha1-rgKvOkJHk9jMvyEtaRdODFTf/jg=",
"requires": {
"chainsaw": ">=0.0.7 <0.1",
@ -9577,8 +9577,8 @@
},
"strtok3": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/strtok3/-/strtok3-3.0.1.tgz",
"integrity": "sha512-1aRPsZAxNJ8xo0UPpJgI7VRLZsjal0lvjkF4kIvHL6u3RxHM+hbenfJA0hVmwoUcjbvHuo/HqeB+tTUYx2FciA==",
"resolved": "https://registry.npm.taobao.org/strtok3/download/strtok3-3.0.1.tgz",
"integrity": "sha1-Z7Z8MYtE+fv/l/2UAzaB7FAv36I=",
"requires": {
"debug": "^4.1.1",
"then-read-stream": "^2.0.6",
@ -9697,8 +9697,8 @@
},
"then-read-stream": {
"version": "2.0.6",
"resolved": "https://registry.npmjs.org/then-read-stream/-/then-read-stream-2.0.6.tgz",
"integrity": "sha512-5HA8j7O3NL6P4Pi0IzZx8/t46sK0+h3n+P/P0Yzi11ODwR+ZWjG+KILzLXPvJM7PvYjK7sDKfcN1YVCNGbPNEQ=="
"resolved": "https://registry.npm.taobao.org/then-read-stream/download/then-read-stream-2.0.6.tgz",
"integrity": "sha1-jY4rFltUocX4ZstD4hZMH1+bhaw="
},
"thenify": {
"version": "3.3.0",
@ -9827,8 +9827,8 @@
},
"token-types": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/token-types/-/token-types-1.0.3.tgz",
"integrity": "sha512-8THi5oekS/TLE01xOMknevTgHwVEcWOsO3zlqxGvzAz+tjZGiACyjcZuH1LTJuHvqmb8SsX/BeqcfQA0JRwqzA=="
"resolved": "https://registry.npm.taobao.org/token-types/download/token-types-1.0.3.tgz",
"integrity": "sha1-c3zAGTnSNXeuM5uI3oL6PLPQtzU="
},
"topo": {
"version": "2.0.2",
@ -9865,7 +9865,7 @@
},
"traverse": {
"version": "0.3.9",
"resolved": "https://registry.npmjs.org/traverse/-/traverse-0.3.9.tgz",
"resolved": "https://registry.npm.taobao.org/traverse/download/traverse-0.3.9.tgz",
"integrity": "sha1-cXuPIgzAu3tE5AUUwisui7xw2Lk="
},
"trim-right": {
@ -9931,8 +9931,8 @@
},
"typedarray-to-buffer": {
"version": "3.1.5",
"resolved": "https://registry.npmjs.org/typedarray-to-buffer/-/typedarray-to-buffer-3.1.5.tgz",
"integrity": "sha512-zdu8XMNEDepKKR+XYOXAVPtWui0ly0NtohUscw+UmaHiAWT8hrV1rr//H6V+0DvJ3OQ19S979M0laLfX8rm82Q==",
"resolved": "https://registry.npm.taobao.org/typedarray-to-buffer/download/typedarray-to-buffer-3.1.5.tgz?cache=0&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Ftypedarray-to-buffer%2Fdownload%2Ftypedarray-to-buffer-3.1.5.tgz",
"integrity": "sha1-qX7nqf9CaRufeD/xvFES/j/KkIA=",
"requires": {
"is-typedarray": "^1.0.0"
}

View File

@ -31,10 +31,10 @@ async function Decrypt(file) {
}
const mime = audio_mime_type[new_ext];
// 读取文件
const fileBuffer = await new Promise(() => {
const fileBuffer = await new Promise(resolve => {
const reader = new FileReader();
reader.onload = (e) => {
reslove(e.target.result);
resolve(e.target.result);
};
reader.readAsArrayBuffer(file);
});
@ -51,7 +51,7 @@ async function Decrypt(file) {
});
const musicUrl = URL.createObjectURL(musicData);
// 读取Meta
let tag = await musicMetadata.parseBlob(file);
let tag = await musicMetadata.parseBlob(musicData);
// 处理无标题歌手
let filename_array = file.name.substring(0, file.name.lastIndexOf(".")).split("-");
@ -66,6 +66,7 @@ async function Decrypt(file) {
const filename = artist + " - " + title + "." + new_ext;
// 处理无封面
let pic_url = "";
if (tag.common.picture !== undefined && tag.common.picture.length >= 1) {
const picture = tag.common.picture[0];
const blobPic = new Blob([picture.data], {type: picture.format});
@ -76,7 +77,7 @@ async function Decrypt(file) {
filename: filename,
title: title,
artist: artist,
album: tag.tags.album,
album: tag.common.album,
file: musicUrl,
picture: pic_url,
mime: mime

View File

@ -9,14 +9,13 @@ const audio_mime_type = {
async function Decrypt(file) {
let tag = await musicMetadata.parseBlob(file);
let pic_url = "";
if (tag.tags.picture !== undefined) {
let pic = new Blob([new Uint8Array(tag.tags.picture.data)], {type: tag.tags.picture.format});
if (tag.common.picture !== undefined && tag.common.picture.length > 0) {
let pic = new Blob([tag.common.picture[0].data], {type: tag.common.picture[0].format});
pic_url = URL.createObjectURL(pic);
}
let file_url = URL.createObjectURL(file);
let filename_no_ext = file.name.substring(0, file.name.lastIndexOf("."));
let filename_array = filename_no_ext.split("-");
let filename_ext = file.name.substring(file.name.lastIndexOf(".") + 1, file.name.length).toLowerCase();
@ -36,7 +35,7 @@ async function Decrypt(file) {
filename: filename,
title: title,
artist: artist,
album: tag.tags.album,
album: tag.common.album,
picture: pic_url,
file: file_url,
mime: mime