Skip to content

Commit 8094f7a

Browse files
committed
Upgraded SDK V1.10.5 support Upstream API V5.0.3
1 parent 3c9bfe7 commit 8094f7a

File tree

6 files changed

+78
-11
lines changed

6 files changed

+78
-11
lines changed

dist/tikhub-1.10.5-py3-none-any.whl

54.1 KB
Binary file not shown.

dist/tikhub-1.10.5.tar.gz

35.9 KB
Binary file not shown.

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
setup(
1515
name="tikhub",
16-
version="1.10.4",
16+
version="1.10.5",
1717
author="TikHub.io",
1818
author_email="tikhub.io@proton.me",
1919
description="A Python SDK for TikHub RESTful API",
Lines changed: 67 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,70 @@
1-
# 导入API SDK Client
1+
# 导入API SDK Client类
2+
23
from tikhub.http_client.api_client import APIClient
34

4-
@router.get("/test", response_model=ResponseModel, summary="测试接口")
5-
async def test(request: Request):
6-
# 测试函数
7-
data = {"message": "即将上线,敬请期待 | Coming soon, stay tuned"}
8-
return ResponseModel(code=200,
9-
router=request.url.path,
10-
params=dict(request.query_params),
11-
data=data)
125

6+
class CaptchaSolver:
7+
# 初始化 | Initialize
8+
def __init__(self, client: APIClient):
9+
self.client = client
10+
11+
# Cloudflare Turnstile
12+
async def cloudflare_turnstile(self, sitekey: str, url: str, proxy: dict = None):
13+
endpoint = "/api/v1/captcha/cloudflare_turnstile"
14+
payload = {
15+
"sitekey": sitekey,
16+
"url": url,
17+
"proxy": proxy
18+
}
19+
return await self.client.fetch_post_json(endpoint, payload)
20+
21+
# Recaptcha V2
22+
async def recaptcha_v2(self, sitekey: str, url: str, proxy: dict = None):
23+
endpoint = "/api/v1/captcha/recaptcha_v2"
24+
payload = {
25+
"sitekey": sitekey,
26+
"url": url,
27+
"proxy": proxy
28+
}
29+
return await self.client.fetch_post_json(endpoint, payload)
30+
31+
# Recaptcha V3
32+
async def recaptcha_v3(self, sitekey: str, url: str, action: str = None, proxy: dict = None):
33+
endpoint = "/api/v1/captcha/recaptcha_v3"
34+
payload = {
35+
"sitekey": sitekey,
36+
"url": url,
37+
"action": action,
38+
"proxy": proxy
39+
}
40+
return await self.client.fetch_post_json(endpoint, payload)
41+
42+
# hCaptcha
43+
async def hcaptcha(self, sitekey: str, url: str, proxy: dict = None):
44+
endpoint = "/api/v1/captcha/hcaptcha"
45+
payload = {
46+
"sitekey": sitekey,
47+
"url": url,
48+
"proxy": proxy
49+
}
50+
return await self.client.fetch_post_json(endpoint, payload)
51+
52+
# Tencent Captcha
53+
async def tencent_captcha(self, app_id: str, url: str, proxy: dict = None):
54+
endpoint = "/api/v1/captcha/tencent_captcha"
55+
payload = {
56+
"app_id": app_id,
57+
"url": url,
58+
"proxy": proxy
59+
}
60+
return await self.client.fetch_post_json(endpoint, payload)
61+
62+
# Amazon Captcha
63+
async def amazon_captcha(self, app_id: str, url: str, proxy: dict = None):
64+
endpoint = "/api/v1/captcha/amazon_captcha"
65+
payload = {
66+
"app_id": app_id,
67+
"url": url,
68+
"proxy": proxy
69+
}
70+
return await self.client.fetch_post_json(endpoint, payload)

tikhub/api/v1/endpoints/weibo/web/weibo_web.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33

44
from tikhub.http_client.api_client import APIClient
55

6+
67
class WeiboWeb:
78

89
# 初始化 | Initialize
910
def __init__(self, client: APIClient):
1011
self.client = client
1112

12-
1313
# 获取单个作品数据 | Get single video data
1414
async def fetch_post_detail(self, id: str):
1515
endpoint = "/api/v1/weibo/web/fetch_post_detail"
@@ -28,9 +28,11 @@ async def fetch_user_posts(self, uid: str, page: int, feature: int):
2828
data = await self.client.fetch_get_json(f"{endpoint}?uid={uid}&page={page}&feature={feature}")
2929
return data
3030

31+
3132
if __name__ == "__main__":
3233
import asyncio
3334

35+
3436
async def main():
3537
client = APIClient(base_url="http://127.0.0.1:8000", client_headers={
3638
"Authorization": "Bearer l7sVQFh64V8ltC8fzEaNtWE60zVSopDLlpVX62fArT1FznsPds9+2RGoXw=="})
@@ -49,4 +51,5 @@ async def main():
4951
data = await weibo_web.fetch_user_posts("7277477906", 1, 0)
5052
print(data)
5153

54+
5255
asyncio.run(main())

tikhub/client/client.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@
2121
# Weibo
2222
from tikhub.api.v1.endpoints.weibo.web.weibo_web import WeiboWeb
2323

24+
# Captcha Solver
25+
from tikhub.api.v1.endpoints.captcha.captcha_solver import CaptchaSolver
26+
2427

2528
class Client:
2629
def __init__(self,
@@ -70,3 +73,6 @@ def __init__(self,
7073

7174
# Weibo
7275
self.WeiboWeb = WeiboWeb(self.client)
76+
77+
# Captcha Solver
78+
self.CaptchaSolver = CaptchaSolver(self.client)

0 commit comments

Comments
 (0)