qqmusic-api-python 0.1.0__py3-none-any.whl
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/__init__.py +4 -0
- qqmusic_api/api/album.py +40 -0
- qqmusic_api/api/login.py +437 -0
- qqmusic_api/api/mv.py +115 -0
- qqmusic_api/api/search.py +168 -0
- qqmusic_api/api/song.py +389 -0
- qqmusic_api/api/songlist.py +81 -0
- qqmusic_api/api/top.py +98 -0
- qqmusic_api/data/api/album.json +20 -0
- qqmusic_api/data/api/login.json +69 -0
- qqmusic_api/data/api/mv.json +26 -0
- qqmusic_api/data/api/search.json +73 -0
- qqmusic_api/data/api/singer.json +1 -0
- qqmusic_api/data/api/song.json +105 -0
- qqmusic_api/data/api/songlist.json +17 -0
- qqmusic_api/data/api/top.json +20 -0
- qqmusic_api/data/file_type.json +50 -0
- qqmusic_api/data/search_type.json +11 -0
- qqmusic_api/exceptions.py +121 -0
- qqmusic_api/settings.py +22 -0
- qqmusic_api/utils/__init__.py +0 -0
- qqmusic_api/utils/common.py +140 -0
- qqmusic_api/utils/credential.py +92 -0
- qqmusic_api/utils/network.py +249 -0
- qqmusic_api/utils/qimei.py +267 -0
- qqmusic_api_python-0.1.0.dist-info/LICENSE +21 -0
- qqmusic_api_python-0.1.0.dist-info/METADATA +99 -0
- qqmusic_api_python-0.1.0.dist-info/RECORD +29 -0
- qqmusic_api_python-0.1.0.dist-info/WHEEL +4 -0
qqmusic_api/api/top.py
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
from qqmusic_api.api.song import Song
|
|
2
|
+
from qqmusic_api.utils.network import Api
|
|
3
|
+
from ..utils.common import get_api
|
|
4
|
+
import datetime
|
|
5
|
+
|
|
6
|
+
API = get_api("top")
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
async def get_top_category(show_detail: bool = False) -> list[dict]:
|
|
10
|
+
"""
|
|
11
|
+
获取所有排行榜
|
|
12
|
+
|
|
13
|
+
Args:
|
|
14
|
+
show_detail: 是否显示详情(包括介绍,前三歌曲). Defaults to False
|
|
15
|
+
|
|
16
|
+
Returns:
|
|
17
|
+
list: 排行榜信息
|
|
18
|
+
"""
|
|
19
|
+
result = await Api(**API["category"]).result
|
|
20
|
+
return [
|
|
21
|
+
{
|
|
22
|
+
"groupId": group["groupId"],
|
|
23
|
+
"groupTitle": group["groupName"],
|
|
24
|
+
"topList": [
|
|
25
|
+
{
|
|
26
|
+
"id": top["topId"],
|
|
27
|
+
"title": top["title"],
|
|
28
|
+
"intro": top["intro"] if show_detail else None,
|
|
29
|
+
"period": top["period"],
|
|
30
|
+
"updateTime": top["updateTime"],
|
|
31
|
+
"listenNum": top["listenNum"],
|
|
32
|
+
"picUrl": top["headPicUrl"],
|
|
33
|
+
"song": top["song"] if show_detail else None,
|
|
34
|
+
}
|
|
35
|
+
for top in group["toplist"]
|
|
36
|
+
],
|
|
37
|
+
}
|
|
38
|
+
for group in result["group"]
|
|
39
|
+
]
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
class Top:
|
|
43
|
+
"""排行榜类"""
|
|
44
|
+
|
|
45
|
+
def __init__(self, id: int, period: str = "") -> None:
|
|
46
|
+
"""
|
|
47
|
+
Args:
|
|
48
|
+
id: 排行榜 ID
|
|
49
|
+
period: 排行榜周期
|
|
50
|
+
"""
|
|
51
|
+
self.id = id
|
|
52
|
+
self.set_period(period)
|
|
53
|
+
|
|
54
|
+
def set_period(self, period: str):
|
|
55
|
+
"""
|
|
56
|
+
设置排行榜周期
|
|
57
|
+
|
|
58
|
+
Args:
|
|
59
|
+
year: 年
|
|
60
|
+
week: 周
|
|
61
|
+
"""
|
|
62
|
+
time_type = "%Y-%m-%d" if self.id in [4, 27, 62] else "'%Y_%W"
|
|
63
|
+
self.period = period or datetime.datetime.strftime(
|
|
64
|
+
datetime.datetime.now(), time_type
|
|
65
|
+
)
|
|
66
|
+
|
|
67
|
+
async def get_detail(self):
|
|
68
|
+
"""
|
|
69
|
+
获取排行榜详细信息
|
|
70
|
+
|
|
71
|
+
Returns:
|
|
72
|
+
dict: 排行榜信息
|
|
73
|
+
"""
|
|
74
|
+
param = {"topId": self.id, "period": self.period}
|
|
75
|
+
result = await Api(**API["detail"]).update_params(**param).result
|
|
76
|
+
data = result["data"]
|
|
77
|
+
return {
|
|
78
|
+
"id": data["topId"],
|
|
79
|
+
"title": data["title"],
|
|
80
|
+
"subTitle": data["titleSub"],
|
|
81
|
+
"titleDetail": data["titleDetail"],
|
|
82
|
+
"desc": data["intro"],
|
|
83
|
+
"listenNum": data["listenNum"],
|
|
84
|
+
"total": data["totalNum"],
|
|
85
|
+
"updateTime": data["updateTime"],
|
|
86
|
+
"period": self.period,
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
async def get_song(self) -> list[Song]:
|
|
90
|
+
"""
|
|
91
|
+
获取排行榜歌曲
|
|
92
|
+
|
|
93
|
+
Returns:
|
|
94
|
+
list: 排行榜歌曲
|
|
95
|
+
"""
|
|
96
|
+
param = {"topId": self.id, "period": self.period, "offset": 0, "num": 100}
|
|
97
|
+
result = await Api(**API["detail"]).update_params(**param).result
|
|
98
|
+
return [Song.from_dict(song) for song in result["songInfoList"]]
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"detail": {
|
|
3
|
+
"module": "music.musichallAlbum.AlbumInfoServer",
|
|
4
|
+
"method": "GetAlbumDetail",
|
|
5
|
+
"params": {
|
|
6
|
+
"albumMid": "str 专辑 mid"
|
|
7
|
+
},
|
|
8
|
+
"comment": "获取专辑信息"
|
|
9
|
+
},
|
|
10
|
+
"song": {
|
|
11
|
+
"module": "music.musichallAlbum.AlbumSongList",
|
|
12
|
+
"method": "GetAlbumSongList",
|
|
13
|
+
"params": {
|
|
14
|
+
"albumMid": "str 专辑 mid",
|
|
15
|
+
"begin": "int 开启位置",
|
|
16
|
+
"num": "int 返回数量"
|
|
17
|
+
},
|
|
18
|
+
"comment": "获取专辑歌曲"
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
{
|
|
2
|
+
"QQ_login": {
|
|
3
|
+
"module": "QQConnectLogin.LoginServer",
|
|
4
|
+
"method": "QQLogin",
|
|
5
|
+
"params": {
|
|
6
|
+
"code": "str 鉴权码"
|
|
7
|
+
},
|
|
8
|
+
"extra_common": {
|
|
9
|
+
"tmeLoginType": "str 2"
|
|
10
|
+
},
|
|
11
|
+
"comment": "QQ 鉴权"
|
|
12
|
+
},
|
|
13
|
+
"WX_login": {
|
|
14
|
+
"module": "music.login.LoginServer",
|
|
15
|
+
"method": "Login",
|
|
16
|
+
"params": {
|
|
17
|
+
"strAppid": "wx48db31d50e334801",
|
|
18
|
+
"code": "str 鉴权码"
|
|
19
|
+
},
|
|
20
|
+
"extra_common": {
|
|
21
|
+
"tmeLoginType": "str 1"
|
|
22
|
+
},
|
|
23
|
+
"comment": "微信鉴权"
|
|
24
|
+
},
|
|
25
|
+
"send_authcode": {
|
|
26
|
+
"module": "music.login.LoginServer",
|
|
27
|
+
"method": "SendPhoneAuthCode",
|
|
28
|
+
"params": {
|
|
29
|
+
"tmeAppid": "qqmusic",
|
|
30
|
+
"phoneNo": "str 手机号",
|
|
31
|
+
"areaCode": "int 地区码(86)"
|
|
32
|
+
},
|
|
33
|
+
"extra_common": {
|
|
34
|
+
"tmeLoginMethod": "str 3"
|
|
35
|
+
},
|
|
36
|
+
"comment": "发送验证码"
|
|
37
|
+
},
|
|
38
|
+
"phone_login": {
|
|
39
|
+
"module": "music.login.LoginServer",
|
|
40
|
+
"method": "Login",
|
|
41
|
+
"params": {
|
|
42
|
+
"code": "str 验证码",
|
|
43
|
+
"phoneNo": "str 手机号",
|
|
44
|
+
"loginMode": "int 1"
|
|
45
|
+
},
|
|
46
|
+
"extra_common": {
|
|
47
|
+
"tmeLoginMethod": "str 3"
|
|
48
|
+
},
|
|
49
|
+
"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
|
+
}
|
|
69
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"detail": {
|
|
3
|
+
"module": "video.VideoDataServer",
|
|
4
|
+
"method": "get_video_info_batch",
|
|
5
|
+
"params": {
|
|
6
|
+
"vidlist": "list vid 列表",
|
|
7
|
+
"required": "list 查询字段"
|
|
8
|
+
},
|
|
9
|
+
"comment": "获取 MV 信息"
|
|
10
|
+
},
|
|
11
|
+
"url": {
|
|
12
|
+
"module": "music.stream.MvUrlProxy",
|
|
13
|
+
"method": "GetMvUrls",
|
|
14
|
+
"params": {
|
|
15
|
+
"vids": "list vid 列表",
|
|
16
|
+
"request_type": "int 10003",
|
|
17
|
+
"guid": "str 随机32位字符串",
|
|
18
|
+
"videoformat": "int 1",
|
|
19
|
+
"format": "int 265",
|
|
20
|
+
"dolby": "int 1",
|
|
21
|
+
"use_new_domain": "int 1",
|
|
22
|
+
"use_ipv6": "int 1"
|
|
23
|
+
},
|
|
24
|
+
"comment": "获取 MV 播放地址"
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
{
|
|
2
|
+
"hotkey": {
|
|
3
|
+
"module": "music.musicsearch.HotkeyService",
|
|
4
|
+
"method": "GetHotkeyForQQMusicMobile",
|
|
5
|
+
"params": {
|
|
6
|
+
"search_id": "int 随机生成"
|
|
7
|
+
},
|
|
8
|
+
"comment": "获取热搜词"
|
|
9
|
+
},
|
|
10
|
+
"complete": {
|
|
11
|
+
"module": "tencent_music_soso_smartbox_cgi.SmartBoxCgi",
|
|
12
|
+
"method": "GetSmartBoxResult",
|
|
13
|
+
"params": {
|
|
14
|
+
"query": "str 搜索词",
|
|
15
|
+
"num_per_page": "int 每页返回数量",
|
|
16
|
+
"highlight": "int 是否高亮搜索词",
|
|
17
|
+
"page_idx": "int 页数"
|
|
18
|
+
},
|
|
19
|
+
"comment": "获取搜索词补全"
|
|
20
|
+
},
|
|
21
|
+
"quick_search": {
|
|
22
|
+
"url": "https://c.y.qq.com/splcloud/fcgi-bin/smartbox_new.fcg",
|
|
23
|
+
"method": "GET",
|
|
24
|
+
"params": {
|
|
25
|
+
"key": "str 搜索词"
|
|
26
|
+
},
|
|
27
|
+
"comment": "桌面端快速搜索"
|
|
28
|
+
},
|
|
29
|
+
"general_search": {
|
|
30
|
+
"module": "music.adaptor.SearchAdaptor",
|
|
31
|
+
"method": "do_search_v2",
|
|
32
|
+
"params": {
|
|
33
|
+
"search_id": "int 随机生成",
|
|
34
|
+
"search_type": "int 100",
|
|
35
|
+
"query": "str 搜索词",
|
|
36
|
+
"highlight": "int 是否高亮搜索词",
|
|
37
|
+
"grp": "int 是否返回歌曲其他版本",
|
|
38
|
+
"page_id": "int 页数"
|
|
39
|
+
},
|
|
40
|
+
"comment": "综合搜索"
|
|
41
|
+
},
|
|
42
|
+
"desktop_search_by_type": {
|
|
43
|
+
"module": "music.search.SearchCgiService",
|
|
44
|
+
"method": "DoSearchForQQMusicDesktop",
|
|
45
|
+
"params": {
|
|
46
|
+
"search_id": "int 随机生成",
|
|
47
|
+
"search_type": "int 搜索类型",
|
|
48
|
+
"query": "str 搜索词",
|
|
49
|
+
"highlight": "int 是否高亮搜索词",
|
|
50
|
+
"page_id": "int 页数",
|
|
51
|
+
"page_num": "int 页数",
|
|
52
|
+
"num_per_page": "int 每页返回数量",
|
|
53
|
+
"selectors": "dict 选择器"
|
|
54
|
+
},
|
|
55
|
+
"comment": "桌面端搜索"
|
|
56
|
+
},
|
|
57
|
+
"mobile_search_by_type": {
|
|
58
|
+
"module": "music.search.SearchCgiService",
|
|
59
|
+
"method": "DoSearchForQQMusicMobile",
|
|
60
|
+
"params": {
|
|
61
|
+
"search_id": "int 随机生成",
|
|
62
|
+
"search_type": "int 搜索类型",
|
|
63
|
+
"query": "str 搜索词",
|
|
64
|
+
"highlight": "int 是否高亮搜索词",
|
|
65
|
+
"page_id": "int 页数",
|
|
66
|
+
"page_num": "int 页数",
|
|
67
|
+
"grp": "int 是否返回歌曲其他版本",
|
|
68
|
+
"num_per_page": "int 每页返回数量",
|
|
69
|
+
"selectors": "dict 选择器"
|
|
70
|
+
},
|
|
71
|
+
"comment": "手机端搜索"
|
|
72
|
+
}
|
|
73
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
{
|
|
2
|
+
"query": {
|
|
3
|
+
"module": "music.trackInfo.UniformRuleCtrl",
|
|
4
|
+
"method": "CgiGetTrackInfo",
|
|
5
|
+
"params": {
|
|
6
|
+
"ids": "list id列表",
|
|
7
|
+
"mids": "list mid列表",
|
|
8
|
+
"types": "[0 for i in range(len(id or mid))]",
|
|
9
|
+
"modify_stamp": "[0 for i in range(len(id or mid))]",
|
|
10
|
+
"ctx": "int 0",
|
|
11
|
+
"client": "int 1"
|
|
12
|
+
},
|
|
13
|
+
"comment": "使用 ID 或 mid 查询歌曲"
|
|
14
|
+
},
|
|
15
|
+
"detail": {
|
|
16
|
+
"module": "music.pf_song_detail_svr",
|
|
17
|
+
"method": "get_song_detail_yqq",
|
|
18
|
+
"params": {
|
|
19
|
+
"song_id": "int 歌曲 ID",
|
|
20
|
+
"song_mid": "str 歌曲 mid"
|
|
21
|
+
},
|
|
22
|
+
"comment": "获取歌曲详细信息"
|
|
23
|
+
},
|
|
24
|
+
"similar": {
|
|
25
|
+
"module": "music.recommend.TrackRelationServer",
|
|
26
|
+
"method": "GetSimilarSongs",
|
|
27
|
+
"params": {
|
|
28
|
+
"songid": "int 歌曲 ID"
|
|
29
|
+
},
|
|
30
|
+
"comment": "获取相似歌曲"
|
|
31
|
+
},
|
|
32
|
+
"labels": {
|
|
33
|
+
"module": "music.recommend.TrackRelationServer",
|
|
34
|
+
"method": "GetSongLabels",
|
|
35
|
+
"params": {
|
|
36
|
+
"songid": "int 歌曲 ID"
|
|
37
|
+
},
|
|
38
|
+
"comment": "获取歌曲标签"
|
|
39
|
+
},
|
|
40
|
+
"playlist": {
|
|
41
|
+
"module": "music.recommend.TrackRelationServer",
|
|
42
|
+
"method": "GetRelatedPlaylist",
|
|
43
|
+
"params": {
|
|
44
|
+
"songid": "int 歌曲 ID"
|
|
45
|
+
},
|
|
46
|
+
"comment": "获取相关歌单"
|
|
47
|
+
},
|
|
48
|
+
"mv": {
|
|
49
|
+
"module": "MvService.MvInfoProServer",
|
|
50
|
+
"method": "GetSongRelatedMv",
|
|
51
|
+
"params": {
|
|
52
|
+
"songid": "int 歌曲 ID",
|
|
53
|
+
"songmid": "str 歌曲 mid"
|
|
54
|
+
},
|
|
55
|
+
"comment": "获取相关MV"
|
|
56
|
+
},
|
|
57
|
+
"other": {
|
|
58
|
+
"module": "music.musichallSong.OtherVersionServer",
|
|
59
|
+
"method": "GetOtherVersionSongs",
|
|
60
|
+
"params": {
|
|
61
|
+
"songid": "int 歌曲 ID",
|
|
62
|
+
"songmid": "str 歌曲 mid"
|
|
63
|
+
},
|
|
64
|
+
"comment": "获取其他版本"
|
|
65
|
+
},
|
|
66
|
+
"sheet": {
|
|
67
|
+
"module": "music.mir.SheetMusicSvr",
|
|
68
|
+
"method": "GetMoreSheetMusic",
|
|
69
|
+
"params": {
|
|
70
|
+
"songmid": "str 歌曲 mid"
|
|
71
|
+
},
|
|
72
|
+
"comment": "获取相关曲谱"
|
|
73
|
+
},
|
|
74
|
+
"producer": {
|
|
75
|
+
"module": "music.sociality.KolWorksTag",
|
|
76
|
+
"method": "SongProducer",
|
|
77
|
+
"params": {
|
|
78
|
+
"songid": "int 歌曲 ID",
|
|
79
|
+
"songmid": "str 歌曲 mid"
|
|
80
|
+
},
|
|
81
|
+
"comment": "获取歌曲制作团队"
|
|
82
|
+
},
|
|
83
|
+
"play_url": {
|
|
84
|
+
"module": "music.vkey.GetVkey",
|
|
85
|
+
"method": "UrlGetVkey",
|
|
86
|
+
"params": {
|
|
87
|
+
"filename": "[f'{file_type.s}{_}{_}{file_type.e}' for _ in mid]",
|
|
88
|
+
"guid": "str 随机32位字符串",
|
|
89
|
+
"songmid": "list mid 列表",
|
|
90
|
+
"songtype": "[1 for _ in range(len(mid))]"
|
|
91
|
+
},
|
|
92
|
+
"comment": "获取播放链接"
|
|
93
|
+
},
|
|
94
|
+
"download_url": {
|
|
95
|
+
"module": "music.vkey.GetDownUrl",
|
|
96
|
+
"method": "CgiGetDownUrl",
|
|
97
|
+
"params": {
|
|
98
|
+
"filename": "[f'{file_type.s}{_}{_}{file_type.e}' for _ in mid]",
|
|
99
|
+
"guid": "str 随机32位字符串",
|
|
100
|
+
"songmid": "list mid 列表",
|
|
101
|
+
"songtype": "[1 for _ in range(len(mid))]"
|
|
102
|
+
},
|
|
103
|
+
"comment": "获取下载链接"
|
|
104
|
+
}
|
|
105
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"detail": {
|
|
3
|
+
"module": "srf_diss_info.DissInfoServer",
|
|
4
|
+
"method": "CgiGetDiss",
|
|
5
|
+
"params": {
|
|
6
|
+
"disstid": "int 歌单ID",
|
|
7
|
+
"dirid": "int 0",
|
|
8
|
+
"tag": "int 是否返回歌曲标签",
|
|
9
|
+
"onlysonglist": "int 是否只返回歌曲",
|
|
10
|
+
"song_begin": "int 开始位置",
|
|
11
|
+
"song_num": "int 返回数量",
|
|
12
|
+
"userinfo": "int 是否返回以后信息",
|
|
13
|
+
"orderlist": "int 是否排序歌单",
|
|
14
|
+
"caller": "str musicid"
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"category": {
|
|
3
|
+
"module": "music.musicToplist.Toplist",
|
|
4
|
+
"method": "GetAll",
|
|
5
|
+
"params": {},
|
|
6
|
+
"comment": "获取所有榜单"
|
|
7
|
+
},
|
|
8
|
+
"detail": {
|
|
9
|
+
"module": "music.musicToplist.Toplist",
|
|
10
|
+
"method": "GetDetail",
|
|
11
|
+
"params": {
|
|
12
|
+
"topId": "int 榜单ID",
|
|
13
|
+
"offset": "int 开始位置",
|
|
14
|
+
"num": "int 返回数量",
|
|
15
|
+
"withTags": "bool 是否返回歌曲标签",
|
|
16
|
+
"period": "str 榜单周期"
|
|
17
|
+
},
|
|
18
|
+
"comment": "获取榜单详情"
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
{
|
|
2
|
+
"new_0": {
|
|
3
|
+
"s": "AI00",
|
|
4
|
+
"e": ".flac"
|
|
5
|
+
},
|
|
6
|
+
"new_1": {
|
|
7
|
+
"s": "Q000",
|
|
8
|
+
"e": ".flac"
|
|
9
|
+
},
|
|
10
|
+
"new_2": {
|
|
11
|
+
"s": "Q001",
|
|
12
|
+
"e": ".flac"
|
|
13
|
+
},
|
|
14
|
+
"flac": {
|
|
15
|
+
"s": "F000",
|
|
16
|
+
"e": ".flac"
|
|
17
|
+
},
|
|
18
|
+
"ogg_192": {
|
|
19
|
+
"s": "O600",
|
|
20
|
+
"e": ".ogg"
|
|
21
|
+
},
|
|
22
|
+
"ogg_96": {
|
|
23
|
+
"s": "O400",
|
|
24
|
+
"e": ".ogg"
|
|
25
|
+
},
|
|
26
|
+
"mp3_320": {
|
|
27
|
+
"s": "M800",
|
|
28
|
+
"e": ".mp3"
|
|
29
|
+
},
|
|
30
|
+
"mp3_128": {
|
|
31
|
+
"s": "M500",
|
|
32
|
+
"e": ".mp3"
|
|
33
|
+
},
|
|
34
|
+
"acc_192": {
|
|
35
|
+
"s": "C600",
|
|
36
|
+
"e": ".m4a"
|
|
37
|
+
},
|
|
38
|
+
"acc_96": {
|
|
39
|
+
"s": "C400",
|
|
40
|
+
"e": ".m4a"
|
|
41
|
+
},
|
|
42
|
+
"acc_48": {
|
|
43
|
+
"s": "C200",
|
|
44
|
+
"e": ".m4a"
|
|
45
|
+
},
|
|
46
|
+
"try": {
|
|
47
|
+
"s": "RS02",
|
|
48
|
+
"e": ".mp3"
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
class ApiException(Exception):
|
|
2
|
+
"""
|
|
3
|
+
API 异常基类
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
def __init__(self, msg: str = "未知原因"):
|
|
7
|
+
super().__init__(msg)
|
|
8
|
+
self.msg = msg
|
|
9
|
+
|
|
10
|
+
def __str__(self):
|
|
11
|
+
return self.msg
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class ArgsException(ApiException):
|
|
15
|
+
"""
|
|
16
|
+
参数错误。
|
|
17
|
+
"""
|
|
18
|
+
|
|
19
|
+
def __init__(self, msg: str):
|
|
20
|
+
super().__init__(msg)
|
|
21
|
+
self.msg = msg
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
class ClientException(ApiException):
|
|
25
|
+
"""
|
|
26
|
+
服务器连接错误
|
|
27
|
+
"""
|
|
28
|
+
|
|
29
|
+
def __init__(self):
|
|
30
|
+
super().__init__()
|
|
31
|
+
self.msg = "连接到服务器时出现了问题"
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
class NetworkException(ApiException):
|
|
35
|
+
"""
|
|
36
|
+
网络错误
|
|
37
|
+
"""
|
|
38
|
+
|
|
39
|
+
def __init__(self, status: int, msg: str):
|
|
40
|
+
super().__init__(msg)
|
|
41
|
+
self.status = status
|
|
42
|
+
self.msg = f"网络错误,状态码:{status} - {msg}"
|
|
43
|
+
|
|
44
|
+
def __str__(self):
|
|
45
|
+
return self.msg
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
class ResponseCodeException(ApiException):
|
|
49
|
+
"""
|
|
50
|
+
API 返回 code 错误
|
|
51
|
+
"""
|
|
52
|
+
|
|
53
|
+
def __init__(self, code: int, subcode: int, api: list):
|
|
54
|
+
super().__init__()
|
|
55
|
+
self.msg = "API 返回 code 错误"
|
|
56
|
+
self.code = code
|
|
57
|
+
self.subcode = subcode
|
|
58
|
+
self.api = api
|
|
59
|
+
|
|
60
|
+
def __str__(self):
|
|
61
|
+
return f"接口信息:{'.'.join(self.api)} 错误代码:{self.code} | {self.subcode}"
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
class CredientialCanNotRefreshException(ApiException):
|
|
65
|
+
"""
|
|
66
|
+
Crediential 无法刷新
|
|
67
|
+
"""
|
|
68
|
+
|
|
69
|
+
def __init__(self):
|
|
70
|
+
super().__init__()
|
|
71
|
+
self.msg = "Crediential 无法刷新,请检查是否缺少必要字段"
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
class CredentialNoMusicidException(ApiException):
|
|
75
|
+
"""
|
|
76
|
+
Crediential 缺少 Musicid
|
|
77
|
+
"""
|
|
78
|
+
|
|
79
|
+
def __init__(self):
|
|
80
|
+
super().__init__()
|
|
81
|
+
self.msg = "Crediential 缺少 Musicid"
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
class CredentialNoMusickeyException(ApiException):
|
|
85
|
+
"""
|
|
86
|
+
Crediential 缺少 Musickey
|
|
87
|
+
"""
|
|
88
|
+
|
|
89
|
+
def __init__(self):
|
|
90
|
+
super().__init__()
|
|
91
|
+
self.msg = "Crediential 缺少 Musickey"
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
class LoginDevicesFullException(ApiException):
|
|
95
|
+
"""
|
|
96
|
+
登录设备已满
|
|
97
|
+
"""
|
|
98
|
+
|
|
99
|
+
def __init__(self):
|
|
100
|
+
super().__init__()
|
|
101
|
+
self.msg = "登录设备已满"
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
class AuthcodeExpiredException(ApiException):
|
|
105
|
+
"""
|
|
106
|
+
验证码已失效
|
|
107
|
+
"""
|
|
108
|
+
|
|
109
|
+
def __init__(self):
|
|
110
|
+
super().__init__()
|
|
111
|
+
self.msg = "验证码已失效"
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
class AuthcodeGetFrequentlyException(ApiException):
|
|
115
|
+
"""
|
|
116
|
+
验证码获取频繁
|
|
117
|
+
"""
|
|
118
|
+
|
|
119
|
+
def __init__(self):
|
|
120
|
+
super().__init__()
|
|
121
|
+
self.msg = "验证码获取频繁"
|
qqmusic_api/settings.py
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
from .utils.common import random_string
|
|
2
|
+
from .utils.qimei import Qimei
|
|
3
|
+
|
|
4
|
+
# 接口参数配置
|
|
5
|
+
# API接口
|
|
6
|
+
API_URL = "https://u.y.qq.com/cgi-bin/musicu.fcg"
|
|
7
|
+
|
|
8
|
+
# QQ音乐版本号
|
|
9
|
+
QQMUSIC_VERSION = "13.2.5.8"
|
|
10
|
+
QQMUSIC_VERSION_CODE = 13020508
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def get_qimei36(version):
|
|
14
|
+
result = Qimei.get(version)
|
|
15
|
+
if result.q36:
|
|
16
|
+
return result.q36
|
|
17
|
+
else:
|
|
18
|
+
return "cc8d07a748d4be0a8b91eacd100014a1730e"
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
QIMEI36 = get_qimei36(QQMUSIC_VERSION)
|
|
22
|
+
UID = random_string(10, "0123456789")
|
|
File without changes
|