Skip to content

Commit f55d136

Browse files
committed
Upgraded SDK V1.11.4 Add Support for YouTube API
1 parent a780e0a commit f55d136

File tree

8 files changed

+46
-1
lines changed

8 files changed

+46
-1
lines changed

README.md

+3
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,9 @@ self.XiaohongshuWeb = XiaohongshuWeb(self.client)
164164

165165
# KuaiShou Web | 快手网页端
166166
self.KuaishouWeb = KuaishouWeb(self.client)
167+
168+
# YouTube Web | YouTube网页端
169+
self.YouTubeWeb = YouTubeWeb(self.client)
167170
```
168171

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

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

60.8 KB
Binary file not shown.

dist/tikhub-1.11.4.tar.gz

40.5 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.3",
16+
version="1.11.4",
1717
author="TikHub.io",
1818
author_email="tikhub.io@proton.me",
1919
description="A Python SDK for TikHub RESTful API",

tikhub/api/v1/endpoints/youtube/__init__.py

Whitespace-only changes.

tikhub/api/v1/endpoints/youtube/web/__init__.py

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# 导入API SDK Client类
2+
import json
3+
4+
from tikhub.http_client.api_client import APIClient
5+
6+
7+
class YouTubeWeb:
8+
9+
# 初始化 | Initialize
10+
def __init__(self, client: APIClient):
11+
self.client = client
12+
13+
# 获取视频信息 | Get video information
14+
async def get_video_info(self, id: str):
15+
endpoint = "/api/v1/youtube/web/get_video_info"
16+
data = await self.client.fetch_get_json(f"{endpoint}?id={id}")
17+
return data
18+
19+
# 获取视频字幕 | Get video subtitles
20+
async def get_video_subtitles(self, id: str, format: str = "json3"):
21+
endpoint = "/api/v1/youtube/web/get_video_subtitles"
22+
data = await self.client.fetch_get_json(f"{endpoint}?id={id}&format={format}")
23+
return data
24+
25+
# 获取视频评论 | Get video comments
26+
async def get_video_comments(self, id: str, continuation: str = None, sort_by: str = None):
27+
endpoint = "/api/v1/youtube/web/get_video_comments"
28+
data = await self.client.fetch_get_json(f"{endpoint}?id={id}&continuation={continuation}&sort_by={sort_by}")
29+
return data
30+
31+
# 获取短视频信息 | Get short video information
32+
async def get_short_video_info(self, id: str):
33+
endpoint = "/api/v1/youtube/web/get_short_video_info"
34+
data = await self.client.fetch_get_json(f"{endpoint}?id={id}")
35+
return data
36+

tikhub/client/client.py

+6
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@
3333
# KuaiShou Web
3434
from tikhub.api.v1.endpoints.kuaishou.web.kuaishou_web import KuaishouWeb
3535

36+
# YouTube Web
37+
from tikhub.api.v1.endpoints.youtube.web.youtube_web import YouTubeWeb
38+
3639

3740
class Client:
3841
def __init__(self,
@@ -94,3 +97,6 @@ def __init__(self,
9497

9598
# KuaiShou Web
9699
self.KuaishouWeb = KuaishouWeb(self.client)
100+
101+
# YouTube Web
102+
self.YouTubeWeb = YouTubeWeb(self.client)

0 commit comments

Comments
 (0)