pyncm-async


Namepyncm-async JSON
Version 0.1.3 PyPI version JSON
download
home_pagehttps://github.com/greats3an/pyncm
SummaryNeteaseCloudMusic APIs for Python 3.x 适用于 Python 3 的网易云音乐异步 API
upload_time2024-11-18 11:37:23
maintainerNone
docs_urlNone
authorgreats3an
requires_python>=3.8
licenseNone
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ![Logo](https://github.com/greats3an/pyncm/raw/master/demos/_logo.png)

# PyNCM Async!

# 安装
    pip install pyncm-async

# API 使用示例 (IPython)
```python
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 示例

```python
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
```python
await GetTrackComments(..., session=session)
```

详见 [Session 说明](https://github.com/mos9527/pyncm/blob/async/pyncm/__init__.py#L35)
## API 说明
大部分 API 函数已经详细注释,可读性较高。推荐参阅 [API 源码](https://github.com/mos9527/pyncm/tree/async/pyncm) 获得支持

## FAQ
- 为什么 `GetTrackAudio` 几乎拿不到音频 URL?

你需要[进行登陆](https://github.com/mos9527/pyncm/blob/master/async/apis/login.py)。若身边没有合适的账号,也可选择匿名登陆 (IPython内示例):
```python
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(上)](https://juejin.im/post/6844903586879520775)

[Binaryify/NeteaseCloudMusicApi](https://github.com/Binaryify/NeteaseCloudMusicApi)

### 衍生项目
[PyNCMd](https://github.com/mos9527/pyncmd)

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/greats3an/pyncm",
    "name": "pyncm-async",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": null,
    "author": "greats3an",
    "author_email": "greats3an@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/66/73/8d0cb7146d96ddb03ee4b71cba75a1b11fa24c19dd4aa2bce3617b4a5696/pyncm_async-0.1.3.tar.gz",
    "platform": null,
    "description": "![Logo](https://github.com/greats3an/pyncm/raw/master/demos/_logo.png)\n\n# PyNCM Async!\n\n# \u5b89\u88c5\n    pip install pyncm-async\n\n# API \u4f7f\u7528\u793a\u4f8b (IPython)\n```python\nIn [1]: from pyncm_async import apis\n# \u83b7\u53d6\u6b4c\u66f2\u4fe1\u606f    \nIn [2]: await apis.track.GetTrackAudio(29732235)\nOut[2]:\n{'data': [{'id': 29732235, 'url': 'http://m701.music...\n# \u83b7\u53d6\u6b4c\u66f2\u8be6\u60c5\nIn [3]: await apis.track.GetTrackDetail(29732235)    \nOut[3]:\n{'songs': [{'name': 'Supernova', 'id': 2...\n# \u83b7\u53d6\u6b4c\u66f2\u8bc4\u8bba\nIn [4]: await apis.track.GetTrackComments(29732235)    \nOut[4]:\n{'isMusician': False, 'userId': -1, 'topComments': [], 'moreHot': True, 'hotComments': [{'user': {'locationInfo': None, 'liveIn ...\n```\n- \u591a Session \u793a\u4f8b\n\n```python\nLoginViaEmail(...) \n# \u5229\u7528\u5168\u5c40 Session \u5b8c\u6210\u8be5 API Call\nsession = CreateNewSession() # \u5efa\u7acb\u65b0\u7684 Session\nawait LoginViaEmail(...) \nasync with CreateNewSession(): # \u5efa\u7acb\u65b0\u7684 Session\uff0c\u5e76\u8fdb\u5165\u8be5 Session, \u5728 `with` \u5185\u7684 API \u5c06\u7531\u8be5 Session \u5b8c\u6210\n    await LoginViaCellPhone(...)\n# \u79bb\u5f00 Session. \u6b64\u540e API \u5c06\u7ee7\u7eed\u7531\u5168\u5c40 Session \u7ba1\u7406\nawait GetTrackComments(...)\n```\n\u4f7f\u7528 `with` \u65f6...\n- \u6ce8\uff1aSession \u5404*\u7ebf\u7a0b*\u72ec\u7acb\uff0c\u5404\u7ebf\u7a0b\u5229\u7528 `with` \u8bbe\u7f6e\u7684 Session \u4e0d\u4e92\u76f8\u5f71\u54cd\n- \u6ce8\uff1aSession \u79bb\u5f00 `with` clause \u65f6\uff0c**Session \u4f1a\u88ab\u9500\u6bc1**\uff0c\u4f46\u4e0d\u4f1a\u5f71\u54cd\u5168\u5c40 Session\n- \u6ce8\uff1aSession \u751f\u547d\u5468\u671f\u7ec6\u8282\u8bf7\u53c2\u9605 https://www.python-httpx.org/async/\n\n\u540c\u65f6\uff0c\u4f60\u4e5f\u53ef\u4ee5\u5728 API Call \u4e2d \u6307\u5b9a Session\n```python\nawait GetTrackComments(..., session=session)\n```\n\n\u8be6\u89c1 [Session \u8bf4\u660e](https://github.com/mos9527/pyncm/blob/async/pyncm/__init__.py#L35)\n## API \u8bf4\u660e\n\u5927\u90e8\u5206 API \u51fd\u6570\u5df2\u7ecf\u8be6\u7ec6\u6ce8\u91ca\uff0c\u53ef\u8bfb\u6027\u8f83\u9ad8\u3002\u63a8\u8350\u53c2\u9605 [API \u6e90\u7801](https://github.com/mos9527/pyncm/tree/async/pyncm) \u83b7\u5f97\u652f\u6301\n\n## FAQ\n- \u4e3a\u4ec0\u4e48 `GetTrackAudio` \u51e0\u4e4e\u62ff\u4e0d\u5230\u97f3\u9891 URL\uff1f\n\n\u4f60\u9700\u8981[\u8fdb\u884c\u767b\u9646](https://github.com/mos9527/pyncm/blob/master/async/apis/login.py)\u3002\u82e5\u8eab\u8fb9\u6ca1\u6709\u5408\u9002\u7684\u8d26\u53f7\uff0c\u4e5f\u53ef\u9009\u62e9\u533f\u540d\u767b\u9646 (IPython\u5185\u793a\u4f8b)\uff1a\n```python\nIn [1]: from pyncm_async.apis.login import LoginViaAnonymousAccount\nIn [2]: await LoginViaAnonymousAccount()\nOut[2]:\n{'tick': 1662870122.1159196,\n 'content': {'code': 200,\n  'userId': 8023914528,\n  'createTime': 1662868134354,\n  'profile': {'nickname': 'Ano...\n```\n# \u611f\u8c22\n[Android\u9006\u5411\u2014\u2014\u7f51\u6613\u4e91\u97f3\u4e50\u6392\u884c\u699capi(\u4e0a)](https://juejin.im/post/6844903586879520775)\n\n[Binaryify/NeteaseCloudMusicApi](https://github.com/Binaryify/NeteaseCloudMusicApi)\n\n### \u884d\u751f\u9879\u76ee\n[PyNCMd](https://github.com/mos9527/pyncmd)\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "NeteaseCloudMusic APIs for Python 3.x \u9002\u7528\u4e8e Python 3 \u7684\u7f51\u6613\u4e91\u97f3\u4e50\u5f02\u6b65 API",
    "version": "0.1.3",
    "project_urls": {
        "Homepage": "https://github.com/greats3an/pyncm"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "83ca46c013d4366425950d82f643785b7acdb76600f4ad7d09bc45d598fe6a1d",
                "md5": "410491aca29431f8757375478f599f8d",
                "sha256": "7d2bc7669e3779c9f6e21e5a115e3f6f77427a206a2a6bfd16ac163e1135abfd"
            },
            "downloads": -1,
            "filename": "pyncm_async-0.1.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "410491aca29431f8757375478f599f8d",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 36684,
            "upload_time": "2024-11-18T11:37:22",
            "upload_time_iso_8601": "2024-11-18T11:37:22.169565Z",
            "url": "https://files.pythonhosted.org/packages/83/ca/46c013d4366425950d82f643785b7acdb76600f4ad7d09bc45d598fe6a1d/pyncm_async-0.1.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "66738d0cb7146d96ddb03ee4b71cba75a1b11fa24c19dd4aa2bce3617b4a5696",
                "md5": "8c71b417345578f50d586e3c6df9ef5f",
                "sha256": "9ca99e524b5ccc2a7ab9e44101685f1be80de1a16c4889f82714c28601e603e0"
            },
            "downloads": -1,
            "filename": "pyncm_async-0.1.3.tar.gz",
            "has_sig": false,
            "md5_digest": "8c71b417345578f50d586e3c6df9ef5f",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 30515,
            "upload_time": "2024-11-18T11:37:23",
            "upload_time_iso_8601": "2024-11-18T11:37:23.729546Z",
            "url": "https://files.pythonhosted.org/packages/66/73/8d0cb7146d96ddb03ee4b71cba75a1b11fa24c19dd4aa2bce3617b4a5696/pyncm_async-0.1.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-11-18 11:37:23",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "greats3an",
    "github_project": "pyncm",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "pyncm-async"
}
        
Elapsed time: 0.39767s