Skip to content

Commit a3957fc

Browse files
committedJul 1, 2024
Upgraded SDK V1.11.5 Add Support for NetEase Cloud Music API
1 parent 568d154 commit a3957fc

File tree

9 files changed

+145
-1
lines changed

9 files changed

+145
-1
lines changed
 

‎README.md

+4
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
* [微博网页版数据接口](https://api.tikhub.io/#/Weibo-Web-API)
2424
* [Instagram Web以及APP数据接口](https://api.tikhub.io/#/Instagram-Web-And-APP-API)
2525
* [YouTube Web数据接口](https://api.tikhub.io/#/YouTube-Web-API)
26+
* [网易云音乐App数据接口](https://api.tikhub.io/#/NetEase-Cloud-Music-API)
2627
* [验证码绕过接口](https://api.tikhub.io/#/Captcha-Solver)
2728
* [临时邮箱接口](https://api.tikhub.io/#/Temp-Mail-API)
2829
* 请将任何问题或错误报告给[Discord服务器](https://discord.gg/aMEAS8Xsvz)
@@ -168,6 +169,9 @@ self.KuaishouWeb = KuaishouWeb(self.client)
168169

169170
# YouTube Web | YouTube网页端
170171
self.YouTubeWeb = YouTubeWeb(self.client)
172+
173+
# 网易云音乐APP | NetEase Cloud Music APP
174+
self.NetEaseCloudMusicAppV1 = NetEaseCloudMusicAppV1(self.client)
171175
```
172176

173177
- 使用`DouyinAppV1``fetch_one_video`方法调用接口获取单一视频数据。

‎dist/tikhub-1.11.5-py3-none-any.whl

63.1 KB
Binary file not shown.

‎dist/tikhub-1.11.5.tar.gz

42.4 KB
Binary file not shown.

‎setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
setup(
1515
name="tikhub",
16-
version="1.11.4",
16+
version="1.11.5",
1717
author="TikHub.io",
1818
author_email="tikhub.io@proton.me",
1919
description="A Python SDK for TikHub RESTful API",

‎tikhub/api/v1/endpoints/instagram/web/instagram_web.py

+24
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,30 @@ async def fetch_global_search(self, keyword: str):
149149
data = await self.client.fetch_get_json(f"{endpoint}?keyword={keyword}")
150150
return data
151151

152+
# 根据用户名获取用户的Reels数据V2 | Get user reels by username V2
153+
async def fetch_user_reels_by_username_v2(self, username: str, pagination_token: str = None):
154+
endpoint = "/api/v1/instagram/web_app/fetch_user_reels_by_username_v2"
155+
data = await self.client.fetch_get_json(f"{endpoint}?username={username}&pagination_token={pagination_token}")
156+
return data
157+
158+
# 根据用户名获取用户的Stories数据 | Get user stories by username
159+
async def fetch_user_stories_by_username(self, username: str):
160+
endpoint = "/api/v1/instagram/web_app/fetch_user_stories_by_username"
161+
data = await self.client.fetch_get_json(f"{endpoint}?username={username}")
162+
return data
163+
164+
# 根据用户名获取用户的highlights数据 | Get user highlights by username
165+
async def fetch_user_highlights_by_username(self, username: str):
166+
endpoint = "/api/v1/instagram/web_app/fetch_user_highlights_by_username"
167+
data = await self.client.fetch_get_json(f"{endpoint}?username={username}")
168+
return data
169+
170+
# 根据用户名获取用户的tv_posts数据 | Get user tv_posts by username
171+
async def fetch_user_tv_posts_by_username(self, username: str, pagination_token: str = None):
172+
endpoint = "/api/v1/instagram/web_app/fetch_user_tv_posts_by_username"
173+
data = await self.client.fetch_get_json(f"{endpoint}?username={username}&pagination_token={pagination_token}")
174+
return data
175+
152176

153177
if __name__ == "__main__":
154178
import asyncio

‎tikhub/api/v1/endpoints/net_ease_cloud_music/__init__.py

Whitespace-only changes.

‎tikhub/api/v1/endpoints/net_ease_cloud_music/app/__init__.py

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
# 导入API SDK Client类
2+
import json
3+
4+
from tikhub.http_client.api_client import APIClient
5+
6+
7+
class NetEaseCloudMusicAppV1:
8+
9+
# 初始化 | Initialize
10+
def __init__(self, client: APIClient):
11+
self.client = client
12+
13+
# 获取单一歌曲信息V1(信息更全)| Fetch one music information V1 (more information)
14+
async def fetch_one_music_v1(self, music_id: str):
15+
endpoint = "/api/v1/net_ease_cloud_music/app/fetch_one_music_v1"
16+
data = await self.client.fetch_get_json(f"{endpoint}?music_id={music_id}")
17+
return data
18+
19+
# 获取单一歌曲信息V2(信息更少)| Fetch one music information V2 (less information)
20+
async def fetch_one_music_v2(self, music_id: str):
21+
endpoint = "/api/v1/net_ease_cloud_music/app/fetch_one_music_v2"
22+
data = await self.client.fetch_get_json(f"{endpoint}?music_id={music_id}")
23+
return data
24+
25+
# 获取单一歌曲歌词/Fetch one music lyric
26+
async def fetch_one_music_lyric(self, music_id: str):
27+
endpoint = "/api/v1/net_ease_cloud_music/app/fetch_one_music_lyric"
28+
data = await self.client.fetch_get_json(f"{endpoint}?music_id={music_id}")
29+
return data
30+
31+
# 获取单一歌曲播放地址V1(只能返回MP3格式,支持参数较少)/Fetch one music URL V1 (only MP3 format is supported, with fewer parameters)
32+
async def fetch_one_music_url_v1(self, music_id: str, br: str = "192000"):
33+
endpoint = "/api/v1/net_ease_cloud_music/app/fetch_one_music_url_v1"
34+
data = await self.client.fetch_get_json(f"{endpoint}?music_id={music_id}&br={br}")
35+
return data
36+
37+
# 获取单一歌曲播放地址V2(支持更多参数)/Fetch one music URL V2 (support more parameters)
38+
async def fetch_one_music_url_v2(self, music_id: str, level: str = "exhigh", encodeType: str = "mp3"):
39+
endpoint = "/api/v1/net_ease_cloud_music/app/fetch_one_music_url_v2"
40+
data = await self.client.fetch_get_json(f"{endpoint}?music_id={music_id}&level={level}&encodeType={encodeType}")
41+
return data
42+
43+
# Mlog(音乐视频)播放地址/Mlog (music video) playback address
44+
async def fetch_music_log_video_url(self, mlogId: str, resolution: str = "1080"):
45+
endpoint = "/api/v1/net_ease_cloud_music/app/fetch_music_log_video_url"
46+
data = await self.client.fetch_get_json(f"{endpoint}?mlogId={mlogId}&resolution={resolution}")
47+
return data
48+
49+
# 获取歌曲评论/Fetch music comment
50+
async def fetch_music_comment(self, resource_id: str, beforeTime: str = "0", limit: str = "30"):
51+
endpoint = "/api/v1/net_ease_cloud_music/app/fetch_music_comment"
52+
data = await self.client.fetch_get_json(
53+
f"{endpoint}?resource_id={resource_id}&beforeTime={beforeTime}&limit={limit}")
54+
return data
55+
56+
# 搜索接口V1/Search interface V1
57+
async def search_v1(self, keywords: str, offset: str = "0", limit: str = "20", _type: str = "1"):
58+
endpoint = "/api/v1/net_ease_cloud_music/app/search_v1"
59+
data = await self.client.fetch_get_json(
60+
f"{endpoint}?keywords={keywords}&offset={offset}&limit={limit}&type={_type}")
61+
return data
62+
63+
# 获取用户歌单/Get user playlist
64+
async def fetch_user_playlist(self, uid: str, offset: str = "0", limit: str = "20"):
65+
endpoint = "/api/v1/net_ease_cloud_music/app/fetch_user_playlist"
66+
data = await self.client.fetch_get_json(f"{endpoint}?uid={uid}&offset={offset}&limit={limit}")
67+
return data
68+
69+
# 获取用户信息/Get user information
70+
async def fetch_user_info(self, uid: str):
71+
endpoint = "/api/v1/net_ease_cloud_music/app/fetch_user_info"
72+
data = await self.client.fetch_get_json(f"{endpoint}?uid={uid}")
73+
return data
74+
75+
# 获取用户动态/Fetch user event
76+
async def fetch_user_event(self, uid: str, _time: str = "-1", limit: str = "10"):
77+
endpoint = "/api/v1/net_ease_cloud_music/app/fetch_user_event"
78+
data = await self.client.fetch_get_json(f"{endpoint}?uid={uid}&time={_time}&limit={limit}")
79+
return data
80+
81+
# 获取用户粉丝列表/Fetch user followers
82+
async def fetch_user_followers(self, uid: str, lasttime: str = "0", pagesize: str = "20"):
83+
endpoint = "/api/v1/net_ease_cloud_music/app/fetch_user_followers"
84+
data = await self.client.fetch_get_json(f"{endpoint}?uid={uid}&lasttime={lasttime}&pagesize={pagesize}")
85+
return data
86+
87+
# 获取用户关注列表/Fetch user follows
88+
async def fetch_user_follows(self, uid: str, offset: str = "0", limit: str = "20"):
89+
endpoint = "/api/v1/net_ease_cloud_music/app/fetch_user_follows"
90+
data = await self.client.fetch_get_json(f"{endpoint}?uid={uid}&offset={offset}&limit={limit}")
91+
return data
92+
93+
# 获取歌手信息/Fetch artist detail
94+
async def fetch_artist_detail(self, artist_id: str):
95+
endpoint = "/api/v1/net_ease_cloud_music/app/fetch_artist_detail"
96+
data = await self.client.fetch_get_json(f"{endpoint}?artist_id={artist_id}")
97+
return data
98+
99+
# 解密POST请求中的16进制payload/Decrypt the 16-bit payload in the POST request
100+
async def decrypt_post_payload(self, payload: str):
101+
endpoint = "/api/v1/net_ease_cloud_music/app/decrypt_post_payload"
102+
data = await self.client.fetch_post_json(endpoint, data=payload)
103+
return data
104+
105+
# 加密POST请求中的payload并且返回16进制/Encrypt the payload in the POST request and return 16 hexadecimal
106+
async def encrypt_post_payload(self, uri: str, payload: dict, add_variable: bool = False):
107+
endpoint = "/api/v1/net_ease_cloud_music/app/encrypt_post_payload"
108+
endpoint = f"{endpoint}?uri={uri}&add_variable={add_variable}"
109+
data = await self.client.fetch_post_json(endpoint, data=json.dumps(payload))
110+
return data

‎tikhub/client/client.py

+6
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@
3636
# YouTube Web
3737
from tikhub.api.v1.endpoints.youtube.web.youtube_web import YouTubeWeb
3838

39+
# Net Ease Cloud Music
40+
from tikhub.api.v1.endpoints.net_ease_cloud_music.app.net_ease_cloud_music_app_v1 import NetEaseCloudMusicAppV1
41+
3942

4043
class Client:
4144
def __init__(self,
@@ -100,3 +103,6 @@ def __init__(self,
100103

101104
# YouTube Web
102105
self.YouTubeWeb = YouTubeWeb(self.client)
106+
107+
# Net Ease Cloud Music
108+
self.NetEaseCloudMusicAppV1 = NetEaseCloudMusicAppV1(self.client)

0 commit comments

Comments
 (0)
Please sign in to comment.