Giter Site home page Giter Site logo

zonemeen / musicn Goto Github PK

View Code? Open in Web Editor NEW
1.6K 11.0 149.0 1.02 MB

🎵 一个可播放及下载音乐的 Node.js 命令行工具

License: MIT License

JavaScript 27.54% Shell 0.10% TypeScript 58.64% CSS 1.69% HTML 12.03%
nodejs cli command-line command-line-tool music music-download free free-download music-downloader cli-tools

musicn's Introduction

Musicn

🎵 一个可播放及下载音乐的 Node.js 命令行工具

全局安装

$ npm i musicn -g
# or
$ yarn global add musicn

容器形式部署安装可以参考:musicn-container

使用

$ musicn 周杰伦
# or
$ msc 周杰伦

帮助信息:

$ msc --help
# or
$ msc -h

开启本地播放链接(手机可扫描二维码)下载及播放:

$ msc --qrcode
# or
$ msc -q
# or
$ msc -q -P 3000 # 指定端口,-P为大写

注意:使用手机扫描二维码时,电脑和手机两个设备必须连接到同一个 Wi-Fi;强烈推荐这种方式,既能听歌又能下载歌曲

也可以部署到自己的服务器,具体方法如下:

git clone https://github.com/zonemeen/musicn.git
cd musicn
npm install
npm run build
node ./bin/cli.js -q
# or
pm2 start ./bin/cli.js --name music-app -- -q

开启本地播放链接是否自动打开浏览器:

$ msc -q --open
# or
$ msc -q -o

搜索的页码数(默认是第1页):

$ msc 周杰伦 --number 2
# or
$ msc 周杰伦 -n 2
# or
$ msc -n 2 周杰伦

搜索的歌曲数量(默认是20条):

$ msc 周杰伦 --size 10 -w # wangyi的服务
# or
$ msc 周杰伦 -s 10 -w
# or
$ msc -s 10 -w 周杰伦

注意:咪咕正常搜索因为api不支持,搜索时的自定义歌曲数量是无效的

咪咕服务下载(默认是这个服务):

$ msc 周杰伦

网易云服务下载:

$ msc 周杰伦 --wangyi
# or
$ msc 周杰伦 -w
# or
$ msc -w 周杰伦

酷狗服务下载:

$ msc 周杰伦 --kugou
# or
$ msc 周杰伦 -g
# or
$ msc -g 周杰伦

根据歌单id下载:

$ msc --songListId 206140403
# or
$ msc -i 206140403
# or
$ msc -i 206140403 -n 2

自定义下载路径(默认是当前路径):

$ msc 周杰伦 --path ../music
# or
$ msc 周杰伦 -p ../music
# or
$ msc -p ../music 周杰伦

开启本地播放链接时附带此参数,可通过 web 页面下载音乐至服务器对应 path

自定义base URL(默认为空):

$ msc 周杰伦 -q --base musicn
# or
$ msc 周杰伦 -q -b musicn

注意:只应用在开启本地播放链接时且首尾不能是 /,最终呈现的 URL http://192.168.0.204:7478/musicn

附带歌词下载(默认是不附带):

$ msc 周杰伦 --lyric
# or
$ msc 周杰伦 -l
# or
$ msc -l 周杰伦

开启本地播放链接时附带此参数,可通过 web 页面下载歌词至服务器对应 path(需结合 path 使用)

版本信息:

$ msc --version
# or
$ msc -v

资源

  • 音乐来源: 咪咕、酷狗和网易云(API 是从公开的网络中获得)

说明

  1. 暂时只支持咪咕、酷狗和网易云的服务(因一些特殊原因,其余平台暂时是不支持的,所有服务暂时也只支持普通mp3格式的下载及播放,且部分服务的会员专属歌曲下载暂时也不支持,后期会继续探索其余平台可用的音乐下载)
  2. windows 桌面端的 git Bash 中不支持上下切换选歌,问题是 inquirer 不兼容,建议使用其它终端工具
  3. node version > 16
  4. 此项目仅供个人学习研究,严禁用于商业用途

musicn's People

Contributors

markthree avatar renovate[bot] avatar zonemeen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

musicn's Issues

SyntaxError: Unexpected token

➜ Downloads msc 稻香
/usr/local/lib/node_modules/musicn/lib/search.js:12
const songs = JSON.parse(body).songResultData?.result
^

SyntaxError: Unexpected token .
at Module._compile (internal/modules/cjs/loader.js:723:23)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Module.require (internal/modules/cjs/loader.js:692:17)
at require (internal/modules/cjs/helpers.js:25:18)
at Object. (/usr/local/lib/node_modules/musicn/lib/index.js:3:16)
at Module._compile (internal/modules/cjs/loader.js:778:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)

连接不上

image
这个报错好几天了,是因为不在大陆吗?
msc -V
1.4.3
node -v
v16.16.0

运行报错

 msc --version

/Users/momo/.nvm/versions/node/v11.12.0/lib/node_modules/musicn/bin/cli.js:3
import cli from '../dist/index.js'
       ^^^

SyntaxError: Unexpected identifier
    at Module._compile (internal/modules/cjs/loader.js:743:23)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:810:10)
    at Module.load (internal/modules/cjs/loader.js:666:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:606:12)
    at Function.Module._load (internal/modules/cjs/loader.js:598:3)
    at Function.Module.runMain (internal/modules/cjs/loader.js:862:12)
    at internal/main/run_main_module.js:21:11

是我本地哪个环境配置的有问题吗?

版权问题

大佬是不是要说明下音乐的来源...

web界面重新设计

咪咕又不可用了,能搜索,但是无法播放。另外希望增加播放界面全屏的功能,方便看歌词,现在在最底下歌词看着都不方便。另外希望给web界面设计一个favicon网站图标,当一个网站使用的话看着比较正规而且美观

求教命令行模式下如何翻页

版本: v1.4.41
环境: windows 10 powershell Node.js v19.9.0,node:alpine 容器,node:bullseye-slim 容器

image

上下左右方向键和pagedown/pageup都试过了,实在不知道怎么翻页

win搜索歌曲报错

win10 node版本 :v16.15.0
使用如下命令安装的musicn

scoop install nodejs-lts pnpm
pnpm add -g musicn

安装后使用 报错
msc 稻香
node:internal/process/promises:279
triggerUncaughtException(err, true /* fromPromise */);
^

RequestError: read ECONNRESET
at ClientRequest. (C:\Users\brucm\AppData\Roaming\npm\pnpm-global\5\node_modules.pnpm\[email protected]\node_modules\got\dist\source\core\index.js:962:111) at Object.onceWrapper (node:events:642:26)
at ClientRequest.emit (node:events:539:35)
at ClientRequest.origin.emit (C:\Users\brucm\AppData\Roaming\npm\pnpm-global\5\node_modules.pnpm@[email protected]\node_modules@szmarczak\http-timer\dist\source\index.js:43:20)
at TLSSocket.socketErrorListener (node:_http_client:454:9)
at TLSSocket.emit (node:events:527:28)
at emitErrorNT (node:internal/streams/destroy:157:8)
at emitErrorCloseNT (node:internal/streams/destroy:122:3)
at processTicksAndRejections (node:internal/process/task_queues:83:21)
at TLSWrap.onStreamRead (node:internal/stream_base_commons:217:20) {
code: 'ECONNRESET',
timings: {
start: 1652756875734,
socket: 1652756875735,
lookup: 1652756875737,
connect: 1652756875739,
secureConnect: undefined,
upload: undefined,
response: undefined,
end: undefined,
error: 1652756880750,
abort: undefined,
phases: {
wait: 1,
dns: 2,
tcp: 2,
tls: undefined,
request: undefined,
firstByte: undefined,
download: undefined,
total: 5016
}
}
}

cannot use

system win 11
node v14.15.4
down way :npm intall musicn -g
question:internal/process/esm_loader.js:74
internalBinding('errors').triggerUncaughtException(
^

Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'stream' imported from C:\Users\ASUS\AppData\Roaming\npm\node_modules\musicn\lib\download.js

下载失败 报错信息为空

PS C:\Users\Administrator\AppData\Roaming\npm\node_modules\musicn> msc 黄丽玲 -n 2
? 选择歌曲 2. 难得孤寂 - A-Lin.flac - 52.1 MB, 4. 一直走 - A-Lin.flac - 45.1 MB, 5. 画心(歌手2019) - 杨坤,A-Lin.flac -
54.5 MB, 6. 我不离开 - 戴爱玲,A-Lin.flac - 60 MB, 7. 雨后彩虹 - A-Lin.flac - 42.3 MB, 8. 抱歉 我不抱歉
(电影《恋爱好好说》主题曲)(The movie theme song of Love Talk) - A-Lin.flac - 28.3 MB, 9. 听见下雨的声音 (Live) -
12. 真相-电视剧《守护神之保险调查》主题曲 - A-Lin.flac - 45.5 MB, 13. 我笑到都哭了 - A-Lin.flac - 44 MB, 14. 我都记得
(电影《奇人密码:古罗布之谜》主题曲) - A-Lin.flac - 55.5 MB, 15. 最佳男主角 - A-Lin.flac - 67.1 MB, 16. Gentlewoman -
A-Lin.flac - 47.4 MB, 17. 我值得 - A-Lin.flac - 49.6 MB, 18. 梦话 (电视剧《幻城》片尾曲) - A-Lin.flac - 47.1 MB, 19.
海洋之心 (A Lin Version)(电影《海洋奇缘》主题曲) - A-Lin.flac - 35.9 MB
下载开始...
[##############################] | 难得孤寂 - A-Lin.flac | 52.1 MB/52.1 MB
[##############################] | 一直走 - A-Lin.flac | 45.1 MB/45.1 MB
[##############################] | 画心(歌手2019) - 杨坤,A-Lin.flac | 54.5 MB/54.5 MB
[##############################] | 我不离开 - 戴爱玲,A-Lin.flac | 60 MB/60 MB
[##############################] | 雨后彩虹 - A-Lin.flac | 42.3 MB/42.3 MB
[##############################] | 抱歉 我不抱歉 (电影《恋爱好好说》主题曲)(The movie theme song of Love Talk) - A-Lin.flac
[##############################] | 听见下雨的声音 (Live) - A-Lin.flac | 50.9 MB/50.9 MB
[##############################] | 讨厌(蒙面唱将猜猜猜) - A-Lin.flac | 53.6 MB/53.6 MB
[##############################] | 伤痕(蒙面唱将猜猜猜) - A-Lin.flac | 48.7 MB/48.7 MB
[##############################] | 真相-电视剧《守护神之保险调查》主题曲 - A-Lin.flac | 45.5 MB/45.5 MB
[##############################] | 我笑到都哭了 - A-Lin.flac | 44 MB/44 MB
[##############################] | 我都记得 (电影《奇人密码:古罗布之谜》主题曲) - A-Lin.flac | 55.5 MB/55.5 MB
[##############################] | 最佳男主角 - A-Lin.flac | 67.1 MB/67.1 MB
[##############################] | Gentlewoman - A-Lin.flac | 47.4 MB/47.4 MB
[##############################] | 我值得 - A-Lin.flac | 49.6 MB/49.6 MB
[##############################] | 梦话 (电视剧《幻城》片尾曲) - A-Lin.flac | 47.1 MB/47.1 MB
[##############################] | 海洋之心 (A Lin Version)(电影《海洋奇缘》主题曲) - A-Lin.flac | 35.9 MB/35.9 MB
下载完成,成功 14 首,失败 3 首
失败信息:
1.我不离开 - 戴爱玲,A-Lin.flac下载失败,报错信息:
2.最佳男主角 - A-Lin.flac下载失败,报错信息:
3.我值得 - A-Lin.flac下载失败,报错信息:
PS C:\Users\Administrator\AppData\Roaming\npm\node_modules\musicn> msc 黄丽玲 -n 2
? 选择歌曲 6. 我不离开 - 戴爱玲,A-Lin.flac - 60 MB, 15. 最佳男主角 - A-Lin.flac - 67.1 MB, 17. 我值得 - A-Lin.flac -
49.6 MB
下载开始...
[##############################] | 我不离开 - 戴爱玲,A-Lin.flac | 60 MB/60 MB
[##############################] | 最佳男主角 - A-Lin.flac | 67.1 MB/67.1 MB
[##############################] | 我值得 - A-Lin.flac | 49.6 MB/49.6 MB
下载完成,成功 3 首,失败 0 首

更新到最新版失败

有一台电脑还是1.2.6的版本,更新报错

pnpm add -g musicn
 ERROR  Unable to find the global bin directory
Run "pnpm setup" to create it automatically, or set the global-bin-dir setting, or the PNPM_HOME env variable. The global bin directory should be in the PATH.

终于用上了,但是有时候搜索某些歌曲会报错

Snipaste_2022-05-18_00-06-48

file:///C:/Users/brucm/AppData/Roaming/npm/pnpm-global/5/node_modules/.pnpm/[email protected]/node_modules/musicn/lib/names.js:4
  const { pathname } = new URL(option.androidUrl || option.url)
                                      ^

TypeError: Cannot read properties of undefined (reading 'androidUrl')
    at names (file:///C:/Users/brucm/AppData/Roaming/npm/pnpm-global/5/node_modules/.pnpm/[email protected]/node_modules/musicn/lib/names.js:4:39)
    at file:///C:/Users/brucm/AppData/Roaming/npm/pnpm-global/5/node_modules/.pnpm/[email protected]/node_modules/musicn/lib/choose.js:10:43
    at Array.map (<anonymous>)
    at choose (file:///C:/Users/brucm/AppData/Roaming/npm/pnpm-global/5/node_modules/.pnpm/[email protected]/node_modules/musicn/lib/choose.js:10:22)
    at musicn (file:///C:/Users/brucm/AppData/Roaming/npm/pnpm-global/5/node_modules/.pnpm/[email protected]/node_modules/musicn/lib/index.js:8:26)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async file:///C:/Users/brucm/AppData/Roaming/npm/pnpm-global/5/node_modules/.pnpm/[email protected]/node_modules/musicn/bin/musicn.js:8:3`

使用 -l 下载歌词失败

林俊杰 - 交换余生.mp3下载失败,报错信息:ParseError: Unexpected token 抱 in JSON at position 0 i"
node:internal/fs/utils:345
throw err;
^

Error: ENOENT: no such file or directory, scandir '/home/allen/Documents/music'
at Object.readdirSync (node:fs:1405:3)
at F (file:///usr/lib/node_modules/musicn/dist/index.js:1:4247)
at process. (file:///usr/lib/node_modules/musicn/dist/index.js:3:801)
at process.emit (node:events:527:28)
at processEmit [as emit] (/usr/lib/node_modules/musicn/node_modules/signal-exit/index.js:199)
at process._fatalException (node:internal/process/execution:167:25) {
errno: -2,
syscall: 'scandir',
code: 'ENOENT',
path: '/home/allen/Documents/music'
}

不论是否加 -p 写相对或者绝对路径,都会报错并且删除当前文件夹

error code E404

node:14.17.0
npm:6.14.13
OS:windos10
我看了下说报错E404需要升级npm,我更新了8.10.0也不行
报错如下
npm ERR! code E404
npm ERR! 404 Not Found - GET https://registry.npmmirror.com/musicn.js - [NOT_FOUND] musicn.js not found
npm ERR! 404
npm ERR! 404 'musicn.js@latest' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it (or use the name yourself!)
npm ERR! 404
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.

npm ERR! A complete log of this run can be found in:

支持自动下载

现在的模式是交互式的,我希望能支持自动下载,比如自动下载最新的音乐,可以支持增量下载

用 yarn 下载后用不了

提示

'musicn' 不是内部或外部命令,也不是可运行的程序

然后 npm 就可以

image

image

node: 14.17.3
windows 11

翻页出现问题 TypeError: Cannot read properties of undefined (reading '0')

我在下载一个歌单的内容的时候遇到的,不会稳定复现,可能是我操作太快导致的,不确定是不是网易云的 API 有速率限制或者别的什么问题。

image

可以试试这个命令

msc -l -s 5336246486 -w

我试了一下,看起来和页码没有关系,如果反复快速请求的话,是会触发的,怀疑是网易云有速率限制。

image

我看 -h 的输出里面没有修改每页数量的选项,如果能支持这个的话应该可以绕过这个问题

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

This repository currently has no open or pending branches.

Detected dependencies

github-actions
.github/workflows/npm-publish.yml
  • actions/checkout v3
  • actions/setup-node v3
npm
package.json
  • @inquirer/checkbox 0.0.24-alpha.0
  • cli-progress 3.11.2
  • colorette 2.0.19
  • commander 9.4.0
  • got 12.3.1
  • ora 6.1.2
  • pretty-bytes 6.0.0
  • update-notifier 6.0.2
  • @types/cli-progress 3.11.0
  • @types/inquirer 9.0.1
  • @types/node 18.7.6
  • @types/update-notifier 6.0.1
  • @typescript-eslint/eslint-plugin 5.33.1
  • @typescript-eslint/parser 5.33.1
  • bumpp 8.2.1
  • eslint 8.22.0
  • eslint-config-prettier 8.5.0
  • eslint-plugin-import 2.26.0
  • eslint-plugin-prettier 4.2.1
  • husky 8.0.1
  • lint-staged 13.0.3
  • prettier 2.7.1
  • tsup 6.2.2
  • typescript 4.7.4
  • node >=16.0.0

  • Check this box to trigger a request for Renovate to run again on this repository

msc 周杰伦 报错

internal/process/esm_loader.js:74
internalBinding('errors').triggerUncaughtException(
^

Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'stream' imported from /usr/local/lib/node_modules/musicn/dist/index.js
at packageResolve (internal/modules/esm/resolve.js:664:9)
at moduleResolve (internal/modules/esm/resolve.js:705:18)
at Loader.defaultResolve [as _resolve] (internal/modules/esm/resolve.js:819:11)
at Loader.resolve (internal/modules/esm/loader.js:89:40)
at Loader.getModuleJob (internal/modules/esm/loader.js:242:28)
at ModuleWrap. (internal/modules/esm/module_job.js:73:40)
at link (internal/modules/esm/module_job.js:72:36) {
code: 'ERR_MODULE_NOT_FOUND'
}

node -v
v14.17.6

出现连接超时下载失败的问题

我在自己的电脑和阿里云服务器上尝试下载不同的歌曲均失败,因为我人在国外所以我感觉应该不是因为墙的原因吧。
报错信息如下:
1
这是阿里云服务器上的报错,尝试直接ping这个IP地址是通的。
2
这是我自己电脑上的报错。
各位有没有什么头绪?挠头.jpg

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.