qqmusic-api-python 0.1.4__tar.gz → 0.1.6__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.
Files changed (53) hide show
  1. {qqmusic_api_python-0.1.4 → qqmusic_api_python-0.1.6}/PKG-INFO +6 -6
  2. {qqmusic_api_python-0.1.4 → qqmusic_api_python-0.1.6}/README.md +4 -3
  3. {qqmusic_api_python-0.1.4 → qqmusic_api_python-0.1.6}/pyproject.toml +9 -12
  4. {qqmusic_api_python-0.1.4 → qqmusic_api_python-0.1.6}/qqmusic_api/__init__.py +6 -4
  5. qqmusic_api_python-0.1.6/qqmusic_api/album.py +72 -0
  6. {qqmusic_api_python-0.1.4 → qqmusic_api_python-0.1.6}/qqmusic_api/data/api/album.json +3 -1
  7. {qqmusic_api_python-0.1.4 → qqmusic_api_python-0.1.6}/qqmusic_api/data/api/login.json +9 -20
  8. {qqmusic_api_python-0.1.4 → qqmusic_api_python-0.1.6}/qqmusic_api/data/api/search.json +9 -10
  9. {qqmusic_api_python-0.1.4 → qqmusic_api_python-0.1.6}/qqmusic_api/data/api/song.json +2 -1
  10. {qqmusic_api_python-0.1.4 → qqmusic_api_python-0.1.6}/qqmusic_api/login.py +98 -73
  11. {qqmusic_api_python-0.1.4 → qqmusic_api_python-0.1.6}/qqmusic_api/mv.py +2 -5
  12. {qqmusic_api_python-0.1.4 → qqmusic_api_python-0.1.6}/qqmusic_api/search.py +31 -49
  13. {qqmusic_api_python-0.1.4 → qqmusic_api_python-0.1.6}/qqmusic_api/singer.py +24 -43
  14. qqmusic_api_python-0.1.6/qqmusic_api/song.py +284 -0
  15. qqmusic_api_python-0.1.6/qqmusic_api/songlist.py +56 -0
  16. qqmusic_api_python-0.1.6/qqmusic_api/top.py +52 -0
  17. qqmusic_api_python-0.1.6/qqmusic_api/utils/credential.py +131 -0
  18. {qqmusic_api_python-0.1.4 → qqmusic_api_python-0.1.6}/qqmusic_api/utils/network.py +27 -30
  19. {qqmusic_api_python-0.1.4 → qqmusic_api_python-0.1.6}/qqmusic_api/utils/qimei.py +3 -4
  20. qqmusic_api_python-0.1.6/qqmusic_api/utils/utils.py +52 -0
  21. {qqmusic_api_python-0.1.4 → qqmusic_api_python-0.1.6}/tests/conftest.py +1 -1
  22. qqmusic_api_python-0.1.6/tests/test_qimei.py +5 -0
  23. {qqmusic_api_python-0.1.4 → qqmusic_api_python-0.1.6}/tests/test_singer.py +0 -7
  24. {qqmusic_api_python-0.1.4 → qqmusic_api_python-0.1.6}/tests/test_song.py +3 -7
  25. qqmusic_api_python-0.1.4/qqmusic_api/album.py +0 -43
  26. qqmusic_api_python-0.1.4/qqmusic_api/song.py +0 -415
  27. qqmusic_api_python-0.1.4/qqmusic_api/songlist.py +0 -85
  28. qqmusic_api_python-0.1.4/qqmusic_api/top.py +0 -105
  29. qqmusic_api_python-0.1.4/qqmusic_api/utils/credential.py +0 -89
  30. qqmusic_api_python-0.1.4/qqmusic_api/utils/utils.py +0 -130
  31. {qqmusic_api_python-0.1.4 → qqmusic_api_python-0.1.6}/LICENSE +0 -0
  32. {qqmusic_api_python-0.1.4 → qqmusic_api_python-0.1.6}/qqmusic_api/data/api/mv.json +0 -0
  33. {qqmusic_api_python-0.1.4 → qqmusic_api_python-0.1.6}/qqmusic_api/data/api/singer.json +0 -0
  34. {qqmusic_api_python-0.1.4 → qqmusic_api_python-0.1.6}/qqmusic_api/data/api/songlist.json +0 -0
  35. {qqmusic_api_python-0.1.4 → qqmusic_api_python-0.1.6}/qqmusic_api/data/api/top.json +0 -0
  36. {qqmusic_api_python-0.1.4 → qqmusic_api_python-0.1.6}/qqmusic_api/data/file_type.json +0 -0
  37. {qqmusic_api_python-0.1.4 → qqmusic_api_python-0.1.6}/qqmusic_api/data/search_type.json +0 -0
  38. {qqmusic_api_python-0.1.4 → qqmusic_api_python-0.1.6}/qqmusic_api/exceptions/ApiException.py +0 -0
  39. {qqmusic_api_python-0.1.4 → qqmusic_api_python-0.1.6}/qqmusic_api/exceptions/CredentialNoMusicidException.py +0 -0
  40. {qqmusic_api_python-0.1.4 → qqmusic_api_python-0.1.6}/qqmusic_api/exceptions/CredentialNoMusickeyException.py +0 -0
  41. {qqmusic_api_python-0.1.4 → qqmusic_api_python-0.1.6}/qqmusic_api/exceptions/CredentialNoRefreshkeyException.py +0 -0
  42. {qqmusic_api_python-0.1.4 → qqmusic_api_python-0.1.6}/qqmusic_api/exceptions/LoginException.py +0 -0
  43. {qqmusic_api_python-0.1.4 → qqmusic_api_python-0.1.6}/qqmusic_api/exceptions/ResponseCodeException.py +0 -0
  44. {qqmusic_api_python-0.1.4 → qqmusic_api_python-0.1.6}/qqmusic_api/exceptions/__init__.py +0 -0
  45. {qqmusic_api_python-0.1.4 → qqmusic_api_python-0.1.6}/qqmusic_api/utils/__init__.py +0 -0
  46. {qqmusic_api_python-0.1.4 → qqmusic_api_python-0.1.6}/qqmusic_api/utils/sync.py +0 -0
  47. {qqmusic_api_python-0.1.4 → qqmusic_api_python-0.1.6}/tests/__init__.py +0 -0
  48. {qqmusic_api_python-0.1.4 → qqmusic_api_python-0.1.6}/tests/test_album.py +0 -0
  49. {qqmusic_api_python-0.1.4 → qqmusic_api_python-0.1.6}/tests/test_login.py +0 -0
  50. {qqmusic_api_python-0.1.4 → qqmusic_api_python-0.1.6}/tests/test_mv.py +0 -0
  51. {qqmusic_api_python-0.1.4 → qqmusic_api_python-0.1.6}/tests/test_search.py +0 -0
  52. {qqmusic_api_python-0.1.4 → qqmusic_api_python-0.1.6}/tests/test_songlist.py +0 -0
  53. {qqmusic_api_python-0.1.4 → qqmusic_api_python-0.1.6}/tests/test_top.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: qqmusic-api-python
3
- Version: 0.1.4
3
+ Version: 0.1.6
4
4
  Summary: QQ音乐API封装库
5
5
  Keywords: music,api,qqmusic,tencentmusic
6
6
  Home-page: https://github.com/luren-dc/QQMusicApi
@@ -22,9 +22,8 @@ Project-URL: Repository, https://github.com/luren-dc/QQMusicApi
22
22
  Project-URL: Documentation, https://github.com/luren-dc/QQMusicApi
23
23
  Requires-Python: <4.0,>=3.9
24
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
25
  Requires-Dist: typing-extensions>=4.12.2
26
+ Requires-Dist: httpx>=0.27.0
28
27
  Description-Content-Type: text/markdown
29
28
 
30
29
  <div align="center">
@@ -39,7 +38,7 @@ Description-Content-Type: text/markdown
39
38
  <a href="https://pdm-project.org">
40
39
  <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
40
  </a>
42
- <a href="https://github.com/luren-dc/QQMusicApi/tree/build?tab=License-1-ov-file">
41
+ <a href="https://github.com/luren-dc/QQMusicApi?tab=MIT-1-ov-file">
43
42
  <img src="https://img.shields.io/github/license/luren-dc/PyQQMusicApi" alt="GitHub license">
44
43
  </a>
45
44
  <a href="https://github.com/luren-dc/QQMusicApi/stargazers">
@@ -71,9 +70,10 @@ Description-Content-Type: text/markdown
71
70
 
72
71
  ## 依赖
73
72
 
74
- - [AIOHTTP](https://docs.aiohttp.org/)
75
- - [Requests](https://requests.readthedocs.io/)
73
+ - ~~[AIOHTTP](https://docs.aiohttp.org/)~~
74
+ - ~~[Requests](https://requests.readthedocs.io/)~~
76
75
  - [Cryptography](https://cryptography.io/)
76
+ - [HTTPX](https://github.com/encode/httpx/)
77
77
 
78
78
  ## 快速上手
79
79
 
@@ -10,7 +10,7 @@
10
10
  <a href="https://pdm-project.org">
11
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
12
  </a>
13
- <a href="https://github.com/luren-dc/QQMusicApi/tree/build?tab=License-1-ov-file">
13
+ <a href="https://github.com/luren-dc/QQMusicApi?tab=MIT-1-ov-file">
14
14
  <img src="https://img.shields.io/github/license/luren-dc/PyQQMusicApi" alt="GitHub license">
15
15
  </a>
16
16
  <a href="https://github.com/luren-dc/QQMusicApi/stargazers">
@@ -42,9 +42,10 @@
42
42
 
43
43
  ## 依赖
44
44
 
45
- - [AIOHTTP](https://docs.aiohttp.org/)
46
- - [Requests](https://requests.readthedocs.io/)
45
+ - ~~[AIOHTTP](https://docs.aiohttp.org/)~~
46
+ - ~~[Requests](https://requests.readthedocs.io/)~~
47
47
  - [Cryptography](https://cryptography.io/)
48
+ - [HTTPX](https://github.com/encode/httpx/)
48
49
 
49
50
  ## 快速上手
50
51
 
@@ -12,9 +12,8 @@ authors = [
12
12
  ]
13
13
  dependencies = [
14
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
15
  "typing-extensions>=4.12.2",
16
+ "httpx>=0.27.0",
18
17
  ]
19
18
  requires-python = "<4.0,>=3.9"
20
19
  readme = "README.md"
@@ -40,7 +39,7 @@ classifiers = [
40
39
  "Topic :: Software Development :: Libraries :: Python Modules",
41
40
  ]
42
41
  dynamic = []
43
- version = "0.1.4"
42
+ version = "0.1.6"
44
43
 
45
44
  [project.license]
46
45
  text = "MIT"
@@ -73,20 +72,11 @@ docs = [
73
72
  ]
74
73
  mypy = [
75
74
  "mypy>=1.11.0",
76
- "types-requests>=2.32.0.20240712",
77
75
  ]
78
76
  linting = [
79
77
  "ruff>=0.5.4",
80
78
  ]
81
79
 
82
- [tool.pdm.build]
83
- source-includes = [
84
- "qqmusic_api",
85
- "README.md",
86
- "LICENSE",
87
- "tests",
88
- ]
89
-
90
80
  [tool.pdm.scripts]
91
81
  docs = "mkdocs serve"
92
82
 
@@ -129,6 +119,13 @@ convention = "google"
129
119
  "tests/*" = [
130
120
  "D",
131
121
  ]
122
+ "examples/*" = [
123
+ "D",
124
+ "T",
125
+ ]
126
+ "qqmusic_api/login.py" = [
127
+ "D102",
128
+ ]
132
129
  "qqmusic_api/__init__.py" = [
133
130
  "F405",
134
131
  "F403",
@@ -1,19 +1,21 @@
1
1
  from . import album, login, mv, search, singer, song, songlist, top
2
2
  from .utils.credential import Credential
3
- from .utils.network import get_aiohttp_session, set_aiohttp_session
3
+ from .utils.network import get_session, set_session
4
+ from .utils.sync import sync
4
5
 
5
- __version__ = "0.1.4"
6
+ __version__ = "0.1.6"
6
7
 
7
8
  __all__ = [
8
9
  "album",
9
10
  "Credential",
10
- "get_aiohttp_session",
11
+ "get_session",
11
12
  "login",
12
13
  "mv",
13
14
  "search",
14
- "set_aiohttp_session",
15
+ "set_session",
15
16
  "singer",
16
17
  "song",
17
18
  "songlist",
19
+ "sync",
18
20
  "top",
19
21
  ]
@@ -0,0 +1,72 @@
1
+ """专辑相关 API"""
2
+
3
+ from typing import Optional
4
+
5
+ from .utils.network import Api
6
+ from .utils.utils import get_api
7
+
8
+ API = get_api("album")
9
+
10
+
11
+ class Album:
12
+ """专辑类
13
+
14
+ Attributes:
15
+ mid: 专辑 mid
16
+ id: 专辑 id
17
+ """
18
+
19
+ def __init__(
20
+ self,
21
+ *,
22
+ mid: Optional[str] = None,
23
+ id: Optional[int] = None,
24
+ ):
25
+ """/// admonition | 注意
26
+ 歌曲 mid 和 id,两者至少提供一个
27
+ ///
28
+
29
+ Args:
30
+ mid: 专辑 mid
31
+ id: 专辑 id
32
+ """
33
+ if mid is None and id is None:
34
+ raise ValueError("mid or id must be provided")
35
+ self.mid = mid
36
+ self.id = id
37
+ self._info: Optional[dict] = None
38
+
39
+ async def get_mid(self) -> str:
40
+ """获取专辑 mid
41
+
42
+ Returns:
43
+ 专辑 mid
44
+ """
45
+ return (await self.get_detail())["basicInfo"]["albumMid"]
46
+
47
+ async def get_id(self) -> int:
48
+ """获取专辑 id
49
+
50
+ Returns:
51
+ 专辑 id
52
+ """
53
+ return (await self.get_detail())["basicInfo"]["albumID"]
54
+
55
+ async def get_detail(self) -> dict:
56
+ """获取专辑详细信息
57
+
58
+ Returns:
59
+ 专辑详细信息
60
+ """
61
+ if not self._info:
62
+ self._info = await Api(**API["detail"]).update_params(albumMid=self.mid, albumId=self.id).result
63
+ return self._info
64
+
65
+ async def get_song(self) -> list[dict]:
66
+ """获取专辑歌曲
67
+
68
+ Returns:
69
+ 歌曲列表
70
+ """
71
+ result = await Api(**API["song"]).update_params(albumMid=self.mid, albumId=self.id, begin=0, num=0).result
72
+ return [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
  },
@@ -3,7 +3,10 @@
3
3
  "module": "QQConnectLogin.LoginServer",
4
4
  "method": "QQLogin",
5
5
  "params": {
6
- "code": "str 鉴权码"
6
+ "code": "str 鉴权码",
7
+ "musicid": "int",
8
+ "musickey": "str",
9
+ "refresh_key": "str"
7
10
  },
8
11
  "extra_common": {
9
12
  "tmeLoginType": "str 2"
@@ -15,7 +18,11 @@
15
18
  "method": "Login",
16
19
  "params": {
17
20
  "strAppid": "wx48db31d50e334801",
18
- "code": "str 鉴权码"
21
+ "code": "str 鉴权码",
22
+ "str_musicid": "str",
23
+ "musickey": "str",
24
+ "refresh_key": "str",
25
+ "loginMode": "int 2"
19
26
  },
20
27
  "extra_common": {
21
28
  "tmeLoginType": "str 1"
@@ -47,23 +54,5 @@
47
54
  "tmeLoginMethod": "str 3"
48
55
  },
49
56
  "comment": "发送验证码"
50
- },
51
- "refresh": {
52
- "module": "music.login.LoginServer",
53
- "method": "Login",
54
- "params": {
55
- "openid": "str",
56
- "access_token": "str",
57
- "refresh_token": "str",
58
- "expired_in": "int",
59
- "musicid": "str 必须",
60
- "musickey": "str",
61
- "refresh_key": "str 必须",
62
- "loginMode": "int 2"
63
- },
64
- "extra_common": {
65
- "tmeLoginMethod": "str 可填2"
66
- },
67
- "comment": "刷新cookies"
68
57
  }
69
58
  }
@@ -11,10 +11,10 @@
11
11
  "module": "tencent_music_soso_smartbox_cgi.SmartBoxCgi",
12
12
  "method": "GetSmartBoxResult",
13
13
  "params": {
14
+ "search_id": "int 随机生成",
14
15
  "query": "str 搜索词",
15
16
  "num_per_page": "int 每页返回数量",
16
- "highlight": "int 是否高亮搜索词",
17
- "page_idx": "int 页数"
17
+ "page_idx": "int 1"
18
18
  },
19
19
  "comment": "获取搜索词补全"
20
20
  },
@@ -30,12 +30,13 @@
30
30
  "module": "music.adaptor.SearchAdaptor",
31
31
  "method": "do_search_v2",
32
32
  "params": {
33
- "search_id": "int 随机生成",
33
+ "searchid": "int 随机生成",
34
34
  "search_type": "int 100",
35
35
  "query": "str 搜索词",
36
- "highlight": "int 是否高亮搜索词",
37
36
  "grp": "int 是否返回歌曲其他版本",
38
- "page_id": "int 页数"
37
+ "highlight": "int 是否高亮搜索词",
38
+ "page_id": "int 页数",
39
+ "page_num": "int 15"
39
40
  },
40
41
  "comment": "综合搜索"
41
42
  },
@@ -46,10 +47,9 @@
46
47
  "search_id": "int 随机生成",
47
48
  "search_type": "int 搜索类型",
48
49
  "query": "str 搜索词",
49
- "highlight": "int 是否高亮搜索词",
50
- "page_id": "int 页数",
51
50
  "page_num": "int 页数",
52
51
  "num_per_page": "int 每页返回数量",
52
+ "highlight": "int 是否高亮搜索词",
53
53
  "selectors": "dict 选择器"
54
54
  },
55
55
  "comment": "桌面端搜索"
@@ -58,13 +58,12 @@
58
58
  "module": "music.search.SearchCgiService",
59
59
  "method": "DoSearchForQQMusicMobile",
60
60
  "params": {
61
- "search_id": "int 随机生成",
61
+ "searchid": "int 随机生成",
62
62
  "search_type": "int 搜索类型",
63
63
  "query": "str 搜索词",
64
- "highlight": "int 是否高亮搜索词",
65
- "page_id": "int 页数",
66
64
  "page_num": "int 页数",
67
65
  "grp": "int 是否返回歌曲其他版本",
66
+ "highlight": "int 是否高亮搜索词",
68
67
  "num_per_page": "int 每页返回数量",
69
68
  "selectors": "dict 选择器"
70
69
  },
@@ -50,7 +50,8 @@
50
50
  "method": "GetSongRelatedMv",
51
51
  "params": {
52
52
  "songid": "int 歌曲 ID",
53
- "songmid": "str 歌曲 mid"
53
+ "songtype": "int 1",
54
+ "lastmvid": "用于刷新列表"
54
55
  },
55
56
  "comment": "获取相关MV"
56
57
  },