{"id":13815191,"url":"https://github.com/mos9527/pyncm","last_synced_at":"2025-05-15T11:05:21.829Z","repository":{"id":37287404,"uuid":"239262386","full_name":"mos9527/pyncm","owner":"mos9527","description":"第三方网易云音乐 Python API + 转储工具","archived":false,"fork":false,"pushed_at":"2024-12-08T07:22:06.000Z","size":525,"stargazers_count":589,"open_issues_count":4,"forks_count":77,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-28T19:49:27.318Z","etag":null,"topics":["api","asyncio","netease-cloud-music","python","reverse-engineering"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mos9527.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-02-09T07:10:42.000Z","updated_at":"2025-04-28T13:05:38.000Z","dependencies_parsed_at":"2024-01-15T13:26:13.379Z","dependency_job_id":"b4d3ec09-0468-4a21-8671-4867e298a76b","html_url":"https://github.com/mos9527/pyncm","commit_stats":{"total_commits":257,"total_committers":9,"mean_commits":"28.555555555555557","dds":"0.10116731517509725","last_synced_commit":"20d846c92e4e44a724c3ef1b0163e860206fc6de"},"previous_names":["greats3an/pyncm"],"tags_count":81,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mos9527%2Fpyncm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mos9527%2Fpyncm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mos9527%2Fpyncm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mos9527%2Fpyncm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mos9527","download_url":"https://codeload.github.com/mos9527/pyncm/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254328385,"owners_count":22052632,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","asyncio","netease-cloud-music","python","reverse-engineering"],"created_at":"2024-08-04T04:03:06.784Z","updated_at":"2025-05-15T11:05:21.780Z","avatar_url":"https://github.com/mos9527.png","language":"Python","readme":"![Logo](https://github.com/greats3an/pyncm/raw/master/demos/_logo.png)\n\n# PyNCM\n[![Windows Build](https://github.com/mos9527/pyncm/actions/workflows/build-and-publish.yml/badge.svg)](https://github.com/mos9527/pyncm/blob/master/.github/workflows/build-and-publish.yml) [![Releases](https://img.shields.io/github/downloads/mos9527/pyncm/total.svg)](https://GitHub.com/mos9527/pyncm/releases/) [![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black) \n\n第三方网易云音乐 Python API 及个人音乐库离线转储工具\n\n**注意** : 异步使用，请移步 [`async` 分支](https://github.com/mos9527/pyncm/tree/async)\n\n# 安装\n    pip install pyncm\n可选 （若不考虑使用CLI则请忽略）\n- `mutagen` : 为下载的音乐打上封面等\n- `tqdm`    : 显示实时下载进度\n- `coloredlogs` : 彩色日志输出\n\n**Windows 用户**: 在 [Releases](https://github.com/mos9527/pyncm/releases) 可下载已打包 `.exe` 版本 (x86)\n# 命令行使用\n    positional arguments:\n    链接                    网易云音乐分享链接\n\n    options:\n    -h, --help            show this help message and exit\n\n    下载:\n    --max-workers 最多同时下载任务数, -m 最多同时下载任务数\n    --output-name 保存文件名模板, --template 保存文件名模板, -t 保存文件名模板\n                            保存文件名模板\n                                参数：\n                                    id     - 网易云音乐资源 ID\n                                    year   - 出版年份\n                                    no     - 专辑中编号\n                                    album  - 专辑标题\n                                    track  - 单曲标题\n                                    title  - 完整标题\n                                    artists- 艺术家名\n                                例：\n                                    {track} - {artists} 等效于 {title}\n    -o 输出, --output 输出    输出文件夹\n                                注：该参数也可使用模板，格式同 保存文件名模板\n    --quality 音质          音频音质（高音质需要 CVIP）\n                                参数：\n                                    hires  - Hi-Res\n                                    lossless- “无损”\n                                    exhigh  - 较高\n                                    standard- 标准\n    -dl, --use-download-api\n                            调用下载API，而非播放API进行下载。如此可能允许更高高音质音频的下载。\n                            【注意】此API有额度限制，参考 https://music.163.com/member/downinfo\n    --no-overwrite        不重复下载已经存在的音频文件\n\n    歌词:\n    --lyric-no 跳过歌词       跳过某些歌词类型的下载\n                                参数：\n                                    lrc    - 源语言歌词  (合并到 .lrc)\n                                    tlyric - 翻译后歌词  (合并到 .lrc)\n                                    romalrc- 罗马音歌词  (合并到 .lrc)\n                                    yrc    - 逐词滚动歌词 (保存到 .ass)\n                                    none   - 下载所有歌词\n                                例：\n                                    --lyric-no \"tlyric romalrc yrc\" 将只下载源语言歌词\n                                    --lyric-no none 将下载所有歌词\n                                注：\n                                    默认不下载 *逐词滚动歌词*\n\n\n    登陆:\n    --phone 手机            网易账户手机号\n    --cookie Cookie (MUSIC_U)\n                            网易云音乐 MUSIC_U Cookie (形如 '00B2471D143...')\n    --pwd 密码, --password 密码\n                            网易账户密码\n    --save [保存到]          写本次登录信息于文件\n    --load [保存的登陆信息文件]    从文件读取登录信息供本次登陆使用\n    --http                优先使用 HTTP，不保证不被升级\n    --deviceId 设备ID       指定设备 ID；匿名登陆时，设备 ID 既指定对应账户\n                            【注意】默认 ID 与当前设备无关，乃从内嵌 256 可用 ID 中随机选取；指定自定义 ID 不一定能登录，相关性暂时未知\n    --log-level LOG_LEVEL\n                            日志等级\n\n    限量及过滤（注：只适用于*每单个*链接 / ID）:\n    -n 下载总量, --count 下载总量\n                            限制下载歌曲总量，n=0即不限制（注：过大值可能导致限流）\n    --sort-by 歌曲排序        【限制总量时】歌曲排序方式 (default: 默认排序 hot: 热度高（相对于其所在专辑）在前 time: 发行时间新在前)\n    --reverse-sort        【限制总量时】倒序排序歌曲\n    --user-bookmarks      【下载用户歌单时】在下载用户创建的歌单的同时，也下载其收藏的歌单\n\n    工具:\n    --save-m3u 保存M3U播放列表文件名\n                            将本次下载的歌曲文件名依一定顺序保存在M3U文件中；写入的文件目录相对于该M3U文件\n                                    文件编码为 UTF-8\n                                    顺序为：链接先后优先——每个链接的所有歌曲依照歌曲排序设定 （--sort-by）排序\n## 环境变量\n|变量名|说明|\n|-|-|\n|`PYNCM_DEBUG`|调试日志输出等级,`'CRITICAL', 'DEBUG', 'ERROR','FATAL','INFO','WARNING'` 之一|\n### 使用示例\n## 转储单曲\n[![asciicast](https://asciinema.org/a/4PEC5977rTcm4hp9jLuPFYUM1.svg)](https://asciinema.org/a/4PEC5977rTcm4hp9jLuPFYUM1)\n\nAPI使用详见 \n- [Demo](https://github.com/mos9527/pyncm/tree/master/demos)\n\n# API 使用示例\n```python\n\u003e\u003e\u003e from pyncm import apis\n# 获取歌曲信息    \n\u003e\u003e\u003e apis.track.GetTrackAudio(29732235)\n{'data': [{'id': 29732235, 'url': 'http://m701.music...\n# 获取歌曲详情\n\u003e\u003e\u003e apis.track.GetTrackDetail(29732235)    \n{'songs': [{'name': 'Supernova', 'id': 2...\n# 获取歌曲评论\n\u003e\u003e\u003e apis.track.GetTrackComments(29732235)    \n{'isMusician': False, 'userId': -1, 'topComments': [], 'moreHot': True, 'hotComments': [{'user': {'locationInfo': None, 'liveIn ...\n```\n- 多 Session 示例\n```python\nLoginViaEmail(...) \n# 利用全局 Session 完成该 API Call\nsession = CreateNewSession() # 建立新的 Session\nwith session: # 进入该 Session, 在 `with` 内的 API 将由该 Session 完成\n    LoginViaCellPhone(...)\n    result = GetTrackAudio(...)\n# 离开 Session. 此后 API 将继续由全局 Session 管理\nGetTrackComments(...)\n```\n\n同时，你也可以在 API Call 中 指定 Session\n```python\nawait GetTrackComments(..., session=session)\n```\n\n详见 [Session 说明](https://github.com/mos9527/pyncm/blob/master/pyncm/__init__.py#L52)\n## API 说明\n大部分 API 函数已经详细注释，可读性较高。推荐参阅 [API 源码](https://github.com/mos9527/pyncm/tree/master/pyncm) 获得支持\n\n## FAQ\n- 为什么 `GetTrackAudio` 几乎拿不到音频 URL？\n\n你需要[进行登陆](https://github.com/mos9527/pyncm/blob/master/pyncm/apis/login.py)。若身边没有合适的账号，也可选择匿名登陆：\n```python\n\u003e\u003e\u003e from pyncm.apis.login import LoginViaAnonymousAccount\n\u003e\u003e\u003e LoginViaAnonymousAccount()\n{'tick': 1662870122.1159196,\n 'content': {'code': 200,\n  'userId': 8023914528,\n  'createTime': 1662868134354,\n  'profile': {'nickname': 'Ano...\n```\n# 感谢\n[Android逆向——网易云音乐排行榜api(上)](https://juejin.im/post/6844903586879520775)\n\n[Binaryify/NeteaseCloudMusicApi](https://gitlab.com/Binaryify/neteasecloudmusicapi)\n","funding_links":[],"categories":["Python"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmos9527%2Fpyncm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmos9527%2Fpyncm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmos9527%2Fpyncm/lists"}