qqmusic-api-python 0.3.3__tar.gz → 0.3.4__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 (41) hide show
  1. {qqmusic_api_python-0.3.3 → qqmusic_api_python-0.3.4}/PKG-INFO +2 -6
  2. {qqmusic_api_python-0.3.3 → qqmusic_api_python-0.3.4}/README.md +1 -5
  3. {qqmusic_api_python-0.3.3 → qqmusic_api_python-0.3.4}/qqmusic_api/__init__.py +1 -1
  4. {qqmusic_api_python-0.3.3 → qqmusic_api_python-0.3.4}/qqmusic_api/song.py +4 -1
  5. {qqmusic_api_python-0.3.3 → qqmusic_api_python-0.3.4}/qqmusic_api/songlist.py +4 -4
  6. {qqmusic_api_python-0.3.3 → qqmusic_api_python-0.3.4}/qqmusic_api/user.py +1 -1
  7. {qqmusic_api_python-0.3.3 → qqmusic_api_python-0.3.4}/qqmusic_api/utils/credential.py +2 -4
  8. qqmusic_api_python-0.3.4/web/README.md +46 -0
  9. {qqmusic_api_python-0.3.3 → qqmusic_api_python-0.3.4}/.gitignore +0 -0
  10. {qqmusic_api_python-0.3.3 → qqmusic_api_python-0.3.4}/LICENSE +0 -0
  11. {qqmusic_api_python-0.3.3 → qqmusic_api_python-0.3.4}/pyproject.toml +0 -0
  12. {qqmusic_api_python-0.3.3 → qqmusic_api_python-0.3.4}/qqmusic_api/album.py +0 -0
  13. {qqmusic_api_python-0.3.3 → qqmusic_api_python-0.3.4}/qqmusic_api/exceptions/__init__.py +0 -0
  14. {qqmusic_api_python-0.3.3 → qqmusic_api_python-0.3.4}/qqmusic_api/exceptions/api_exception.py +0 -0
  15. {qqmusic_api_python-0.3.3 → qqmusic_api_python-0.3.4}/qqmusic_api/login.py +0 -0
  16. {qqmusic_api_python-0.3.3 → qqmusic_api_python-0.3.4}/qqmusic_api/lyric.py +0 -0
  17. {qqmusic_api_python-0.3.3 → qqmusic_api_python-0.3.4}/qqmusic_api/mv.py +0 -0
  18. {qqmusic_api_python-0.3.3 → qqmusic_api_python-0.3.4}/qqmusic_api/search.py +0 -0
  19. {qqmusic_api_python-0.3.3 → qqmusic_api_python-0.3.4}/qqmusic_api/singer.py +0 -0
  20. {qqmusic_api_python-0.3.3 → qqmusic_api_python-0.3.4}/qqmusic_api/top.py +0 -0
  21. {qqmusic_api_python-0.3.3 → qqmusic_api_python-0.3.4}/qqmusic_api/utils/__init__.py +0 -0
  22. {qqmusic_api_python-0.3.3 → qqmusic_api_python-0.3.4}/qqmusic_api/utils/common.py +0 -0
  23. {qqmusic_api_python-0.3.3 → qqmusic_api_python-0.3.4}/qqmusic_api/utils/device.py +0 -0
  24. {qqmusic_api_python-0.3.3 → qqmusic_api_python-0.3.4}/qqmusic_api/utils/network.py +0 -0
  25. {qqmusic_api_python-0.3.3 → qqmusic_api_python-0.3.4}/qqmusic_api/utils/qimei.py +0 -0
  26. {qqmusic_api_python-0.3.3 → qqmusic_api_python-0.3.4}/qqmusic_api/utils/session.py +0 -0
  27. {qqmusic_api_python-0.3.3 → qqmusic_api_python-0.3.4}/qqmusic_api/utils/sign.py +0 -0
  28. {qqmusic_api_python-0.3.3 → qqmusic_api_python-0.3.4}/qqmusic_api/utils/tripledes.py +0 -0
  29. {qqmusic_api_python-0.3.3 → qqmusic_api_python-0.3.4}/tests/test_album.py +0 -0
  30. {qqmusic_api_python-0.3.3 → qqmusic_api_python-0.3.4}/tests/test_login.py +0 -0
  31. {qqmusic_api_python-0.3.3 → qqmusic_api_python-0.3.4}/tests/test_lyric.py +0 -0
  32. {qqmusic_api_python-0.3.3 → qqmusic_api_python-0.3.4}/tests/test_mv.py +0 -0
  33. {qqmusic_api_python-0.3.3 → qqmusic_api_python-0.3.4}/tests/test_qimei.py +0 -0
  34. {qqmusic_api_python-0.3.3 → qqmusic_api_python-0.3.4}/tests/test_search.py +0 -0
  35. {qqmusic_api_python-0.3.3 → qqmusic_api_python-0.3.4}/tests/test_session.py +0 -0
  36. {qqmusic_api_python-0.3.3 → qqmusic_api_python-0.3.4}/tests/test_sign.py +0 -0
  37. {qqmusic_api_python-0.3.3 → qqmusic_api_python-0.3.4}/tests/test_singer.py +0 -0
  38. {qqmusic_api_python-0.3.3 → qqmusic_api_python-0.3.4}/tests/test_song.py +0 -0
  39. {qqmusic_api_python-0.3.3 → qqmusic_api_python-0.3.4}/tests/test_songlist.py +0 -0
  40. {qqmusic_api_python-0.3.3 → qqmusic_api_python-0.3.4}/tests/test_top.py +0 -0
  41. {qqmusic_api_python-0.3.3 → qqmusic_api_python-0.3.4}/tests/test_user.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: qqmusic-api-python
3
- Version: 0.3.3
3
+ Version: 0.3.4
4
4
  Summary: QQ音乐API封装库
5
5
  Project-URL: homepage, https://luren-dc.github.io/QQMusicApi/
6
6
  Project-URL: repository, https://github.com/luren-dc/QQMusicApi
@@ -98,11 +98,7 @@ async def main():
98
98
  asyncio.run(main())
99
99
  ```
100
100
 
101
- ## Web API
102
- ```
103
- docker build . -t qq-music-api
104
- docker run -d -p 8000:8000 qq-music-api
105
- ```
101
+ ## [Web API](./web/README.md)
106
102
 
107
103
  ## Licence
108
104
 
@@ -68,11 +68,7 @@ async def main():
68
68
  asyncio.run(main())
69
69
  ```
70
70
 
71
- ## Web API
72
- ```
73
- docker build . -t qq-music-api
74
- docker run -d -p 8000:8000 qq-music-api
75
- ```
71
+ ## [Web API](./web/README.md)
76
72
 
77
73
  ## Licence
78
74
 
@@ -4,7 +4,7 @@ from . import album, login, lyric, mv, search, singer, song, songlist, top, user
4
4
  from .utils.credential import Credential
5
5
  from .utils.session import Session, get_session, set_session
6
6
 
7
- __version__ = "0.3.3"
7
+ __version__ = "0.3.4"
8
8
 
9
9
  logger = logging.getLogger("qqmusicapi")
10
10
 
@@ -16,7 +16,7 @@ def _get_extract_func(key: str):
16
16
 
17
17
 
18
18
  @api_request("music.trackInfo.UniformRuleCtrl", "CgiGetTrackInfo")
19
- async def query_song(value: list[str] | list[int]):
19
+ async def query_song(value: list[int] | list[str]):
20
20
  """根据 id 或 mid 获取歌曲信息
21
21
 
22
22
  Args:
@@ -114,6 +114,7 @@ class EncryptedSongFileType(BaseSongFileType):
114
114
  async def get_song_urls(
115
115
  mid: list[str],
116
116
  file_type: SongFileType = SongFileType.MP3_128,
117
+ *,
117
118
  credential: Credential | None = None,
118
119
  ) -> dict[str, str]: ...
119
120
 
@@ -122,6 +123,7 @@ async def get_song_urls(
122
123
  async def get_song_urls(
123
124
  mid: list[str],
124
125
  file_type: EncryptedSongFileType,
126
+ *,
125
127
  credential: Credential | None = None,
126
128
  ) -> dict[str, tuple[str, str]]: ...
127
129
 
@@ -129,6 +131,7 @@ async def get_song_urls(
129
131
  async def get_song_urls(
130
132
  mid: list[str],
131
133
  file_type: SongFileType | EncryptedSongFileType = SongFileType.MP3_128,
134
+ *,
132
135
  credential: Credential | None = None,
133
136
  ) -> dict[str, str] | dict[str, tuple[str, str]]:
134
137
  """获取歌曲文件链接
@@ -79,7 +79,7 @@ async def get_songlist(
79
79
 
80
80
 
81
81
  @api_request("music.musicasset.PlaylistBaseWrite", "AddPlaylist", verify=True, cacheable=False)
82
- async def create(dirname: str, credential: Credential | None = None):
82
+ async def create(dirname: str, *, credential: Credential | None = None):
83
83
  """添加歌单, 重名会在名称后面添加时间戳
84
84
 
85
85
  Args:
@@ -95,7 +95,7 @@ async def create(dirname: str, credential: Credential | None = None):
95
95
 
96
96
 
97
97
  @api_request("music.musicasset.PlaylistBaseWrite", "DelPlaylist", verify=True, cacheable=False)
98
- async def delete(dirid: int, credential: Credential | None = None):
98
+ async def delete(dirid: int, *, credential: Credential | None = None):
99
99
  """删除歌单
100
100
 
101
101
  Args:
@@ -111,7 +111,7 @@ async def delete(dirid: int, credential: Credential | None = None):
111
111
 
112
112
 
113
113
  @api_request("music.musicasset.PlaylistDetailWrite", "AddSonglist", verify=True, cacheable=False)
114
- async def add_songs(dirid: int = 1, song_ids: list[int] = [], credential: Credential | None = None):
114
+ async def add_songs(dirid: int = 1, song_ids: list[int] = [], *, credential: Credential | None = None):
115
115
  """添加歌曲到歌单
116
116
 
117
117
  Args:
@@ -129,7 +129,7 @@ async def add_songs(dirid: int = 1, song_ids: list[int] = [], credential: Creden
129
129
 
130
130
 
131
131
  @api_request("music.musicasset.PlaylistDetailWrite", "DelSonglist", verify=True, cacheable=False)
132
- async def del_songs(dirid: int = 1, song_ids: list[int] = [], credential: Credential | None = None):
132
+ async def del_songs(dirid: int = 1, song_ids: list[int] = [], *, credential: Credential | None = None):
133
133
  """删除歌单歌曲
134
134
 
135
135
  Args:
@@ -93,7 +93,7 @@ async def get_friend(page: int = 1, num: int = 10, *, credential: Credential | N
93
93
  return {
94
94
  "PageSize": num,
95
95
  "Page": page - 1,
96
- }, lambda data: {"total": data.get("Total", 0), "list": data.get("List", [])}
96
+ }, lambda data: {"total": len(data.get("Friends", [])), "list": data.get("Friends", [])}
97
97
 
98
98
 
99
99
  @api_request("music.concern.RelationList", "GetFollowUserList", verify=True, cacheable=False)
@@ -84,16 +84,14 @@ class Credential:
84
84
  if not self.has_musicid() or not self.has_musickey():
85
85
  return False
86
86
  if await self.is_expired():
87
- return bool(self.refresh_key) and bool(self.refresh_token)
87
+ return bool(self.refresh_key)
88
88
  return True
89
89
 
90
90
  async def is_expired(self) -> bool:
91
91
  """判断 credential 是否过期"""
92
92
  if "musickeyCreateTime" in self.extra_fields and "keyExpiresIn" in self.extra_fields:
93
93
  expired_time_stamp = self.extra_fields["musickeyCreateTime"] + self.extra_fields["keyExpiresIn"]
94
- if expired_time_stamp >= time():
95
- return True
96
- return False
94
+ return expired_time_stamp <= time()
97
95
 
98
96
  from ..login import check_expired
99
97
 
@@ -0,0 +1,46 @@
1
+ # Web Port 使用说明
2
+
3
+ ## 1. 安装与运行
4
+
5
+ ### 克隆仓库
6
+
7
+ ```bash
8
+ git clone https://github.com/luren-dc/QQMusicApi
9
+ ```
10
+
11
+ ### 依赖安装
12
+
13
+ ```bash
14
+ uv sync --group web
15
+ ```
16
+
17
+ ### 启动服务
18
+
19
+ ```bash
20
+ uv run uvicorn web.app:app --host 0.0.0.0 --port 8000 --reload
21
+ ```
22
+
23
+ ### Docker
24
+
25
+ ```bash
26
+ docker build . -t qq-music-api
27
+ docker run -d -p 8000:8000 qq-music-api
28
+ ```
29
+
30
+ ## 2. API Endpoint
31
+
32
+ - **请求格式**: `GET /{module}/{func}`
33
+ - **示例**:
34
+ `GET /song/get_detail?id=12345`
35
+
36
+ ## 3. 请求参数规则
37
+
38
+ ### 类型转换规则
39
+
40
+ | 参数类型 | 示例值 | 说明 |
41
+ | ----------- | ------------------------------- | ------------------------------------ |
42
+ | `int` | `count=5` | 整数 |
43
+ | `bool` | `is_vip=true` | `true`/`1`/`yes` 或 `false`/`0`/`no` |
44
+ | `datetime` | `date=2023-10-01T12:34` | ISO 8601 格式 |
45
+ | `list[int]` | `id=1,2,3` | 逗号分隔的字符串 |
46
+ | `Enum` | `type=SongType.HIT`or`type=HIT` | 枚举名或值(见具体模块定义) |