-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
gengark
committed
Dec 16, 2024
0 parents
commit 29f75b8
Showing
22 changed files
with
667 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Unix lines endings in bash script files | ||
*.sh text eol=lf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created | ||
# For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages | ||
|
||
name: release | ||
|
||
on: | ||
push: | ||
tags: | ||
- 'v*' | ||
- '!v*rc*' | ||
- '!v*beta*' | ||
- '!v*alpha*' | ||
|
||
jobs: | ||
publish-npm: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup Node.js | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: 18.18.0 | ||
registry-url: https://registry.npmjs.org/ | ||
|
||
- name: Install dependencies | ||
run: npm install | ||
|
||
- name: Run build | ||
run: npm run build | ||
|
||
- name: Prepare commit message | ||
uses: 'marvinpinto/action-automatic-releases@latest' | ||
with: | ||
repo_token: '${{ secrets.GITHUB_TOKEN }}' | ||
prerelease: false | ||
files: LICENSE | ||
|
||
- name: Publish dist to NPM | ||
run: npm publish --access public | ||
env: | ||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# Build | ||
dist/ | ||
|
||
# Cache | ||
.cache | ||
|
||
# Lock Files | ||
package-lock.json | ||
yarn.lock | ||
|
||
# VisualStudioCode template | ||
.vscode/* | ||
!.vscode/settings.json | ||
!.vscode/tasks.json | ||
!.vscode/launch.json | ||
!.vscode/extensions.json | ||
!.vscode/*.code-snippets | ||
|
||
# Local History for Visual Studio Code | ||
.history/ | ||
|
||
# IntelliJ project files | ||
.idea | ||
|
||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
lerna-debug.log* | ||
.pnpm-debug.log* | ||
|
||
# Dependency directories | ||
node_modules/ | ||
|
||
# Engineering directories | ||
# lib/ | ||
|
||
# Coverage directories | ||
coverage/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/bin/sh | ||
# .husky/pre-commit | ||
|
||
npm run lint-staged |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/bin/sh | ||
# .husky/pre-push | ||
|
||
# Detected changes in the src or bin directory, running checks... | ||
if git diff --cached --name-only | grep -Eq '^(src|bin)/'; then | ||
npm run build | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
"src/**/*.ts": | ||
- "biome check src bin --write" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2024 Zhang Zixin | ||
|
||
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
# 网易云音乐下载 | ||
|
||
一个简单的 Node.js CLI 库,用来下载网易云音乐源的 mp3 文件。 | ||
|
||
## 📦 安装 | ||
|
||
1. 确保安装过 Node 程序。 | ||
|
||
> 官方提供的简易安装包: [下载链接 (约 30 MB)][node-url] | ||
2. 打开任意终端(cmd/bash/powershell/...)安装当前包。 | ||
|
||
```bash | ||
npm i -g netease-cloud-music-download | ||
``` | ||
|
||
## ⚙️ 使用 | ||
|
||
- 使用 ID | ||
|
||
```bash | ||
netease-dl 25159744 | ||
``` | ||
|
||
``` | ||
下载进度 [========================================] 100% | 433467/433467 KB | ||
✔ 下载完成: C:\Users\User\Downloads\Hello Makka Pakka! - Andrew Davenport.mp3 | ||
``` | ||
- 使用分享链接 | ||
```bash | ||
netease-dl "https://music.xxx.com/song?id=25159744" | ||
``` | ||
|
||
``` | ||
下载进度 [========================================] 100% | 433467/433467 KB | ||
✔ 下载完成: C:\Users\User\Downloads\Hello Makka Pakka! - Andrew Davenport.mp3 | ||
``` | ||
|
||
- 使用剪贴板 | ||
|
||
```bash | ||
netease-dl | ||
``` | ||
|
||
``` | ||
下载进度 [========================================] 100% | 433467/433467 KB | ||
✔ 下载完成: C:\Users\User\Downloads\Hello Makka Pakka! - Andrew Davenport.mp3 | ||
``` | ||
|
||
- 指定下载目录 (`.`表示当前目录) | ||
|
||
```bash | ||
netease-dl -o . | ||
``` | ||
|
||
``` | ||
下载进度 [========================================] 100% | 433467/433467 KB | ||
✔ 下载完成: Hello Makka Pakka! - Andrew Davenport.mp3 | ||
``` | ||
|
||
- 当下载目录同名文件存在时,覆盖现有文件 | ||
|
||
```bash | ||
netease-dl -r | ||
``` | ||
|
||
``` | ||
下载进度 [========================================] 100% | 433467/433467 KB | ||
✔ 下载完成: C:\Users\User\Downloads\Hello Makka Pakka! - Andrew Davenport.mp3 | ||
``` | ||
|
||
## ❓ Q & A | ||
|
||
### \> 默认文件会下载到哪里 | ||
|
||
未指定 -o 参数时,默认下载到当前用户默认的 Downloads 文件夹,即浏览器下载文件目录。 | ||
|
||
### \> 文件命名规则是什么 | ||
|
||
单曲名 - 歌手名1\[, 歌手名2, ...\](若有多个).mp3 | ||
|
||
### \> 如何获取分享链接 | ||
|
||
在客户端中点击一首歌曲的分享按钮 > 点击复制链接。 | ||
|
||
或者直接复制单曲在浏览器中的链接。 | ||
|
||
## 🤝 贡献 | ||
|
||
欢迎通过 Pull Requests 或 [Issues][issues-url] 来贡献你的想法和代码。 | ||
|
||
## 📄 许可 | ||
|
||
本项目采用 MIT 许可证。详情请见 [LICENSE][license-url] 文件。 | ||
|
||
[node-url]: https://nodejs.org/zh-cn/download/prebuilt-installer | ||
|
||
[issues-url]: https://github.com/gengark/netease-cloud-music-download/issues | ||
|
||
[license-url]: LICENSE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#!/usr/bin/env node | ||
import { readFileSync } from 'node:fs'; | ||
import process from 'node:process'; | ||
import updateNotifier from 'update-notifier'; | ||
import yargs from 'yargs'; | ||
import { hideBin } from 'yargs/helpers'; | ||
import main from '../src'; | ||
|
||
process.on('SIGINT', () => { | ||
process.exit(0); | ||
}); | ||
|
||
const pkg = JSON.parse( | ||
readFileSync(new URL('../package.json', import.meta.url)).toString('utf8'), | ||
); | ||
|
||
updateNotifier({ pkg }).notify({ isGlobal: true }); | ||
|
||
|
||
const palette = (code: number) => (text: string) => | ||
`\u001B[${code}m${text}\u001B[39m`; | ||
const grey = palette(90); | ||
const yellow = palette(33); | ||
|
||
main( | ||
yargs(hideBin(process.argv)) | ||
.scriptName('netease-dl') | ||
.usage('$0 [options] <url>') | ||
.options('output', { | ||
alias: 'o', | ||
type: 'string', | ||
desc: '输出路径 (目录/文件名.mp3)', | ||
}) | ||
.options('rewrite', { | ||
alias: 'r', | ||
type: 'boolean', | ||
desc: '覆盖现有的同名文件 (若存在)', | ||
}) | ||
.example(yellow('netease-dl'), '使用剪贴板中的单曲ID / 链接') | ||
.example(yellow('netease-dl 25159744'), '指定单曲ID') | ||
.example(yellow('netease-dl "https://music.163.com/song?id=25159744"'), '指定单曲链接') | ||
.example(grey('-------'), '') | ||
.example(yellow('netease-dl'), '下载到当前用户默认的 Downloads 目录') | ||
.example(yellow('netease-dl -o .'), '下载到当前目录中') | ||
.alias({ | ||
v: 'version', | ||
h: 'help', | ||
}) | ||
.parseSync(), | ||
).catch(console.error); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
{ | ||
"$schema": "./node_modules/@biomejs/biome/configuration_schema.json", | ||
"vcs": { | ||
"enabled": false, | ||
"useIgnoreFile": false, | ||
"clientKind": "git", | ||
"defaultBranch": "master" | ||
}, | ||
"files": { | ||
"ignore": ["dist", "src/locale"], | ||
"ignoreUnknown": false | ||
}, | ||
"formatter": { | ||
"enabled": true, | ||
"indentWidth": 4, | ||
"indentStyle": "space", | ||
"lineWidth": 80, | ||
"lineEnding": "lf" | ||
}, | ||
"organizeImports": { | ||
"enabled": true | ||
}, | ||
"linter": { | ||
"enabled": true, | ||
"rules": { | ||
"recommended": true | ||
} | ||
}, | ||
"javascript": { | ||
"formatter": { | ||
"enabled": true, | ||
"indentWidth": 4, | ||
"indentStyle": "space", | ||
"lineWidth": 80, | ||
"lineEnding": "lf", | ||
"quoteStyle": "single", | ||
"jsxQuoteStyle": "double", | ||
"trailingCommas": "all", | ||
"semicolons": "always", | ||
"quoteProperties": "asNeeded", | ||
"arrowParentheses": "always" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
{ | ||
"name": "netease-cloud-music-download", | ||
"description": "A simple Node.js CLI library that helps you to download mp3 file for NetEase Cloud Music source", | ||
"version": "0.1.0", | ||
"type": "module", | ||
"main": "./dist/cli.js", | ||
"types": "./dist/cli.d.ts", | ||
"files": [ | ||
"dist" | ||
], | ||
"bin": { | ||
"netease-dl": "./dist/cli.js" | ||
}, | ||
"scripts": { | ||
"dev": "ts-node bin/cli.ts", | ||
"prepare": "husky", | ||
"lint": "biome check src bin --write", | ||
"lint-staged": "lint-staged", | ||
"build": "tsup", | ||
"watch": "tsup --watch" | ||
}, | ||
"author": { | ||
"name": "gengarr", | ||
"email": "97z4moon@gmail.com", | ||
"url": "https://github.com/gengark" | ||
}, | ||
"homepage": "https://github.com/gengark/netease-cloud-music-download#readme", | ||
"repository": "git@github.com:gengark/netease-cloud-music-download.git", | ||
"bugs": "https://github.com/gengark/netease-cloud-music-download/issue", | ||
"keywords": [ | ||
"netease", | ||
"music", | ||
"mp3", | ||
"download", | ||
"网易云音乐" | ||
], | ||
"engines": { | ||
"node": ">=18" | ||
}, | ||
"license": "MIT", | ||
"devDependencies": { | ||
"@biomejs/biome": "^1.9.4", | ||
"@types/cli-progress": "^3.11.6", | ||
"@types/node": "^22.10.2", | ||
"@types/update-notifier": "^6.0.8", | ||
"@types/yargs": "^17.0.33", | ||
"husky": "^9.1.7", | ||
"lint-staged": "^15.2.11", | ||
"ts-node": "^10.9.2", | ||
"tsup": "^8.3.5", | ||
"typescript": "^5.7.2" | ||
}, | ||
"dependencies": { | ||
"cli-progress": "^3.12.0", | ||
"clipboardy": "^4.0.0", | ||
"open": "^10.1.0", | ||
"ora": "^8.1.1", | ||
"update-notifier": "^7.3.1", | ||
"yargs": "^17.7.2" | ||
} | ||
} |
Oops, something went wrong.