Skip to main content

NeteaseCloudMusic APIs for Python 3.x 适用于 Python 3 的网易云音乐异步 API

Project description

Logo

PyNCM Async!

安装

pip install pyncm-async

API 使用示例 (IPython)

In [1]: from pyncm_async import apis
# 获取歌曲信息    
In [2]: await apis.track.GetTrackAudio(29732235)
Out[2]:
{'data': [{'id': 29732235, 'url': 'http://m701.music...
# 获取歌曲详情
In [3]: await apis.track.GetTrackDetail(29732235)    
Out[3]:
{'songs': [{'name': 'Supernova', 'id': 2...
# 获取歌曲评论
In [4]: await apis.track.GetTrackComments(29732235)    
Out[4]:
{'isMusician': False, 'userId': -1, 'topComments': [], 'moreHot': True, 'hotComments': [{'user': {'locationInfo': None, 'liveIn ...
  • 多 Session 示例
LoginViaEmail(...) 
# 利用全局 Session 完成该 API Call
session = CreateNewSession() # 建立新的 Session
await LoginViaEmail(...) 
async with CreateNewSession(): # 建立新的 Session,并进入该 Session, 在 `with` 内的 API 将由该 Session 完成
    await LoginViaCellPhone(...)
# 离开 Session. 此后 API 将继续由全局 Session 管理
await GetTrackComments(...)

使用 with 时...

  • 注:Session 各线程独立,各线程利用 with 设置的 Session 不互相影响
  • 注:Session 离开 with clause 时,Session 会被销毁,但不会影响全局 Session
  • 注:Session 生命周期细节请参阅 https://www.python-httpx.org/async/

同时,你也可以在 API Call 中 指定 Session

await GetTrackComments(..., session=session)

详见 Session 说明

API 说明

大部分 API 函数已经详细注释,可读性较高。推荐参阅 API 源码 获得支持

FAQ

  • 为什么 GetTrackAudio 几乎拿不到音频 URL?

你需要进行登陆。若身边没有合适的账号,也可选择匿名登陆 (IPython内示例):

In [1]: from pyncm_async.apis.login import LoginViaAnonymousAccount
In [2]: await LoginViaAnonymousAccount()
Out[2]:
{'tick': 1662870122.1159196,
 'content': {'code': 200,
  'userId': 8023914528,
  'createTime': 1662868134354,
  'profile': {'nickname': 'Ano...

感谢

Android逆向——网易云音乐排行榜api(上)

Binaryify/NeteaseCloudMusicApi

衍生项目

PyNCMd

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyncm_async-0.1.2.tar.gz (30.4 kB view details)

Uploaded Source

Built Distribution

pyncm_async-0.1.2-py3-none-any.whl (36.6 kB view details)

Uploaded Python 3

File details

Details for the file pyncm_async-0.1.2.tar.gz.

File metadata

  • Download URL: pyncm_async-0.1.2.tar.gz
  • Upload date:
  • Size: 30.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.20

File hashes

Hashes for pyncm_async-0.1.2.tar.gz
Algorithm Hash digest
SHA256 e14f032a5b28daa558c31501f9b514989e553a8ee28b86ef2b03e9cbc48be300
MD5 11c9505328547c34b530e68677401ced
BLAKE2b-256 1525b90bb0ecf59317c8c28ae8e8721155f3d1be381323219a2caa7ee3d1fabf

See more details on using hashes here.

File details

Details for the file pyncm_async-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: pyncm_async-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 36.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.20

File hashes

Hashes for pyncm_async-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 377f1f323b67f11bdbe5e2121cd55213706feffb675bc2a2ee624fcad969c865
MD5 02c51add7283bbd43d883593e8181e1d
BLAKE2b-256 a01023654f414e0ed4e8f08c2fd03e123ac1e99771dad6d540abce1aeffd6c19

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page