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.3.tar.gz (30.5 kB view details)

Uploaded Source

Built Distribution

pyncm_async-0.1.3-py3-none-any.whl (36.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pyncm_async-0.1.3.tar.gz
  • Upload date:
  • Size: 30.5 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.3.tar.gz
Algorithm Hash digest
SHA256 9ca99e524b5ccc2a7ab9e44101685f1be80de1a16c4889f82714c28601e603e0
MD5 8c71b417345578f50d586e3c6df9ef5f
BLAKE2b-256 66738d0cb7146d96ddb03ee4b71cba75a1b11fa24c19dd4aa2bce3617b4a5696

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pyncm_async-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 36.7 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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 7d2bc7669e3779c9f6e21e5a115e3f6f77427a206a2a6bfd16ac163e1135abfd
MD5 410491aca29431f8757375478f599f8d
BLAKE2b-256 83ca46c013d4366425950d82f643785b7acdb76600f4ad7d09bc45d598fe6a1d

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