qqmusic-api-python 0.1.2__tar.gz → 0.1.5__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- qqmusic_api_python-0.1.5/PKG-INFO +110 -0
- qqmusic_api_python-0.1.5/README.md +81 -0
- qqmusic_api_python-0.1.5/pyproject.toml +145 -0
- {qqmusic_api_python-0.1.2 → qqmusic_api_python-0.1.5}/qqmusic_api/__init__.py +2 -0
- qqmusic_api_python-0.1.5/qqmusic_api/album.py +54 -0
- {qqmusic_api_python-0.1.2 → qqmusic_api_python-0.1.5}/qqmusic_api/data/api/album.json +3 -1
- {qqmusic_api_python-0.1.2 → qqmusic_api_python-0.1.5}/qqmusic_api/exceptions/ApiException.py +4 -3
- {qqmusic_api_python-0.1.2 → qqmusic_api_python-0.1.5}/qqmusic_api/exceptions/CredentialNoMusicidException.py +4 -0
- {qqmusic_api_python-0.1.2 → qqmusic_api_python-0.1.5}/qqmusic_api/exceptions/CredentialNoMusickeyException.py +4 -0
- {qqmusic_api_python-0.1.2 → qqmusic_api_python-0.1.5}/qqmusic_api/exceptions/CredentialNoRefreshkeyException.py +4 -0
- {qqmusic_api_python-0.1.2 → qqmusic_api_python-0.1.5}/qqmusic_api/exceptions/LoginException.py +4 -0
- {qqmusic_api_python-0.1.2 → qqmusic_api_python-0.1.5}/qqmusic_api/exceptions/ResponseCodeException.py +5 -4
- {qqmusic_api_python-0.1.2 → qqmusic_api_python-0.1.5}/qqmusic_api/login.py +109 -68
- {qqmusic_api_python-0.1.2 → qqmusic_api_python-0.1.5}/qqmusic_api/mv.py +19 -14
- {qqmusic_api_python-0.1.2 → qqmusic_api_python-0.1.5}/qqmusic_api/search.py +15 -18
- {qqmusic_api_python-0.1.2 → qqmusic_api_python-0.1.5}/qqmusic_api/singer.py +26 -34
- {qqmusic_api_python-0.1.2 → qqmusic_api_python-0.1.5}/qqmusic_api/song.py +65 -81
- {qqmusic_api_python-0.1.2 → qqmusic_api_python-0.1.5}/qqmusic_api/songlist.py +16 -15
- {qqmusic_api_python-0.1.2 → qqmusic_api_python-0.1.5}/qqmusic_api/top.py +18 -14
- {qqmusic_api_python-0.1.2 → qqmusic_api_python-0.1.5}/qqmusic_api/utils/credential.py +23 -28
- {qqmusic_api_python-0.1.2 → qqmusic_api_python-0.1.5}/qqmusic_api/utils/network.py +21 -43
- {qqmusic_api_python-0.1.2 → qqmusic_api_python-0.1.5}/qqmusic_api/utils/qimei.py +80 -6
- {qqmusic_api_python-0.1.2 → qqmusic_api_python-0.1.5}/qqmusic_api/utils/sync.py +2 -4
- {qqmusic_api_python-0.1.2 → qqmusic_api_python-0.1.5}/qqmusic_api/utils/utils.py +16 -9
- qqmusic_api_python-0.1.5/tests/__init__.py +3 -0
- qqmusic_api_python-0.1.5/tests/conftest.py +49 -0
- qqmusic_api_python-0.1.5/tests/test_album.py +11 -0
- qqmusic_api_python-0.1.5/tests/test_login.py +30 -0
- qqmusic_api_python-0.1.5/tests/test_mv.py +21 -0
- qqmusic_api_python-0.1.5/tests/test_search.py +31 -0
- qqmusic_api_python-0.1.5/tests/test_singer.py +35 -0
- qqmusic_api_python-0.1.5/tests/test_song.py +53 -0
- qqmusic_api_python-0.1.5/tests/test_songlist.py +15 -0
- qqmusic_api_python-0.1.5/tests/test_top.py +17 -0
- qqmusic_api_python-0.1.2/PKG-INFO +0 -112
- qqmusic_api_python-0.1.2/README.md +0 -78
- qqmusic_api_python-0.1.2/pyproject.toml +0 -68
- qqmusic_api_python-0.1.2/qqmusic_api/album.py +0 -38
- {qqmusic_api_python-0.1.2 → qqmusic_api_python-0.1.5}/LICENSE +0 -0
- {qqmusic_api_python-0.1.2 → qqmusic_api_python-0.1.5}/qqmusic_api/data/api/login.json +0 -0
- {qqmusic_api_python-0.1.2 → qqmusic_api_python-0.1.5}/qqmusic_api/data/api/mv.json +0 -0
- {qqmusic_api_python-0.1.2 → qqmusic_api_python-0.1.5}/qqmusic_api/data/api/search.json +0 -0
- {qqmusic_api_python-0.1.2 → qqmusic_api_python-0.1.5}/qqmusic_api/data/api/singer.json +0 -0
- {qqmusic_api_python-0.1.2 → qqmusic_api_python-0.1.5}/qqmusic_api/data/api/song.json +0 -0
- {qqmusic_api_python-0.1.2 → qqmusic_api_python-0.1.5}/qqmusic_api/data/api/songlist.json +0 -0
- {qqmusic_api_python-0.1.2 → qqmusic_api_python-0.1.5}/qqmusic_api/data/api/top.json +0 -0
- {qqmusic_api_python-0.1.2 → qqmusic_api_python-0.1.5}/qqmusic_api/data/file_type.json +0 -0
- {qqmusic_api_python-0.1.2 → qqmusic_api_python-0.1.5}/qqmusic_api/data/search_type.json +0 -0
- {qqmusic_api_python-0.1.2 → qqmusic_api_python-0.1.5}/qqmusic_api/exceptions/__init__.py +0 -0
- {qqmusic_api_python-0.1.2 → qqmusic_api_python-0.1.5}/qqmusic_api/utils/__init__.py +0 -0
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: qqmusic-api-python
|
|
3
|
+
Version: 0.1.5
|
|
4
|
+
Summary: QQ音乐API封装库
|
|
5
|
+
Keywords: music,api,qqmusic,tencentmusic
|
|
6
|
+
Home-page: https://github.com/luren-dc/QQMusicApi
|
|
7
|
+
Author-Email: Luren <68656403+luren-dc@users.noreply.github.com>
|
|
8
|
+
Maintainer-Email: Luren <68656403+luren-dc@users.noreply.github.com>
|
|
9
|
+
License: MIT
|
|
10
|
+
Classifier: Development Status :: 4 - Beta
|
|
11
|
+
Classifier: Natural Language :: Chinese (Simplified)
|
|
12
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
13
|
+
Classifier: Framework :: Pytest
|
|
14
|
+
Classifier: Framework :: aiohttp
|
|
15
|
+
Classifier: Programming Language :: Python
|
|
16
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
18
|
+
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
19
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
20
|
+
Project-URL: Homepage, https://github.com/luren-dc/QQMusicApi
|
|
21
|
+
Project-URL: Repository, https://github.com/luren-dc/QQMusicApi
|
|
22
|
+
Project-URL: Documentation, https://github.com/luren-dc/QQMusicApi
|
|
23
|
+
Requires-Python: <4.0,>=3.9
|
|
24
|
+
Requires-Dist: cryptography<42.0.0,>=41.0.2
|
|
25
|
+
Requires-Dist: requests<3.0.0,>=2.31.0
|
|
26
|
+
Requires-Dist: aiohttp<4.0.0,>=3.9.5
|
|
27
|
+
Requires-Dist: typing-extensions>=4.12.2
|
|
28
|
+
Description-Content-Type: text/markdown
|
|
29
|
+
|
|
30
|
+
<div align="center">
|
|
31
|
+
<h1> QQMusicApi </h1>
|
|
32
|
+
<p> Python QQ音乐 API 封装库 </p>
|
|
33
|
+
<a href="https://www.python.org">
|
|
34
|
+
<img src="https://img.shields.io/badge/python-3.9+-blue" alt="Python">
|
|
35
|
+
</a>
|
|
36
|
+
<a href="https://github.com/astral-sh/ruff">
|
|
37
|
+
<img src="https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json" alt="Ruff">
|
|
38
|
+
</a>
|
|
39
|
+
<a href="https://pdm-project.org">
|
|
40
|
+
<img src="https://img.shields.io/endpoint?url=https%3A%2F%2Fcdn.jsdelivr.net%2Fgh%2Fpdm-project%2F.github%2Fbadge.json" alt="pdm-managed">
|
|
41
|
+
</a>
|
|
42
|
+
<a href="https://github.com/luren-dc/QQMusicApi?tab=MIT-1-ov-file">
|
|
43
|
+
<img src="https://img.shields.io/github/license/luren-dc/PyQQMusicApi" alt="GitHub license">
|
|
44
|
+
</a>
|
|
45
|
+
<a href="https://github.com/luren-dc/QQMusicApi/stargazers">
|
|
46
|
+
<img src="https://img.shields.io/github/stars/luren-dc/QQMusicApi?color=yellow&label=Github%20Stars" alt="STARS">
|
|
47
|
+
</a>
|
|
48
|
+
<a href="https://github.com/luren-dc/QQMusicApi/actions/workflows/testing.yml">
|
|
49
|
+
<img src="https://github.com/luren-dc/QQMusicApi/actions/workflows/testing.yml/badge.svg?branch=dev" alt="Testing">
|
|
50
|
+
</a>
|
|
51
|
+
</div>
|
|
52
|
+
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
> [!WARNING]
|
|
56
|
+
> 本仓库的所有内容仅供学习和参考之用,禁止用于商业用途
|
|
57
|
+
|
|
58
|
+
**文档**: <a href="https://luren-dc.github.io/QQMusicApi" target="_blank">https://luren-dc.github.io/QQMusicApi</a>
|
|
59
|
+
|
|
60
|
+
**源代码**: <a href="https://github.com/luren-dc/QQMusicApi" target="_blank">https://github.com/luren-dc/QQMusicApi</a>
|
|
61
|
+
|
|
62
|
+
## 介绍
|
|
63
|
+
|
|
64
|
+
使用 Python 编写的用于调用 [QQ音乐](https://y.qq.com/) 各种 API 的库.
|
|
65
|
+
|
|
66
|
+
## 特色
|
|
67
|
+
|
|
68
|
+
- 涵盖常见 API
|
|
69
|
+
- 调用简便,函数命名易懂,代码注释详细
|
|
70
|
+
- 异步操作
|
|
71
|
+
|
|
72
|
+
## 依赖
|
|
73
|
+
|
|
74
|
+
- [AIOHTTP](https://docs.aiohttp.org/)
|
|
75
|
+
- [Requests](https://requests.readthedocs.io/)
|
|
76
|
+
- [Cryptography](https://cryptography.io/)
|
|
77
|
+
|
|
78
|
+
## 快速上手
|
|
79
|
+
|
|
80
|
+
### 安装
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
pip install qqmusic-api-python
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### 使用
|
|
87
|
+
|
|
88
|
+
```python
|
|
89
|
+
import asyncio
|
|
90
|
+
|
|
91
|
+
from qqmusic_api import search
|
|
92
|
+
|
|
93
|
+
async def main():
|
|
94
|
+
# 搜索歌曲
|
|
95
|
+
result = await search.search_by_type(keyword="周杰伦", num=20)
|
|
96
|
+
# 打印结果
|
|
97
|
+
print(result)
|
|
98
|
+
|
|
99
|
+
asyncio.run(main())
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
## 参考项目
|
|
103
|
+
|
|
104
|
+
- [Rain120/qq-muisc-api](https://github.com/Rain120/qq-music-api)
|
|
105
|
+
- [jsososo/QQMusicApi](https://github.com/jsososo/QQMusicApi)
|
|
106
|
+
- [Nemo2011/bilibili-api](https://github.com/Nemo2011/bilibili-api/)
|
|
107
|
+
|
|
108
|
+
## Licence
|
|
109
|
+
|
|
110
|
+
**[MIT License](https://github.com/luren-dc/QQMusicApi?tab=MIT-1-ov-file)**
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
<h1> QQMusicApi </h1>
|
|
3
|
+
<p> Python QQ音乐 API 封装库 </p>
|
|
4
|
+
<a href="https://www.python.org">
|
|
5
|
+
<img src="https://img.shields.io/badge/python-3.9+-blue" alt="Python">
|
|
6
|
+
</a>
|
|
7
|
+
<a href="https://github.com/astral-sh/ruff">
|
|
8
|
+
<img src="https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json" alt="Ruff">
|
|
9
|
+
</a>
|
|
10
|
+
<a href="https://pdm-project.org">
|
|
11
|
+
<img src="https://img.shields.io/endpoint?url=https%3A%2F%2Fcdn.jsdelivr.net%2Fgh%2Fpdm-project%2F.github%2Fbadge.json" alt="pdm-managed">
|
|
12
|
+
</a>
|
|
13
|
+
<a href="https://github.com/luren-dc/QQMusicApi?tab=MIT-1-ov-file">
|
|
14
|
+
<img src="https://img.shields.io/github/license/luren-dc/PyQQMusicApi" alt="GitHub license">
|
|
15
|
+
</a>
|
|
16
|
+
<a href="https://github.com/luren-dc/QQMusicApi/stargazers">
|
|
17
|
+
<img src="https://img.shields.io/github/stars/luren-dc/QQMusicApi?color=yellow&label=Github%20Stars" alt="STARS">
|
|
18
|
+
</a>
|
|
19
|
+
<a href="https://github.com/luren-dc/QQMusicApi/actions/workflows/testing.yml">
|
|
20
|
+
<img src="https://github.com/luren-dc/QQMusicApi/actions/workflows/testing.yml/badge.svg?branch=dev" alt="Testing">
|
|
21
|
+
</a>
|
|
22
|
+
</div>
|
|
23
|
+
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
> [!WARNING]
|
|
27
|
+
> 本仓库的所有内容仅供学习和参考之用,禁止用于商业用途
|
|
28
|
+
|
|
29
|
+
**文档**: <a href="https://luren-dc.github.io/QQMusicApi" target="_blank">https://luren-dc.github.io/QQMusicApi</a>
|
|
30
|
+
|
|
31
|
+
**源代码**: <a href="https://github.com/luren-dc/QQMusicApi" target="_blank">https://github.com/luren-dc/QQMusicApi</a>
|
|
32
|
+
|
|
33
|
+
## 介绍
|
|
34
|
+
|
|
35
|
+
使用 Python 编写的用于调用 [QQ音乐](https://y.qq.com/) 各种 API 的库.
|
|
36
|
+
|
|
37
|
+
## 特色
|
|
38
|
+
|
|
39
|
+
- 涵盖常见 API
|
|
40
|
+
- 调用简便,函数命名易懂,代码注释详细
|
|
41
|
+
- 异步操作
|
|
42
|
+
|
|
43
|
+
## 依赖
|
|
44
|
+
|
|
45
|
+
- [AIOHTTP](https://docs.aiohttp.org/)
|
|
46
|
+
- [Requests](https://requests.readthedocs.io/)
|
|
47
|
+
- [Cryptography](https://cryptography.io/)
|
|
48
|
+
|
|
49
|
+
## 快速上手
|
|
50
|
+
|
|
51
|
+
### 安装
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
pip install qqmusic-api-python
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### 使用
|
|
58
|
+
|
|
59
|
+
```python
|
|
60
|
+
import asyncio
|
|
61
|
+
|
|
62
|
+
from qqmusic_api import search
|
|
63
|
+
|
|
64
|
+
async def main():
|
|
65
|
+
# 搜索歌曲
|
|
66
|
+
result = await search.search_by_type(keyword="周杰伦", num=20)
|
|
67
|
+
# 打印结果
|
|
68
|
+
print(result)
|
|
69
|
+
|
|
70
|
+
asyncio.run(main())
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## 参考项目
|
|
74
|
+
|
|
75
|
+
- [Rain120/qq-muisc-api](https://github.com/Rain120/qq-music-api)
|
|
76
|
+
- [jsososo/QQMusicApi](https://github.com/jsososo/QQMusicApi)
|
|
77
|
+
- [Nemo2011/bilibili-api](https://github.com/Nemo2011/bilibili-api/)
|
|
78
|
+
|
|
79
|
+
## Licence
|
|
80
|
+
|
|
81
|
+
**[MIT License](https://github.com/luren-dc/QQMusicApi?tab=MIT-1-ov-file)**
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = [
|
|
3
|
+
"pdm-backend",
|
|
4
|
+
]
|
|
5
|
+
build-backend = "pdm.backend"
|
|
6
|
+
|
|
7
|
+
[project]
|
|
8
|
+
name = "qqmusic-api-python"
|
|
9
|
+
description = "QQ音乐API封装库"
|
|
10
|
+
authors = [
|
|
11
|
+
{ name = "Luren", email = "68656403+luren-dc@users.noreply.github.com" },
|
|
12
|
+
]
|
|
13
|
+
dependencies = [
|
|
14
|
+
"cryptography<42.0.0,>=41.0.2",
|
|
15
|
+
"requests<3.0.0,>=2.31.0",
|
|
16
|
+
"aiohttp<4.0.0,>=3.9.5",
|
|
17
|
+
"typing-extensions>=4.12.2",
|
|
18
|
+
]
|
|
19
|
+
requires-python = "<4.0,>=3.9"
|
|
20
|
+
readme = "README.md"
|
|
21
|
+
maintainers = [
|
|
22
|
+
{ name = "Luren", email = "68656403+luren-dc@users.noreply.github.com" },
|
|
23
|
+
]
|
|
24
|
+
keywords = [
|
|
25
|
+
"music",
|
|
26
|
+
"api",
|
|
27
|
+
"qqmusic",
|
|
28
|
+
"tencentmusic",
|
|
29
|
+
]
|
|
30
|
+
classifiers = [
|
|
31
|
+
"Development Status :: 4 - Beta",
|
|
32
|
+
"Natural Language :: Chinese (Simplified)",
|
|
33
|
+
"License :: OSI Approved :: MIT License",
|
|
34
|
+
"Framework :: Pytest",
|
|
35
|
+
"Framework :: aiohttp",
|
|
36
|
+
"Programming Language :: Python",
|
|
37
|
+
"Programming Language :: Python :: 3 :: Only",
|
|
38
|
+
"Programming Language :: Python :: 3.9",
|
|
39
|
+
"Programming Language :: Python :: Implementation :: CPython",
|
|
40
|
+
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
41
|
+
]
|
|
42
|
+
dynamic = []
|
|
43
|
+
version = "0.1.5"
|
|
44
|
+
|
|
45
|
+
[project.license]
|
|
46
|
+
text = "MIT"
|
|
47
|
+
|
|
48
|
+
[project.urls]
|
|
49
|
+
homepage = "https://github.com/luren-dc/QQMusicApi"
|
|
50
|
+
repository = "https://github.com/luren-dc/QQMusicApi"
|
|
51
|
+
documentation = "https://github.com/luren-dc/QQMusicApi"
|
|
52
|
+
|
|
53
|
+
[tool.pdm]
|
|
54
|
+
distribution = true
|
|
55
|
+
|
|
56
|
+
[tool.pdm.version]
|
|
57
|
+
source = "file"
|
|
58
|
+
path = "qqmusic_api/__init__.py"
|
|
59
|
+
|
|
60
|
+
[tool.pdm.dev-dependencies]
|
|
61
|
+
testing = [
|
|
62
|
+
"pytest<9.0.0,>=8.2.0",
|
|
63
|
+
"pytest-asyncio<1.0.0,>=0.23.6",
|
|
64
|
+
"pytest-sugar<2.0.0,>=1.0.0",
|
|
65
|
+
]
|
|
66
|
+
docs = [
|
|
67
|
+
"mkdocs-material>=9.5.29",
|
|
68
|
+
"mkdocstrings-python>=1.10.5",
|
|
69
|
+
"mkdocstrings>=0.25.1",
|
|
70
|
+
"mkdocs>=1.6.0",
|
|
71
|
+
"markdown-callouts>=0.4.0",
|
|
72
|
+
"griffe-inherited-docstrings>=1.0.0",
|
|
73
|
+
]
|
|
74
|
+
mypy = [
|
|
75
|
+
"mypy>=1.11.0",
|
|
76
|
+
"types-requests>=2.32.0.20240712",
|
|
77
|
+
]
|
|
78
|
+
linting = [
|
|
79
|
+
"ruff>=0.5.4",
|
|
80
|
+
]
|
|
81
|
+
|
|
82
|
+
[tool.pdm.scripts]
|
|
83
|
+
docs = "mkdocs serve"
|
|
84
|
+
|
|
85
|
+
[tool.mypy]
|
|
86
|
+
pretty = true
|
|
87
|
+
python_version = 3.9
|
|
88
|
+
show_column_numbers = true
|
|
89
|
+
|
|
90
|
+
[tool.ruff]
|
|
91
|
+
line-length = 120
|
|
92
|
+
target-version = "py39"
|
|
93
|
+
|
|
94
|
+
[tool.ruff.format]
|
|
95
|
+
docstring-code-format = true
|
|
96
|
+
|
|
97
|
+
[tool.ruff.lint]
|
|
98
|
+
extend-select = [
|
|
99
|
+
"Q",
|
|
100
|
+
"RUF100",
|
|
101
|
+
"C90",
|
|
102
|
+
"UP",
|
|
103
|
+
"I",
|
|
104
|
+
"D",
|
|
105
|
+
"T",
|
|
106
|
+
]
|
|
107
|
+
extend-ignore = [
|
|
108
|
+
"D105",
|
|
109
|
+
"D107",
|
|
110
|
+
"D205",
|
|
111
|
+
"D415",
|
|
112
|
+
]
|
|
113
|
+
|
|
114
|
+
[tool.ruff.lint.pydocstyle]
|
|
115
|
+
convention = "google"
|
|
116
|
+
|
|
117
|
+
[tool.ruff.lint.per-file-ignores]
|
|
118
|
+
"docs/*" = [
|
|
119
|
+
"D",
|
|
120
|
+
]
|
|
121
|
+
"tests/*" = [
|
|
122
|
+
"D",
|
|
123
|
+
]
|
|
124
|
+
"qqmusic_api/login.py" = [
|
|
125
|
+
"F405",
|
|
126
|
+
"F403",
|
|
127
|
+
"D102",
|
|
128
|
+
]
|
|
129
|
+
"qqmusic_api/__init__.py" = [
|
|
130
|
+
"F405",
|
|
131
|
+
"F403",
|
|
132
|
+
"D",
|
|
133
|
+
]
|
|
134
|
+
"qqmusic_api/**/__init__.py" = [
|
|
135
|
+
"F405",
|
|
136
|
+
"F403",
|
|
137
|
+
"D",
|
|
138
|
+
]
|
|
139
|
+
|
|
140
|
+
[tool.pytest.ini_options]
|
|
141
|
+
pythonpath = "./"
|
|
142
|
+
testpaths = [
|
|
143
|
+
"tests",
|
|
144
|
+
]
|
|
145
|
+
asyncio_mode = "auto"
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"""专辑相关 API"""
|
|
2
|
+
|
|
3
|
+
from typing import Optional
|
|
4
|
+
|
|
5
|
+
from .song import Song
|
|
6
|
+
from .utils.network import Api
|
|
7
|
+
from .utils.utils import get_api
|
|
8
|
+
|
|
9
|
+
API = get_api("album")
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class Album:
|
|
13
|
+
"""专辑类
|
|
14
|
+
|
|
15
|
+
Attributes:
|
|
16
|
+
mid: 专辑 mid
|
|
17
|
+
"""
|
|
18
|
+
|
|
19
|
+
def __init__(
|
|
20
|
+
self,
|
|
21
|
+
mid: Optional[str] = None,
|
|
22
|
+
id: Optional[int] = None,
|
|
23
|
+
):
|
|
24
|
+
"""初始化专辑类
|
|
25
|
+
|
|
26
|
+
Args:
|
|
27
|
+
mid: 专辑 mid
|
|
28
|
+
id: 专辑 id
|
|
29
|
+
"""
|
|
30
|
+
# ID 检查
|
|
31
|
+
if mid is None and id is None:
|
|
32
|
+
raise ValueError("mid or id must be provided")
|
|
33
|
+
self.mid = mid
|
|
34
|
+
self.id = id
|
|
35
|
+
|
|
36
|
+
def __repr__(self) -> str:
|
|
37
|
+
return f"Album(mid={self.mid}, id={self.id})"
|
|
38
|
+
|
|
39
|
+
async def get_detail(self) -> dict:
|
|
40
|
+
"""获取专辑详细信息
|
|
41
|
+
|
|
42
|
+
Returns:
|
|
43
|
+
专辑详细信息
|
|
44
|
+
"""
|
|
45
|
+
return await Api(**API["detail"]).update_params(albumMid=self.mid, albumId=self.id).result
|
|
46
|
+
|
|
47
|
+
async def get_song(self) -> list[Song]:
|
|
48
|
+
"""获取专辑歌曲
|
|
49
|
+
|
|
50
|
+
Returns:
|
|
51
|
+
歌曲列表
|
|
52
|
+
"""
|
|
53
|
+
result = await Api(**API["song"]).update_params(albumMid=self.mid, albumId=self.id, begin=0, num=0).result
|
|
54
|
+
return [Song.from_dict(song["songInfo"]) for song in result["songList"]]
|
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
"module": "music.musichallAlbum.AlbumInfoServer",
|
|
4
4
|
"method": "GetAlbumDetail",
|
|
5
5
|
"params": {
|
|
6
|
-
"albumMid": "str 专辑 mid"
|
|
6
|
+
"albumMid": "str 专辑 mid",
|
|
7
|
+
"albumId": "str 专辑 id"
|
|
7
8
|
},
|
|
8
9
|
"comment": "获取专辑信息"
|
|
9
10
|
},
|
|
@@ -12,6 +13,7 @@
|
|
|
12
13
|
"method": "GetAlbumSongList",
|
|
13
14
|
"params": {
|
|
14
15
|
"albumMid": "str 专辑 mid",
|
|
16
|
+
"albumId": "str 专辑 id",
|
|
15
17
|
"begin": "int 开启位置",
|
|
16
18
|
"num": "int 返回数量"
|
|
17
19
|
},
|
|
@@ -1,15 +1,16 @@
|
|
|
1
|
+
"""API 返回 code 错误"""
|
|
2
|
+
|
|
1
3
|
from typing import Optional
|
|
2
4
|
|
|
3
5
|
from .ApiException import ApiException
|
|
4
6
|
|
|
5
7
|
|
|
6
8
|
class ResponseCodeException(ApiException):
|
|
7
|
-
"""
|
|
8
|
-
API 返回 code 错误。
|
|
9
|
-
"""
|
|
9
|
+
"""API 返回 code 错误"""
|
|
10
10
|
|
|
11
11
|
def __init__(self, code: int, msg: str, raw: Optional[dict] = None):
|
|
12
|
-
"""
|
|
12
|
+
"""初始化错误类
|
|
13
|
+
|
|
13
14
|
Args:
|
|
14
15
|
code: 错误代码
|
|
15
16
|
msg: 错误信息
|