diff --git a/package-lock.json b/package-lock.json index 01380b6..5b22a14 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4273,8 +4273,7 @@ "content-type": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.4.tgz", - "integrity": "sha512-hIP3EEPs8tB9AT1L+NUqtwOAps4mk2Zob89MWXMHjHWg9milF/j4osnnQLXBCBFBk/tvIG/tUc9mOUJiPBhPXA==", - "dev": true + "integrity": "sha512-hIP3EEPs8tB9AT1L+NUqtwOAps4mk2Zob89MWXMHjHWg9milF/j4osnnQLXBCBFBk/tvIG/tUc9mOUJiPBhPXA==" }, "convert-source-map": { "version": "1.7.0", @@ -8751,14 +8750,6 @@ "integrity": "sha512-OYu7XEzjkCQ3C5Ps3QIZsQfNpqoJyZZA99wd9aWd05NCtC5pWOkShK2mkL6HXQR6/Cy2lbNdPlZBpuQHXE63gA==", "dev": true }, - "jsmediatags": { - "version": "3.9.3", - "resolved": "https://registry.npmjs.org/jsmediatags/-/jsmediatags-3.9.3.tgz", - "integrity": "sha512-h53yFnPYF1Y5jwr2ebcVzIIsvRpSalm0jhNiJDUztoPPHGpuHxi9YHUzdDgiw+ykiinXHd1s6HSIbudHw79zQw==", - "requires": { - "xhr2": "^0.1.4" - } - }, "json-buffer": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/json-buffer/-/json-buffer-3.0.0.tgz", @@ -9659,6 +9650,44 @@ "integrity": "sha1-iZ8R2WhuXgXLkbNdXw5jt3PPyQE=", "dev": true }, + "music-metadata": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/music-metadata/-/music-metadata-5.1.1.tgz", + "integrity": "sha512-UWXFEzQpgLdXnqtP81YgDawVq71kKYjeujYgtir/RRlTs/HrkA5H8Ql96wnv9XwwcZ+GsOS9lxYEPlhOiSvXFw==", + "requires": { + "content-type": "^1.0.4", + "debug": "^4.1.0", + "file-type": "^12.4.0", + "media-typer": "^1.1.0", + "strtok3": "^3.1.0", + "token-types": "^1.1.0" + }, + "dependencies": { + "debug": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", + "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", + "requires": { + "ms": "^2.1.1" + } + }, + "file-type": { + "version": "12.4.0", + "resolved": "https://registry.npmjs.org/file-type/-/file-type-12.4.0.tgz", + "integrity": "sha512-WTvyKq8yjtNmUtVAD8LGcTkvtCdJglM6ks2HTqEClm6+65XTqM6MoZYA1Vtra50DLRWLiM38fEs1y56f5VhnUA==" + }, + "media-typer": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-1.1.0.tgz", + "integrity": "sha512-aisnrDP4GNe06UcKFnV5bfMNPBUw4jsLGaWwWfnH3v02GnBuXX2MCVn5RbrWo0j3pczUilYblq7fQ7Nw2t5XKw==" + }, + "ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" + } + } + }, "mute-stream": { "version": "0.0.8", "resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.8.tgz", @@ -13048,6 +13077,31 @@ "integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo=", "dev": true }, + "strtok3": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/strtok3/-/strtok3-3.1.3.tgz", + "integrity": "sha512-dAM88/m2qkcWHe5/5v/0zF5O9lhza4SpQPdMbvWA2T+GN+WbiGHuUAt9mUdN8yJ5TeOyyxGejrr+D+keA28n7Q==", + "requires": { + "debug": "^4.1.1", + "then-read-stream": "^2.0.8", + "token-types": "^1.1.0" + }, + "dependencies": { + "debug": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", + "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", + "requires": { + "ms": "^2.1.1" + } + }, + "ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" + } + } + }, "stylehacks": { "version": "4.0.3", "resolved": "https://registry.npmjs.org/stylehacks/-/stylehacks-4.0.3.tgz", @@ -13473,6 +13527,11 @@ "integrity": "sha1-f17oI66AUgfACvLfSoTsP8+lcLQ=", "dev": true }, + "then-read-stream": { + "version": "2.0.8", + "resolved": "https://registry.npmjs.org/then-read-stream/-/then-read-stream-2.0.8.tgz", + "integrity": "sha512-OIQn3/zF2J/gp6mAQTbBb1AR+3yoSRqjaij0gGnEUcTl93T840mWIZ9sJWwubjwP7VUDwJpT+Tdl7T9RrQmMlw==" + }, "thenify": { "version": "3.3.0", "resolved": "https://registry.npmjs.org/thenify/-/thenify-3.3.0.tgz", @@ -13668,6 +13727,11 @@ "integrity": "sha512-yaOH/Pk/VEhBWWTlhI+qXxDFXlejDGcQipMlyxda9nthulaxLZUNcUqFxokp0vcYnvteJln5FNQDRrxj3YcbVw==", "dev": true }, + "token-types": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/token-types/-/token-types-1.1.0.tgz", + "integrity": "sha512-CgM5GmtJaZ+uTOiZHzs9pwUa/udjEVl/cxQ2KGpl88Hh7k71sdBz9j95dYjx83O68B6CGvefm29l4rBZq1PeuQ==" + }, "toposort": { "version": "1.0.7", "resolved": "https://registry.npmjs.org/toposort/-/toposort-1.0.7.tgz", @@ -15186,11 +15250,6 @@ "xtend": "^4.0.0" } }, - "xhr2": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/xhr2/-/xhr2-0.1.4.tgz", - "integrity": "sha1-f4dliEdxbbUCYyOBL4GMras4el8=" - }, "xml-parse-from-string": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/xml-parse-from-string/-/xml-parse-from-string-1.0.1.tgz", diff --git a/package.json b/package.json index 640c53f..52c4f78 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,7 @@ "electron-updater": "^4.2.0", "element-ui": "^2.10.1", "iview": "3.3.0", - "jsmediatags": "^3.9.3", + "music-metadata": "^5.1.1", "vue": "^2.6.10", "vue-lazyload": "^1.3.3", "vue-router": "^3.0.3", diff --git a/src/tools/index.js b/src/tools/index.js index fd19820..65287c0 100644 --- a/src/tools/index.js +++ b/src/tools/index.js @@ -218,7 +218,7 @@ Vue.component('BackToTop', BackToTop); Vue.component('ButtonArea', ButtonArea); Vue.component('CountTag', CountTag); /*音乐*/ -const jsmediatags = require('jsmediatags'); +const musicMetadata = require('music-metadata'); import Api from './api/index'; Vue.api = Vue.prototype.$Api = Api; //请求接口 Vue.defaultAlbum = Vue.prototype.$defaultAlbum = 'http://p1.music.126.net/oCnACmhB6CM5oZyWmNfmTg==/109951163051142326.jpg'; @@ -238,14 +238,11 @@ Vue.getMusicInfo = Vue.prototype.$getMusicInfo = (file, cb) => { if (path.extname(name).Exist('flac')) { return cb(getMusicInfoCallback(file, { tags: {} })); } - jsmediatags.read('file://' + file, { - onSuccess: function(tag) { - cb(getMusicInfoCallback(file, tag)); - }, - onError: function() { - cb(getMusicInfoCallback(file, { tags: {} })); - } - }); + musicMetadata.parseFile(file).then(metadata => { + cb(getMusicInfoCallback(file, {tags: metadata.common})); + }, () => { + cb(getMusicInfoCallback(file, { tags: {} })); // error + }); }; //音乐解析 Vue.handleListData = Vue.prototype.$handleListData = (data, parent, flag) => { if (flag) { @@ -259,10 +256,6 @@ Vue.handleListData = Vue.prototype.$handleListData = (data, parent, flag) => { let artist = item.artists ? item.artists : item.ar; let album = item.album ? item.album : item.al; let time = item.duration || (item.mMusic ? item.mMusic.playTime : 0) || item.dt; - let artist_text = ''; - artist.forEach((item, index) => { - artist_text = artist_text + item.name + (index !== artist.length - 1 ? '/' : ''); - }); list = { id: item.id, playList: parent, @@ -274,7 +267,7 @@ Vue.handleListData = Vue.prototype.$handleListData = (data, parent, flag) => { type: 'online', title: item.name, name: item.name, - artist: artist_text, + artist: item.artist, album: album.name, time: time, mvid: item.mvid || item.mv,