-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathYouTube.py
More file actions
57 lines (49 loc) · 1.98 KB
/
YouTube.py
File metadata and controls
57 lines (49 loc) · 1.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
from .Auth import Auth
from typing import Optional, Dict, Any
class YouTube(Auth):
"""YouTube API类 - 严格按照接口文档实现所有接口"""
def __init__(self, token: str, domain: str = "http://api.moreapi.cn"):
super().__init__(token, domain)
def video_data(self, video_id: str) -> Dict[str, Any]:
"""获取视频数据"""
data = {
"video_id": video_id
}
return self._make_request("/api/youtube/video_data", data)
def video_comment(self, video_id: str, max_results: int = 100,
page_token: str = "") -> Dict[str, Any]:
"""获取视频评论"""
data = {
"video_id": video_id,
"max_results": max_results,
"page_token": page_token
}
return self._make_request("/api/youtube/video_comment", data)
def search_data(self, keyword: str, max_results: int = 25,
page_token: str = "", order: str = "relevance") -> Dict[str, Any]:
"""搜索视频"""
data = {
"keyword": keyword,
"max_results": max_results,
"page_token": page_token,
"order": order
}
return self._make_request("/api/youtube/search_data", data)
def play_list(self, channel_id: str, max_results: int = 25,
page_token: str = "") -> Dict[str, Any]:
"""获取播放列表"""
data = {
"channel_id": channel_id,
"max_results": max_results,
"page_token": page_token
}
return self._make_request("/api/youtube/play_list", data)
def play_list_item(self, playlist_id: str, max_results: int = 25,
page_token: str = "") -> Dict[str, Any]:
"""获取播放列表视频"""
data = {
"playlist_id": playlist_id,
"max_results": max_results,
"page_token": page_token
}
return self._make_request("/api/youtube/play_list_item", data)