diff --git a/.gitignore b/.gitignore index 3736680..14d58cf 100644 --- a/.gitignore +++ b/.gitignore @@ -24,3 +24,6 @@ pnpm-debug.log* *.sw? .vercel +NeteaseCloudMusicApi-master +NeteaseCloudMusicApi-master.zip +NeteaseCloudMusicApi-master1.zip diff --git a/LICENSE b/LICENSE deleted file mode 100644 index d8911ac..0000000 --- a/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2020 qier222 - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. \ No newline at end of file diff --git a/package.json b/package.json index 2a6b6cb..91c6039 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,11 @@ "serve": "vue-cli-service serve", "build": "vue-cli-service build", "lint": "vue-cli-service lint", - "prettier": "npx prettier --write ./src" + "prettier": "npx prettier --write ./src", + "napi_run": "cd ./NeteaseCloudMusicApi-master && npm run start", + "napi_pull": "node script/setup.js v3.45.1", + "napi_install": "cd ./NeteaseCloudMusicApi-master && npm install", + "setup": "npm run napi_pull && npm run napi_install" }, "husky": { "hooks": { @@ -21,6 +25,7 @@ "core-js": "^3.6.5", "crypto-js": "^4.0.0", "dayjs": "^1.8.36", + "extract-zip": "^2.0.1", "howler": "^2.2.0", "js-cookie": "^2.2.1", "nprogress": "^0.2.0", diff --git a/script/setup.js b/script/setup.js new file mode 100644 index 0000000..0b374a3 --- /dev/null +++ b/script/setup.js @@ -0,0 +1,103 @@ +// node module +const fs = require("fs"); +const https = require("https"); +const resolve = require("path").resolve; +const join = require("path").resolve; +const extract = require("extract-zip"); + +// 函数参数 +const dest = resolve(__dirname, "../"); +const fileName = "NeteaseCloudMusicApi-master.zip"; +const options = { + hostname: "github.91chifun.workers.dev", + path: `//https://github.com/Binaryify/NeteaseCloudMusicApi/archive/master.zip`, +}; + +// 完整的流程控制 +/** + * 1. 检查本地文件是否已有 + * 2. 下载默认/指定版本的 zip 压缩包,等待下载 + * 3. 解压缩 + * 4. 进入目录安装依赖 npm install + */ + +function fix2(number) { + return number.toFixed(2); +} + +async function download(options, fileName, callback) { + return await new Promise((resolve, reject) => { + const destPath = join(__dirname, "../" + fileName); + // Check if exist + if (fs.existsSync(destPath)) return resolve(destPath); + + const file = fs.createWriteStream(destPath); + const request = https.get(options, (res) => { + let len = res.headers && parseInt(res.headers["content-length"], 10); + console.log(); + if (len) { + console.log(); + } + let cur = 0; + // 1048576 - bytes in 1Megabyte + const MEGA = 1048576; + let total = 0; + if (len) { + total = len / MEGA; + } + if (!len) { + console.log( + "Downloading, but can not get content-length, please be patient." + ); + } + res.on("data", (chunk) => { + if (len) { + cur += chunk.length; + console.log(`Downloading ${fix2((100.0 * cur) / len)}% ${fix2(cur / MEGA)}/${fix2(total)}mb`); + } + }); + res.on("end", () => { + callback("Downloading complete!"); + }); + res.pipe(file); + file.on("finish", () => { + file.close(() => { + callback("File wrote complete!"); + resolve(destPath); + }); + }); + file.on("error", (err) => { + fs.unlink(destPath); + reject(err); + }); + request.on("error", (err) => { + console.log("Error: " + err.message); + }); + }); + }); +} + +async function unzip(source, target) { + try { + await extract(source, { + dir: target, + }); + console.log("Extraction complete"); + return true; + } catch (err) { + // handle any errors + if (err.message === "end of central directory record signature not found") { + console.log("Not a full_downloaded zip file, removed!"); + fs.unlinkSync(source); + } + return false; + } +} +// Download process +download(options, fileName, (text) => { + console.log(text); +}).then((path) => { + console.log(path) + // Unzip process + return unzip(path, dest); +}); diff --git a/yarn.lock b/yarn.lock index 5fe41a9..ca15c6c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -915,6 +915,103 @@ resolved "https://registry.npm.taobao.org/@nodelib/fs.stat/download/@nodelib/fs.stat-1.1.3.tgz#2b5a3ab3f918cca48a8c754c08168e3f03eba61b" integrity sha1-K1o6s/kYzKSKjHVMCBaOPwPrphs= +"@octokit/auth-token@^2.4.0": + version "2.4.2" + resolved "https://registry.npm.taobao.org/@octokit/auth-token/download/@octokit/auth-token-2.4.2.tgz#10d0ae979b100fa6b72fa0e8e63e27e6d0dbff8a" + integrity sha1-ENCul5sQD6a3L6Do5j4n5tDb/4o= + dependencies: + "@octokit/types" "^5.0.0" + +"@octokit/core@^3.0.0", "@octokit/core@^3.1.4": + version "3.1.4" + resolved "https://registry.npm.taobao.org/@octokit/core/download/@octokit/core-3.1.4.tgz#9c51a3d77bad7d8aa5ec0e997ee90da224206b5e" + integrity sha1-nFGj13utfYql7A6ZfukNoiQga14= + dependencies: + "@octokit/auth-token" "^2.4.0" + "@octokit/graphql" "^4.3.1" + "@octokit/request" "^5.4.0" + "@octokit/types" "^5.0.0" + before-after-hook "^2.1.0" + universal-user-agent "^6.0.0" + +"@octokit/endpoint@^6.0.1": + version "6.0.8" + resolved "https://registry.npm.taobao.org/@octokit/endpoint/download/@octokit/endpoint-6.0.8.tgz#91b07e236fdb69929c678c6439f7a560dc6058ac" + integrity sha1-kbB+I2/baZKcZ4xkOfelYNxgWKw= + dependencies: + "@octokit/types" "^5.0.0" + is-plain-object "^5.0.0" + universal-user-agent "^6.0.0" + +"@octokit/graphql@^4.3.1": + version "4.5.6" + resolved "https://registry.npm.taobao.org/@octokit/graphql/download/@octokit/graphql-4.5.6.tgz#708143ba15cf7c1879ed6188266e7f270be805d4" + integrity sha1-cIFDuhXPfBh57WGIJm5/JwvoBdQ= + dependencies: + "@octokit/request" "^5.3.0" + "@octokit/types" "^5.0.0" + universal-user-agent "^6.0.0" + +"@octokit/plugin-paginate-rest@^2.2.0": + version "2.4.0" + resolved "https://registry.npm.taobao.org/@octokit/plugin-paginate-rest/download/@octokit/plugin-paginate-rest-2.4.0.tgz#92f951ddc8a1cd505353fa07650752ca25ed7e93" + integrity sha1-kvlR3cihzVBTU/oHZQdSyiXtfpM= + dependencies: + "@octokit/types" "^5.5.0" + +"@octokit/plugin-request-log@^1.0.0": + version "1.0.2" + resolved "https://registry.npm.taobao.org/@octokit/plugin-request-log/download/@octokit/plugin-request-log-1.0.2.tgz?cache=0&sync_timestamp=1603481907939&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2F%40octokit%2Fplugin-request-log%2Fdownload%2F%40octokit%2Fplugin-request-log-1.0.2.tgz#394d59ec734cd2f122431fbaf05099861ece3c44" + integrity sha1-OU1Z7HNM0vEiQx+68FCZhh7OPEQ= + +"@octokit/plugin-rest-endpoint-methods@4.2.0": + version "4.2.0" + resolved "https://registry.npm.taobao.org/@octokit/plugin-rest-endpoint-methods/download/@octokit/plugin-rest-endpoint-methods-4.2.0.tgz#c5a0691b3aba5d8b4ef5dffd6af3649608f167ba" + integrity sha1-xaBpGzq6XYtO9d/9avNklgjxZ7o= + dependencies: + "@octokit/types" "^5.5.0" + deprecation "^2.3.1" + +"@octokit/request-error@^2.0.0": + version "2.0.2" + resolved "https://registry.npm.taobao.org/@octokit/request-error/download/@octokit/request-error-2.0.2.tgz#0e76b83f5d8fdda1db99027ea5f617c2e6ba9ed0" + integrity sha1-Dna4P12P3aHbmQJ+pfYXwua6ntA= + dependencies: + "@octokit/types" "^5.0.1" + deprecation "^2.0.0" + once "^1.4.0" + +"@octokit/request@^5.3.0", "@octokit/request@^5.4.0": + version "5.4.9" + resolved "https://registry.npm.taobao.org/@octokit/request/download/@octokit/request-5.4.9.tgz?cache=0&sync_timestamp=1600012764030&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2F%40octokit%2Frequest%2Fdownload%2F%40octokit%2Frequest-5.4.9.tgz#0a46f11b82351b3416d3157261ad9b1558c43365" + integrity sha1-CkbxG4I1GzQW0xVyYa2bFVjEM2U= + dependencies: + "@octokit/endpoint" "^6.0.1" + "@octokit/request-error" "^2.0.0" + "@octokit/types" "^5.0.0" + deprecation "^2.0.0" + is-plain-object "^5.0.0" + node-fetch "^2.6.1" + once "^1.4.0" + universal-user-agent "^6.0.0" + +"@octokit/rest@^18.0.6": + version "18.0.6" + resolved "https://registry.npm.taobao.org/@octokit/rest/download/@octokit/rest-18.0.6.tgz?cache=0&sync_timestamp=1600063003790&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2F%40octokit%2Frest%2Fdownload%2F%40octokit%2Frest-18.0.6.tgz#76c274f1a68f40741a131768ef483f041e7b98b6" + integrity sha1-dsJ08aaPQHQaExdo70g/BB57mLY= + dependencies: + "@octokit/core" "^3.0.0" + "@octokit/plugin-paginate-rest" "^2.2.0" + "@octokit/plugin-request-log" "^1.0.0" + "@octokit/plugin-rest-endpoint-methods" "4.2.0" + +"@octokit/types@^5.0.0", "@octokit/types@^5.0.1", "@octokit/types@^5.5.0": + version "5.5.0" + resolved "https://registry.npm.taobao.org/@octokit/types/download/@octokit/types-5.5.0.tgz#e5f06e8db21246ca102aa28444cdb13ae17a139b" + integrity sha1-5fBujbISRsoQKqKERM2xOuF6E5s= + dependencies: + "@types/node" ">= 8" + "@sentry/browser@^5.27.0": version "5.27.0" resolved "https://registry.yarnpkg.com/@sentry/browser/-/browser-5.27.0.tgz#35b77f076fb5f08c91eff23f3c067ee15df0ab90" @@ -1110,6 +1207,11 @@ resolved "https://registry.npm.taobao.org/@types/node/download/@types/node-14.11.2.tgz?cache=0&sync_timestamp=1600732787803&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2F%40types%2Fnode%2Fdownload%2F%40types%2Fnode-14.11.2.tgz#2de1ed6670439387da1c9f549a2ade2b0a799256" integrity sha1-LeHtZnBDk4faHJ9UmireKwp5klY= +"@types/node@>= 8": + version "14.14.3" + resolved "https://registry.npm.taobao.org/@types/node/download/@types/node-14.14.3.tgz#e1c09064121f894baaad2bd9f12ce4a41bffb274" + integrity sha1-4cCQZBIfiUuqrSvZ8SzkpBv/snQ= + "@types/normalize-package-data@^2.4.0": version "2.4.0" resolved "https://registry.npm.taobao.org/@types/normalize-package-data/download/@types/normalize-package-data-2.4.0.tgz?cache=0&sync_timestamp=1596839391651&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2F%40types%2Fnormalize-package-data%2Fdownload%2F%40types%2Fnormalize-package-data-2.4.0.tgz#e486d0d97396d79beedd0a6e33f4534ff6b4973e" @@ -1192,6 +1294,13 @@ "@types/webpack-sources" "*" source-map "^0.6.0" +"@types/yauzl@^2.9.1": + version "2.9.1" + resolved "https://registry.npm.taobao.org/@types/yauzl/download/@types/yauzl-2.9.1.tgz?cache=0&sync_timestamp=1596841684525&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2F%40types%2Fyauzl%2Fdownload%2F%40types%2Fyauzl-2.9.1.tgz#d10f69f9f522eef3cf98e30afb684a1e1ec923af" + integrity sha1-0Q9p+fUi7vPPmOMK+2hKHh7JI68= + dependencies: + "@types/node" "*" + "@vue/babel-helper-vue-jsx-merge-props@^1.0.0": version "1.0.0" resolved "https://registry.npm.taobao.org/@vue/babel-helper-vue-jsx-merge-props/download/@vue/babel-helper-vue-jsx-merge-props-1.0.0.tgz?cache=0&sync_timestamp=1596768129236&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2F%40vue%2Fbabel-helper-vue-jsx-merge-props%2Fdownload%2F%40vue%2Fbabel-helper-vue-jsx-merge-props-1.0.0.tgz#048fe579958da408fb7a8b2a3ec050b50a661040" @@ -2008,6 +2117,11 @@ bcrypt-pbkdf@^1.0.0: dependencies: tweetnacl "^0.14.3" +before-after-hook@^2.1.0: + version "2.1.0" + resolved "https://registry.npm.taobao.org/before-after-hook/download/before-after-hook-2.1.0.tgz#b6c03487f44e24200dd30ca5e6a1979c5d2fb635" + integrity sha1-tsA0h/ROJCAN0wyl5qGXnF0vtjU= + bfj@^6.1.1: version "6.1.2" resolved "https://registry.npm.taobao.org/bfj/download/bfj-6.1.2.tgz#325c861a822bcb358a41c78a33b8e6e2086dde7f" @@ -2200,6 +2314,11 @@ browserslist@^4.0.0, browserslist@^4.12.0, browserslist@^4.8.5: escalade "^3.1.0" node-releases "^1.1.61" +buffer-crc32@~0.2.3: + version "0.2.13" + resolved "https://registry.npm.taobao.org/buffer-crc32/download/buffer-crc32-0.2.13.tgz#0d333e3f00eac50aa1454abd30ef8c2a5d9a7242" + integrity sha1-DTM+PwDqxQqhRUq9MO+MKl2ackI= + buffer-from@^1.0.0: version "1.1.1" resolved "https://registry.npm.taobao.org/buffer-from/download/buffer-from-1.1.1.tgz#32713bc028f75c02fdb710d7c7bcec1f2c6070ef" @@ -3266,6 +3385,11 @@ depd@~1.1.2: resolved "https://registry.npm.taobao.org/depd/download/depd-1.1.2.tgz#9bcd52e14c097763e749b274c4346ed2e560b5a9" integrity sha1-m81S4UwJd2PnSbJ0xDRu0uVgtak= +deprecation@^2.0.0, deprecation@^2.3.1: + version "2.3.1" + resolved "https://registry.npm.taobao.org/deprecation/download/deprecation-2.3.1.tgz#6368cbdb40abf3373b525ac87e4a260c3a700919" + integrity sha1-Y2jL20Cr8zc7UlrIfkomDDpwCRk= + des.js@^1.0.0: version "1.0.1" resolved "https://registry.npm.taobao.org/des.js/download/des.js-1.0.1.tgz#5382142e1bdc53f85d86d53e5f4aa7deb91e0843" @@ -3892,6 +4016,17 @@ extglob@^2.0.2, extglob@^2.0.4: snapdragon "^0.8.1" to-regex "^3.0.1" +extract-zip@^2.0.1: + version "2.0.1" + resolved "https://registry.npm.taobao.org/extract-zip/download/extract-zip-2.0.1.tgz?cache=0&sync_timestamp=1591773082587&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fextract-zip%2Fdownload%2Fextract-zip-2.0.1.tgz#663dca56fe46df890d5f131ef4a06d22bb8ba13a" + integrity sha1-Zj3KVv5G34kNXxMe9KBtIruLoTo= + dependencies: + debug "^4.1.1" + get-stream "^5.1.0" + yauzl "^2.10.0" + optionalDependencies: + "@types/yauzl" "^2.9.1" + extsprintf@1.3.0: version "1.3.0" resolved "https://registry.npm.taobao.org/extsprintf/download/extsprintf-1.3.0.tgz#96918440e3041a7a414f8c52e3c574eb3c3e1e05" @@ -3943,6 +4078,13 @@ faye-websocket@~0.11.1: dependencies: websocket-driver ">=0.5.1" +fd-slicer@~1.1.0: + version "1.1.0" + resolved "https://registry.npm.taobao.org/fd-slicer/download/fd-slicer-1.1.0.tgz#25c7c89cb1f9077f8891bbe61d8f390eae256f1e" + integrity sha1-JcfInLH5B3+IkbvmHY85Dq4lbx4= + dependencies: + pend "~1.2.0" + figgy-pudding@^3.5.1: version "3.5.2" resolved "https://registry.npm.taobao.org/figgy-pudding/download/figgy-pudding-3.5.2.tgz#b4eee8148abb01dcf1d1ac34367d59e12fa61d6e" @@ -4228,7 +4370,7 @@ get-stream@^4.0.0: dependencies: pump "^3.0.0" -get-stream@^5.0.0: +get-stream@^5.0.0, get-stream@^5.1.0: version "5.2.0" resolved "https://registry.npm.taobao.org/get-stream/download/get-stream-5.2.0.tgz?cache=0&sync_timestamp=1597056502934&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fget-stream%2Fdownload%2Fget-stream-5.2.0.tgz#4966a1795ee5ace65e706c4b7beb71257d6e22d3" integrity sha1-SWaheV7lrOZecGxLe+txJX1uItM= @@ -5066,6 +5208,11 @@ is-plain-object@^2.0.3, is-plain-object@^2.0.4: dependencies: isobject "^3.0.1" +is-plain-object@^5.0.0: + version "5.0.0" + resolved "https://registry.npm.taobao.org/is-plain-object/download/is-plain-object-5.0.0.tgz#4427f50ab3429e9025ea7d52e9043a9ef4159344" + integrity sha1-RCf1CrNCnpAl6n1S6QQ6nvQVk0Q= + is-regex@^1.0.4, is-regex@^1.1.0, is-regex@^1.1.1: version "1.1.1" resolved "https://registry.npm.taobao.org/is-regex/download/is-regex-1.1.1.tgz?cache=0&sync_timestamp=1596555640677&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fis-regex%2Fdownload%2Fis-regex-1.1.1.tgz#c6f98aacc546f6cec5468a07b7b153ab564a57b9" @@ -5923,6 +6070,11 @@ no-case@^2.2.0: dependencies: lower-case "^1.1.1" +node-fetch@^2.6.1: + version "2.6.1" + resolved "https://registry.npm.taobao.org/node-fetch/download/node-fetch-2.6.1.tgz?cache=0&sync_timestamp=1599309179354&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fnode-fetch%2Fdownload%2Fnode-fetch-2.6.1.tgz#045bd323631f76ed2e2b55573394416b639a0052" + integrity sha1-BFvTI2Mfdu0uK1VXM5RBa2OaAFI= + node-forge@^0.10.0: version "0.10.0" resolved "https://registry.npm.taobao.org/node-forge/download/node-forge-0.10.0.tgz?cache=0&sync_timestamp=1599010773454&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fnode-forge%2Fdownload%2Fnode-forge-0.10.0.tgz#32dea2afb3e9926f02ee5ce8794902691a676bf3" @@ -6450,6 +6602,11 @@ pbkdf2@^3.0.3: safe-buffer "^5.0.1" sha.js "^2.4.8" +pend@~1.2.0: + version "1.2.0" + resolved "https://registry.npm.taobao.org/pend/download/pend-1.2.0.tgz#7a57eb550a6783f9115331fcf4663d5c8e007a50" + integrity sha1-elfrVQpng/kRUzH89GY9XI4AelA= + performance-now@^2.1.0: version "2.1.0" resolved "https://registry.npm.taobao.org/performance-now/download/performance-now-2.1.0.tgz#6309f4e0e5fa913ec1c69307ae364b4b377c9e7b" @@ -6981,7 +7138,7 @@ process@^0.11.10: resolved "https://registry.npm.taobao.org/process/download/process-0.11.10.tgz#7332300e840161bda3e69a1d1d91a7d4bc16f182" integrity sha1-czIwDoQBYb2j5podHZGn1LwW8YI= -progress@^2.0.0: +progress@^2.0.0, progress@^2.0.3: version "2.0.3" resolved "https://registry.npm.taobao.org/progress/download/progress-2.0.3.tgz#7e8cf8d8f5b8f239c1bc68beb4eb78567d572ef8" integrity sha1-foz42PW48jnBvGi+tOt4Vn1XLvg= @@ -8510,6 +8667,11 @@ unique-slug@^2.0.0: dependencies: imurmurhash "^0.1.4" +universal-user-agent@^6.0.0: + version "6.0.0" + resolved "https://registry.npm.taobao.org/universal-user-agent/download/universal-user-agent-6.0.0.tgz#3381f8503b251c0d9cd21bc1de939ec9df5480ee" + integrity sha1-M4H4UDslHA2c0hvB3pOeyd9UgO4= + universalify@^0.1.0: version "0.1.2" resolved "https://registry.npm.taobao.org/universalify/download/universalify-0.1.2.tgz#b646f69be3942dabcecc9d6639c80dc105efaa66" @@ -9266,6 +9428,14 @@ yargs@^15.0.0: y18n "^4.0.0" yargs-parser "^18.1.2" +yauzl@^2.10.0: + version "2.10.0" + resolved "https://registry.npm.taobao.org/yauzl/download/yauzl-2.10.0.tgz#c7eb17c93e112cb1086fa6d8e51fb0667b79a5f9" + integrity sha1-x+sXyT4RLLEIb6bY5R+wZnt5pfk= + dependencies: + buffer-crc32 "~0.2.3" + fd-slicer "~1.1.0" + yorkie@^2.0.0: version "2.0.0" resolved "https://registry.npm.taobao.org/yorkie/download/yorkie-2.0.0.tgz#92411912d435214e12c51c2ae1093e54b6bb83d9"