tikdataapi 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.
- tikdataapi/__init__.py +8 -0
- tikdataapi/api/__init__.py +1 -0
- tikdataapi/api/account/__init__.py +1 -0
- tikdataapi/api/account/get_me.py +144 -0
- tikdataapi/api/billing/__init__.py +1 -0
- tikdataapi/api/billing/create_checkout.py +215 -0
- tikdataapi/api/billing/list_packs.py +144 -0
- tikdataapi/api/hashtags/__init__.py +1 -0
- tikdataapi/api/hashtags/get_hashtag.py +220 -0
- tikdataapi/api/hashtags/get_hashtag_videos.py +250 -0
- tikdataapi/api/music/__init__.py +1 -0
- tikdataapi/api/music/get_music.py +234 -0
- tikdataapi/api/music/get_music_videos.py +254 -0
- tikdataapi/api/playlists/__init__.py +1 -0
- tikdataapi/api/playlists/get_playlist_videos.py +258 -0
- tikdataapi/api/search/__init__.py +1 -0
- tikdataapi/api/search/search_hashtags.py +261 -0
- tikdataapi/api/search/search_live.py +258 -0
- tikdataapi/api/search/search_music.py +260 -0
- tikdataapi/api/search/search_users.py +276 -0
- tikdataapi/api/search/search_videos.py +260 -0
- tikdataapi/api/users/__init__.py +1 -0
- tikdataapi/api/users/get_user.py +222 -0
- tikdataapi/api/users/get_user_followers.py +266 -0
- tikdataapi/api/users/get_user_following.py +266 -0
- tikdataapi/api/users/get_user_live.py +236 -0
- tikdataapi/api/users/get_user_playlists.py +276 -0
- tikdataapi/api/users/get_user_reposts.py +266 -0
- tikdataapi/api/users/get_user_videos.py +254 -0
- tikdataapi/api/users/get_users.py +247 -0
- tikdataapi/api/users/get_users_videos.py +259 -0
- tikdataapi/api/videos/__init__.py +1 -0
- tikdataapi/api/videos/get_comment_replies.py +260 -0
- tikdataapi/api/videos/get_comments.py +258 -0
- tikdataapi/api/videos/get_related_videos.py +247 -0
- tikdataapi/api/videos/get_trending_videos.py +238 -0
- tikdataapi/api/videos/get_video.py +218 -0
- tikdataapi/api/videos/get_video_transcript.py +247 -0
- tikdataapi/api/videos/get_videos.py +235 -0
- tikdataapi/client.py +268 -0
- tikdataapi/errors.py +16 -0
- tikdataapi/models/__init__.py +117 -0
- tikdataapi/models/batch_error.py +104 -0
- tikdataapi/models/batch_error_code.py +15 -0
- tikdataapi/models/batch_meta.py +127 -0
- tikdataapi/models/batch_meta_cache.py +11 -0
- tikdataapi/models/comment.py +163 -0
- tikdataapi/models/comment_author.py +97 -0
- tikdataapi/models/comment_page.py +130 -0
- tikdataapi/models/create_checkout_body.py +63 -0
- tikdataapi/models/create_checkout_body_pack.py +11 -0
- tikdataapi/models/create_checkout_response_200.py +97 -0
- tikdataapi/models/error.py +78 -0
- tikdataapi/models/error_body.py +107 -0
- tikdataapi/models/error_body_code.py +22 -0
- tikdataapi/models/get_me_response_200.py +88 -0
- tikdataapi/models/get_users_body.py +61 -0
- tikdataapi/models/get_users_videos_body.py +72 -0
- tikdataapi/models/get_videos_body.py +61 -0
- tikdataapi/models/hashtag.py +124 -0
- tikdataapi/models/hashtag_response.py +122 -0
- tikdataapi/models/hashtag_summary.py +98 -0
- tikdataapi/models/hashtag_summary_page.py +130 -0
- tikdataapi/models/list_packs_response_200.py +103 -0
- tikdataapi/models/list_packs_response_200_data_item.py +88 -0
- tikdataapi/models/list_packs_response_200_rate_limits_item.py +70 -0
- tikdataapi/models/live_room.py +142 -0
- tikdataapi/models/live_room_author.py +90 -0
- tikdataapi/models/live_room_page.py +130 -0
- tikdataapi/models/live_room_response.py +124 -0
- tikdataapi/models/meta.py +108 -0
- tikdataapi/models/meta_cache.py +10 -0
- tikdataapi/models/music.py +107 -0
- tikdataapi/models/music_detail.py +172 -0
- tikdataapi/models/music_response.py +124 -0
- tikdataapi/models/music_summary.py +137 -0
- tikdataapi/models/music_summary_page.py +130 -0
- tikdataapi/models/not_found_reason.py +12 -0
- tikdataapi/models/playlist.py +114 -0
- tikdataapi/models/playlist_author.py +86 -0
- tikdataapi/models/playlist_page.py +130 -0
- tikdataapi/models/problem.py +131 -0
- tikdataapi/models/transcript.py +128 -0
- tikdataapi/models/transcript_response.py +124 -0
- tikdataapi/models/transcript_segment.py +77 -0
- tikdataapi/models/user.py +207 -0
- tikdataapi/models/user_batch.py +145 -0
- tikdataapi/models/user_page.py +130 -0
- tikdataapi/models/user_response.py +126 -0
- tikdataapi/models/user_summary.py +152 -0
- tikdataapi/models/user_summary_page.py +130 -0
- tikdataapi/models/user_videos.py +96 -0
- tikdataapi/models/user_videos_batch.py +145 -0
- tikdataapi/models/video.py +297 -0
- tikdataapi/models/video_batch.py +145 -0
- tikdataapi/models/video_page.py +130 -0
- tikdataapi/models/video_response.py +122 -0
- tikdataapi/models/video_type.py +9 -0
- tikdataapi/py.typed +1 -0
- tikdataapi/types.py +54 -0
- tikdataapi-0.1.0.dist-info/METADATA +148 -0
- tikdataapi-0.1.0.dist-info/RECORD +103 -0
- tikdataapi-0.1.0.dist-info/WHEEL +4 -0
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from collections.abc import Mapping
|
|
4
|
+
from typing import Any, TypeVar
|
|
5
|
+
|
|
6
|
+
from attrs import define as _attrs_define
|
|
7
|
+
from attrs import field as _attrs_field
|
|
8
|
+
|
|
9
|
+
T = TypeVar("T", bound="PlaylistAuthor")
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
@_attrs_define
|
|
13
|
+
class PlaylistAuthor:
|
|
14
|
+
"""The account that made a playlist.
|
|
15
|
+
|
|
16
|
+
Attributes:
|
|
17
|
+
id (str): Example: 107955.
|
|
18
|
+
username (str): Example: tiktok.
|
|
19
|
+
sec_uid (str): Example: MS4wLjABAAAAv7iSuuXDJGDvJkmH_vz1qkDZYo1apxgzaxdBSeIuPiM.
|
|
20
|
+
nickname (str): Example: TikTok.
|
|
21
|
+
"""
|
|
22
|
+
|
|
23
|
+
id: str
|
|
24
|
+
username: str
|
|
25
|
+
sec_uid: str
|
|
26
|
+
nickname: str
|
|
27
|
+
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
|
|
28
|
+
|
|
29
|
+
def to_dict(self) -> dict[str, Any]:
|
|
30
|
+
id = self.id
|
|
31
|
+
|
|
32
|
+
username = self.username
|
|
33
|
+
|
|
34
|
+
sec_uid = self.sec_uid
|
|
35
|
+
|
|
36
|
+
nickname = self.nickname
|
|
37
|
+
|
|
38
|
+
field_dict: dict[str, Any] = {}
|
|
39
|
+
field_dict.update(self.additional_properties)
|
|
40
|
+
field_dict.update(
|
|
41
|
+
{
|
|
42
|
+
"id": id,
|
|
43
|
+
"username": username,
|
|
44
|
+
"sec_uid": sec_uid,
|
|
45
|
+
"nickname": nickname,
|
|
46
|
+
}
|
|
47
|
+
)
|
|
48
|
+
|
|
49
|
+
return field_dict
|
|
50
|
+
|
|
51
|
+
@classmethod
|
|
52
|
+
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
|
|
53
|
+
d = dict(src_dict)
|
|
54
|
+
id = d.pop("id")
|
|
55
|
+
|
|
56
|
+
username = d.pop("username")
|
|
57
|
+
|
|
58
|
+
sec_uid = d.pop("sec_uid")
|
|
59
|
+
|
|
60
|
+
nickname = d.pop("nickname")
|
|
61
|
+
|
|
62
|
+
playlist_author = cls(
|
|
63
|
+
id=id,
|
|
64
|
+
username=username,
|
|
65
|
+
sec_uid=sec_uid,
|
|
66
|
+
nickname=nickname,
|
|
67
|
+
)
|
|
68
|
+
|
|
69
|
+
playlist_author.additional_properties = d
|
|
70
|
+
return playlist_author
|
|
71
|
+
|
|
72
|
+
@property
|
|
73
|
+
def additional_keys(self) -> list[str]:
|
|
74
|
+
return list(self.additional_properties.keys())
|
|
75
|
+
|
|
76
|
+
def __getitem__(self, key: str) -> Any:
|
|
77
|
+
return self.additional_properties[key]
|
|
78
|
+
|
|
79
|
+
def __setitem__(self, key: str, value: Any) -> None:
|
|
80
|
+
self.additional_properties[key] = value
|
|
81
|
+
|
|
82
|
+
def __delitem__(self, key: str) -> None:
|
|
83
|
+
del self.additional_properties[key]
|
|
84
|
+
|
|
85
|
+
def __contains__(self, key: str) -> bool:
|
|
86
|
+
return key in self.additional_properties
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from collections.abc import Mapping
|
|
4
|
+
from typing import TYPE_CHECKING, Any, TypeVar
|
|
5
|
+
from uuid import UUID
|
|
6
|
+
|
|
7
|
+
from attrs import define as _attrs_define
|
|
8
|
+
from attrs import field as _attrs_field
|
|
9
|
+
|
|
10
|
+
from ..models.meta_cache import MetaCache
|
|
11
|
+
from ..types import UNSET, Unset
|
|
12
|
+
|
|
13
|
+
if TYPE_CHECKING:
|
|
14
|
+
from ..models.playlist import Playlist
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
T = TypeVar("T", bound="PlaylistPage")
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
@_attrs_define
|
|
21
|
+
class PlaylistPage:
|
|
22
|
+
"""
|
|
23
|
+
Attributes:
|
|
24
|
+
items (int): Objects returned.
|
|
25
|
+
credits_charged (float): Example: 16.
|
|
26
|
+
balance_remaining (float): Example: 79984.
|
|
27
|
+
cache (MetaCache): `miss`: read from TikTok, normal price. `hit`: from cache, half price. `bypass`: `fresh=true`
|
|
28
|
+
skipped a cached copy, 2x. A page that has cached and new items is `miss` (or `bypass`), and each item costs the
|
|
29
|
+
price of its own source; `hit` means all of it came from cache.
|
|
30
|
+
request_id (UUID):
|
|
31
|
+
data (list[Playlist]):
|
|
32
|
+
next_cursor (str | Unset):
|
|
33
|
+
"""
|
|
34
|
+
|
|
35
|
+
items: int
|
|
36
|
+
credits_charged: float
|
|
37
|
+
balance_remaining: float
|
|
38
|
+
cache: MetaCache
|
|
39
|
+
request_id: UUID
|
|
40
|
+
data: list[Playlist]
|
|
41
|
+
next_cursor: str | Unset = UNSET
|
|
42
|
+
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
|
|
43
|
+
|
|
44
|
+
def to_dict(self) -> dict[str, Any]:
|
|
45
|
+
items = self.items
|
|
46
|
+
|
|
47
|
+
credits_charged = self.credits_charged
|
|
48
|
+
|
|
49
|
+
balance_remaining = self.balance_remaining
|
|
50
|
+
|
|
51
|
+
cache = self.cache.value
|
|
52
|
+
|
|
53
|
+
request_id = str(self.request_id)
|
|
54
|
+
|
|
55
|
+
data = []
|
|
56
|
+
for data_item_data in self.data:
|
|
57
|
+
data_item = data_item_data.to_dict()
|
|
58
|
+
data.append(data_item)
|
|
59
|
+
|
|
60
|
+
next_cursor = self.next_cursor
|
|
61
|
+
|
|
62
|
+
field_dict: dict[str, Any] = {}
|
|
63
|
+
field_dict.update(self.additional_properties)
|
|
64
|
+
field_dict.update(
|
|
65
|
+
{
|
|
66
|
+
"items": items,
|
|
67
|
+
"credits_charged": credits_charged,
|
|
68
|
+
"balance_remaining": balance_remaining,
|
|
69
|
+
"cache": cache,
|
|
70
|
+
"request_id": request_id,
|
|
71
|
+
"data": data,
|
|
72
|
+
}
|
|
73
|
+
)
|
|
74
|
+
if next_cursor is not UNSET:
|
|
75
|
+
field_dict["next_cursor"] = next_cursor
|
|
76
|
+
|
|
77
|
+
return field_dict
|
|
78
|
+
|
|
79
|
+
@classmethod
|
|
80
|
+
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
|
|
81
|
+
from ..models.playlist import Playlist # noqa: PLC0415
|
|
82
|
+
|
|
83
|
+
d = dict(src_dict)
|
|
84
|
+
items = d.pop("items")
|
|
85
|
+
|
|
86
|
+
credits_charged = d.pop("credits_charged")
|
|
87
|
+
|
|
88
|
+
balance_remaining = d.pop("balance_remaining")
|
|
89
|
+
|
|
90
|
+
cache = MetaCache(d.pop("cache"))
|
|
91
|
+
|
|
92
|
+
request_id = UUID(d.pop("request_id"))
|
|
93
|
+
|
|
94
|
+
data = []
|
|
95
|
+
_data = d.pop("data")
|
|
96
|
+
for data_item_data in _data:
|
|
97
|
+
data_item = Playlist.from_dict(data_item_data)
|
|
98
|
+
|
|
99
|
+
data.append(data_item)
|
|
100
|
+
|
|
101
|
+
next_cursor = d.pop("next_cursor", UNSET)
|
|
102
|
+
|
|
103
|
+
playlist_page = cls(
|
|
104
|
+
items=items,
|
|
105
|
+
credits_charged=credits_charged,
|
|
106
|
+
balance_remaining=balance_remaining,
|
|
107
|
+
cache=cache,
|
|
108
|
+
request_id=request_id,
|
|
109
|
+
data=data,
|
|
110
|
+
next_cursor=next_cursor,
|
|
111
|
+
)
|
|
112
|
+
|
|
113
|
+
playlist_page.additional_properties = d
|
|
114
|
+
return playlist_page
|
|
115
|
+
|
|
116
|
+
@property
|
|
117
|
+
def additional_keys(self) -> list[str]:
|
|
118
|
+
return list(self.additional_properties.keys())
|
|
119
|
+
|
|
120
|
+
def __getitem__(self, key: str) -> Any:
|
|
121
|
+
return self.additional_properties[key]
|
|
122
|
+
|
|
123
|
+
def __setitem__(self, key: str, value: Any) -> None:
|
|
124
|
+
self.additional_properties[key] = value
|
|
125
|
+
|
|
126
|
+
def __delitem__(self, key: str) -> None:
|
|
127
|
+
del self.additional_properties[key]
|
|
128
|
+
|
|
129
|
+
def __contains__(self, key: str) -> bool:
|
|
130
|
+
return key in self.additional_properties
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from collections.abc import Mapping
|
|
4
|
+
from typing import TYPE_CHECKING, Any, TypeVar
|
|
5
|
+
|
|
6
|
+
from attrs import define as _attrs_define
|
|
7
|
+
from attrs import field as _attrs_field
|
|
8
|
+
|
|
9
|
+
from ..types import UNSET, Unset
|
|
10
|
+
|
|
11
|
+
if TYPE_CHECKING:
|
|
12
|
+
from ..models.error_body import ErrorBody
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
T = TypeVar("T", bound="Problem")
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
@_attrs_define
|
|
19
|
+
class Problem:
|
|
20
|
+
"""RFC 9457 view of the same failure, served when the caller sends
|
|
21
|
+
`Accept: application/problem+json`. Nothing new is reported — `type`, `title`,
|
|
22
|
+
`status` and `detail` are the registered names for what `error.code` and
|
|
23
|
+
`error.message` already said, so a generic client can read a failure it has no
|
|
24
|
+
specific handling for.
|
|
25
|
+
|
|
26
|
+
Attributes:
|
|
27
|
+
type_ (str): A page describing this error code. Example: https://tikdataapi.com/docs/errors#no_credits.
|
|
28
|
+
title (str): Example: Balance is zero.
|
|
29
|
+
status (int): Example: 402.
|
|
30
|
+
code (str): The same value as `error.code`. Stable; match on this, not on the text.
|
|
31
|
+
request_id (str):
|
|
32
|
+
detail (str | Unset): The same text as `error.message`.
|
|
33
|
+
error (ErrorBody | Unset): The failure itself. `code` is stable; match on it, never on `message`.
|
|
34
|
+
"""
|
|
35
|
+
|
|
36
|
+
type_: str
|
|
37
|
+
title: str
|
|
38
|
+
status: int
|
|
39
|
+
code: str
|
|
40
|
+
request_id: str
|
|
41
|
+
detail: str | Unset = UNSET
|
|
42
|
+
error: ErrorBody | Unset = UNSET
|
|
43
|
+
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
|
|
44
|
+
|
|
45
|
+
def to_dict(self) -> dict[str, Any]:
|
|
46
|
+
type_ = self.type_
|
|
47
|
+
|
|
48
|
+
title = self.title
|
|
49
|
+
|
|
50
|
+
status = self.status
|
|
51
|
+
|
|
52
|
+
code = self.code
|
|
53
|
+
|
|
54
|
+
request_id = self.request_id
|
|
55
|
+
|
|
56
|
+
detail = self.detail
|
|
57
|
+
|
|
58
|
+
error: dict[str, Any] | Unset = UNSET
|
|
59
|
+
if not isinstance(self.error, Unset):
|
|
60
|
+
error = self.error.to_dict()
|
|
61
|
+
|
|
62
|
+
field_dict: dict[str, Any] = {}
|
|
63
|
+
field_dict.update(self.additional_properties)
|
|
64
|
+
field_dict.update(
|
|
65
|
+
{
|
|
66
|
+
"type": type_,
|
|
67
|
+
"title": title,
|
|
68
|
+
"status": status,
|
|
69
|
+
"code": code,
|
|
70
|
+
"request_id": request_id,
|
|
71
|
+
}
|
|
72
|
+
)
|
|
73
|
+
if detail is not UNSET:
|
|
74
|
+
field_dict["detail"] = detail
|
|
75
|
+
if error is not UNSET:
|
|
76
|
+
field_dict["error"] = error
|
|
77
|
+
|
|
78
|
+
return field_dict
|
|
79
|
+
|
|
80
|
+
@classmethod
|
|
81
|
+
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
|
|
82
|
+
from ..models.error_body import ErrorBody # noqa: PLC0415
|
|
83
|
+
|
|
84
|
+
d = dict(src_dict)
|
|
85
|
+
type_ = d.pop("type")
|
|
86
|
+
|
|
87
|
+
title = d.pop("title")
|
|
88
|
+
|
|
89
|
+
status = d.pop("status")
|
|
90
|
+
|
|
91
|
+
code = d.pop("code")
|
|
92
|
+
|
|
93
|
+
request_id = d.pop("request_id")
|
|
94
|
+
|
|
95
|
+
detail = d.pop("detail", UNSET)
|
|
96
|
+
|
|
97
|
+
_error = d.pop("error", UNSET)
|
|
98
|
+
error: ErrorBody | Unset
|
|
99
|
+
if isinstance(_error, Unset):
|
|
100
|
+
error = UNSET
|
|
101
|
+
else:
|
|
102
|
+
error = ErrorBody.from_dict(_error)
|
|
103
|
+
|
|
104
|
+
problem = cls(
|
|
105
|
+
type_=type_,
|
|
106
|
+
title=title,
|
|
107
|
+
status=status,
|
|
108
|
+
code=code,
|
|
109
|
+
request_id=request_id,
|
|
110
|
+
detail=detail,
|
|
111
|
+
error=error,
|
|
112
|
+
)
|
|
113
|
+
|
|
114
|
+
problem.additional_properties = d
|
|
115
|
+
return problem
|
|
116
|
+
|
|
117
|
+
@property
|
|
118
|
+
def additional_keys(self) -> list[str]:
|
|
119
|
+
return list(self.additional_properties.keys())
|
|
120
|
+
|
|
121
|
+
def __getitem__(self, key: str) -> Any:
|
|
122
|
+
return self.additional_properties[key]
|
|
123
|
+
|
|
124
|
+
def __setitem__(self, key: str, value: Any) -> None:
|
|
125
|
+
self.additional_properties[key] = value
|
|
126
|
+
|
|
127
|
+
def __delitem__(self, key: str) -> None:
|
|
128
|
+
del self.additional_properties[key]
|
|
129
|
+
|
|
130
|
+
def __contains__(self, key: str) -> bool:
|
|
131
|
+
return key in self.additional_properties
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import datetime
|
|
4
|
+
from collections.abc import Mapping
|
|
5
|
+
from typing import TYPE_CHECKING, Any, TypeVar, cast
|
|
6
|
+
|
|
7
|
+
from attrs import define as _attrs_define
|
|
8
|
+
from attrs import field as _attrs_field
|
|
9
|
+
|
|
10
|
+
if TYPE_CHECKING:
|
|
11
|
+
from ..models.transcript_segment import TranscriptSegment
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
T = TypeVar("T", bound="Transcript")
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
@_attrs_define
|
|
18
|
+
class Transcript:
|
|
19
|
+
"""The transcript of a video, from the subtitles of TikTok. Most are made by its speech recognition
|
|
20
|
+
(`source` `ASR`); they can have errors.
|
|
21
|
+
|
|
22
|
+
Attributes:
|
|
23
|
+
video_id (str): Example: 7708543740230536461.
|
|
24
|
+
language (str): The language of this transcript, as TikTok names it. Example: eng-US.
|
|
25
|
+
source (str): Where the subtitles come from, as TikTok names it: `ASR` is speech recognition. Example: ASR.
|
|
26
|
+
languages (list[str]): Every language that the video has subtitles in. Pick one with `lang`. Example: ['eng-US',
|
|
27
|
+
'deu-DE'].
|
|
28
|
+
segments (list[TranscriptSegment]):
|
|
29
|
+
text (str): The text of the segments Example: hello everyone welcome back.
|
|
30
|
+
collected_at (datetime.datetime): When we read this transcript from TikTok. A transcript from cache keeps the
|
|
31
|
+
time of its own read. Example: 2026-12-03T19:45:00Z.
|
|
32
|
+
"""
|
|
33
|
+
|
|
34
|
+
video_id: str
|
|
35
|
+
language: str
|
|
36
|
+
source: str
|
|
37
|
+
languages: list[str]
|
|
38
|
+
segments: list[TranscriptSegment]
|
|
39
|
+
text: str
|
|
40
|
+
collected_at: datetime.datetime
|
|
41
|
+
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
|
|
42
|
+
|
|
43
|
+
def to_dict(self) -> dict[str, Any]:
|
|
44
|
+
video_id = self.video_id
|
|
45
|
+
|
|
46
|
+
language = self.language
|
|
47
|
+
|
|
48
|
+
source = self.source
|
|
49
|
+
|
|
50
|
+
languages = self.languages
|
|
51
|
+
|
|
52
|
+
segments = []
|
|
53
|
+
for segments_item_data in self.segments:
|
|
54
|
+
segments_item = segments_item_data.to_dict()
|
|
55
|
+
segments.append(segments_item)
|
|
56
|
+
|
|
57
|
+
text = self.text
|
|
58
|
+
|
|
59
|
+
collected_at = self.collected_at.isoformat()
|
|
60
|
+
|
|
61
|
+
field_dict: dict[str, Any] = {}
|
|
62
|
+
field_dict.update(self.additional_properties)
|
|
63
|
+
field_dict.update(
|
|
64
|
+
{
|
|
65
|
+
"video_id": video_id,
|
|
66
|
+
"language": language,
|
|
67
|
+
"source": source,
|
|
68
|
+
"languages": languages,
|
|
69
|
+
"segments": segments,
|
|
70
|
+
"text": text,
|
|
71
|
+
"collected_at": collected_at,
|
|
72
|
+
}
|
|
73
|
+
)
|
|
74
|
+
|
|
75
|
+
return field_dict
|
|
76
|
+
|
|
77
|
+
@classmethod
|
|
78
|
+
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
|
|
79
|
+
from ..models.transcript_segment import TranscriptSegment # noqa: PLC0415
|
|
80
|
+
|
|
81
|
+
d = dict(src_dict)
|
|
82
|
+
video_id = d.pop("video_id")
|
|
83
|
+
|
|
84
|
+
language = d.pop("language")
|
|
85
|
+
|
|
86
|
+
source = d.pop("source")
|
|
87
|
+
|
|
88
|
+
languages = cast(list[str], d.pop("languages"))
|
|
89
|
+
|
|
90
|
+
segments = []
|
|
91
|
+
_segments = d.pop("segments")
|
|
92
|
+
for segments_item_data in _segments:
|
|
93
|
+
segments_item = TranscriptSegment.from_dict(segments_item_data)
|
|
94
|
+
|
|
95
|
+
segments.append(segments_item)
|
|
96
|
+
|
|
97
|
+
text = d.pop("text")
|
|
98
|
+
|
|
99
|
+
collected_at = datetime.datetime.fromisoformat(d.pop("collected_at"))
|
|
100
|
+
|
|
101
|
+
transcript = cls(
|
|
102
|
+
video_id=video_id,
|
|
103
|
+
language=language,
|
|
104
|
+
source=source,
|
|
105
|
+
languages=languages,
|
|
106
|
+
segments=segments,
|
|
107
|
+
text=text,
|
|
108
|
+
collected_at=collected_at,
|
|
109
|
+
)
|
|
110
|
+
|
|
111
|
+
transcript.additional_properties = d
|
|
112
|
+
return transcript
|
|
113
|
+
|
|
114
|
+
@property
|
|
115
|
+
def additional_keys(self) -> list[str]:
|
|
116
|
+
return list(self.additional_properties.keys())
|
|
117
|
+
|
|
118
|
+
def __getitem__(self, key: str) -> Any:
|
|
119
|
+
return self.additional_properties[key]
|
|
120
|
+
|
|
121
|
+
def __setitem__(self, key: str, value: Any) -> None:
|
|
122
|
+
self.additional_properties[key] = value
|
|
123
|
+
|
|
124
|
+
def __delitem__(self, key: str) -> None:
|
|
125
|
+
del self.additional_properties[key]
|
|
126
|
+
|
|
127
|
+
def __contains__(self, key: str) -> bool:
|
|
128
|
+
return key in self.additional_properties
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from collections.abc import Mapping
|
|
4
|
+
from typing import TYPE_CHECKING, Any, TypeVar
|
|
5
|
+
from uuid import UUID
|
|
6
|
+
|
|
7
|
+
from attrs import define as _attrs_define
|
|
8
|
+
from attrs import field as _attrs_field
|
|
9
|
+
|
|
10
|
+
from ..models.meta_cache import MetaCache
|
|
11
|
+
from ..types import UNSET, Unset
|
|
12
|
+
|
|
13
|
+
if TYPE_CHECKING:
|
|
14
|
+
from ..models.transcript import Transcript
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
T = TypeVar("T", bound="TranscriptResponse")
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
@_attrs_define
|
|
21
|
+
class TranscriptResponse:
|
|
22
|
+
"""
|
|
23
|
+
Attributes:
|
|
24
|
+
items (int): Objects returned.
|
|
25
|
+
credits_charged (float): Example: 16.
|
|
26
|
+
balance_remaining (float): Example: 79984.
|
|
27
|
+
cache (MetaCache): `miss`: read from TikTok, normal price. `hit`: from cache, half price. `bypass`: `fresh=true`
|
|
28
|
+
skipped a cached copy, 2x. A page that has cached and new items is `miss` (or `bypass`), and each item costs the
|
|
29
|
+
price of its own source; `hit` means all of it came from cache.
|
|
30
|
+
request_id (UUID):
|
|
31
|
+
data (Transcript): The transcript of a video, from the subtitles of TikTok. Most are made by its speech
|
|
32
|
+
recognition
|
|
33
|
+
(`source` `ASR`); they can have errors.
|
|
34
|
+
next_cursor (str | Unset):
|
|
35
|
+
"""
|
|
36
|
+
|
|
37
|
+
items: int
|
|
38
|
+
credits_charged: float
|
|
39
|
+
balance_remaining: float
|
|
40
|
+
cache: MetaCache
|
|
41
|
+
request_id: UUID
|
|
42
|
+
data: Transcript
|
|
43
|
+
next_cursor: str | Unset = UNSET
|
|
44
|
+
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
|
|
45
|
+
|
|
46
|
+
def to_dict(self) -> dict[str, Any]:
|
|
47
|
+
items = self.items
|
|
48
|
+
|
|
49
|
+
credits_charged = self.credits_charged
|
|
50
|
+
|
|
51
|
+
balance_remaining = self.balance_remaining
|
|
52
|
+
|
|
53
|
+
cache = self.cache.value
|
|
54
|
+
|
|
55
|
+
request_id = str(self.request_id)
|
|
56
|
+
|
|
57
|
+
data = self.data.to_dict()
|
|
58
|
+
|
|
59
|
+
next_cursor = self.next_cursor
|
|
60
|
+
|
|
61
|
+
field_dict: dict[str, Any] = {}
|
|
62
|
+
field_dict.update(self.additional_properties)
|
|
63
|
+
field_dict.update(
|
|
64
|
+
{
|
|
65
|
+
"items": items,
|
|
66
|
+
"credits_charged": credits_charged,
|
|
67
|
+
"balance_remaining": balance_remaining,
|
|
68
|
+
"cache": cache,
|
|
69
|
+
"request_id": request_id,
|
|
70
|
+
"data": data,
|
|
71
|
+
}
|
|
72
|
+
)
|
|
73
|
+
if next_cursor is not UNSET:
|
|
74
|
+
field_dict["next_cursor"] = next_cursor
|
|
75
|
+
|
|
76
|
+
return field_dict
|
|
77
|
+
|
|
78
|
+
@classmethod
|
|
79
|
+
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
|
|
80
|
+
from ..models.transcript import Transcript # noqa: PLC0415
|
|
81
|
+
|
|
82
|
+
d = dict(src_dict)
|
|
83
|
+
items = d.pop("items")
|
|
84
|
+
|
|
85
|
+
credits_charged = d.pop("credits_charged")
|
|
86
|
+
|
|
87
|
+
balance_remaining = d.pop("balance_remaining")
|
|
88
|
+
|
|
89
|
+
cache = MetaCache(d.pop("cache"))
|
|
90
|
+
|
|
91
|
+
request_id = UUID(d.pop("request_id"))
|
|
92
|
+
|
|
93
|
+
data = Transcript.from_dict(d.pop("data"))
|
|
94
|
+
|
|
95
|
+
next_cursor = d.pop("next_cursor", UNSET)
|
|
96
|
+
|
|
97
|
+
transcript_response = cls(
|
|
98
|
+
items=items,
|
|
99
|
+
credits_charged=credits_charged,
|
|
100
|
+
balance_remaining=balance_remaining,
|
|
101
|
+
cache=cache,
|
|
102
|
+
request_id=request_id,
|
|
103
|
+
data=data,
|
|
104
|
+
next_cursor=next_cursor,
|
|
105
|
+
)
|
|
106
|
+
|
|
107
|
+
transcript_response.additional_properties = d
|
|
108
|
+
return transcript_response
|
|
109
|
+
|
|
110
|
+
@property
|
|
111
|
+
def additional_keys(self) -> list[str]:
|
|
112
|
+
return list(self.additional_properties.keys())
|
|
113
|
+
|
|
114
|
+
def __getitem__(self, key: str) -> Any:
|
|
115
|
+
return self.additional_properties[key]
|
|
116
|
+
|
|
117
|
+
def __setitem__(self, key: str, value: Any) -> None:
|
|
118
|
+
self.additional_properties[key] = value
|
|
119
|
+
|
|
120
|
+
def __delitem__(self, key: str) -> None:
|
|
121
|
+
del self.additional_properties[key]
|
|
122
|
+
|
|
123
|
+
def __contains__(self, key: str) -> bool:
|
|
124
|
+
return key in self.additional_properties
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from collections.abc import Mapping
|
|
4
|
+
from typing import Any, TypeVar
|
|
5
|
+
|
|
6
|
+
from attrs import define as _attrs_define
|
|
7
|
+
from attrs import field as _attrs_field
|
|
8
|
+
|
|
9
|
+
T = TypeVar("T", bound="TranscriptSegment")
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
@_attrs_define
|
|
13
|
+
class TranscriptSegment:
|
|
14
|
+
"""
|
|
15
|
+
Attributes:
|
|
16
|
+
start (float): Seconds from the start of the video. Example: 0.12.
|
|
17
|
+
end (float): Seconds from the start of the video. Example: 1.5.
|
|
18
|
+
text (str): Example: hello everyone.
|
|
19
|
+
"""
|
|
20
|
+
|
|
21
|
+
start: float
|
|
22
|
+
end: float
|
|
23
|
+
text: str
|
|
24
|
+
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
|
|
25
|
+
|
|
26
|
+
def to_dict(self) -> dict[str, Any]:
|
|
27
|
+
start = self.start
|
|
28
|
+
|
|
29
|
+
end = self.end
|
|
30
|
+
|
|
31
|
+
text = self.text
|
|
32
|
+
|
|
33
|
+
field_dict: dict[str, Any] = {}
|
|
34
|
+
field_dict.update(self.additional_properties)
|
|
35
|
+
field_dict.update(
|
|
36
|
+
{
|
|
37
|
+
"start": start,
|
|
38
|
+
"end": end,
|
|
39
|
+
"text": text,
|
|
40
|
+
}
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
return field_dict
|
|
44
|
+
|
|
45
|
+
@classmethod
|
|
46
|
+
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
|
|
47
|
+
d = dict(src_dict)
|
|
48
|
+
start = d.pop("start")
|
|
49
|
+
|
|
50
|
+
end = d.pop("end")
|
|
51
|
+
|
|
52
|
+
text = d.pop("text")
|
|
53
|
+
|
|
54
|
+
transcript_segment = cls(
|
|
55
|
+
start=start,
|
|
56
|
+
end=end,
|
|
57
|
+
text=text,
|
|
58
|
+
)
|
|
59
|
+
|
|
60
|
+
transcript_segment.additional_properties = d
|
|
61
|
+
return transcript_segment
|
|
62
|
+
|
|
63
|
+
@property
|
|
64
|
+
def additional_keys(self) -> list[str]:
|
|
65
|
+
return list(self.additional_properties.keys())
|
|
66
|
+
|
|
67
|
+
def __getitem__(self, key: str) -> Any:
|
|
68
|
+
return self.additional_properties[key]
|
|
69
|
+
|
|
70
|
+
def __setitem__(self, key: str, value: Any) -> None:
|
|
71
|
+
self.additional_properties[key] = value
|
|
72
|
+
|
|
73
|
+
def __delitem__(self, key: str) -> None:
|
|
74
|
+
del self.additional_properties[key]
|
|
75
|
+
|
|
76
|
+
def __contains__(self, key: str) -> bool:
|
|
77
|
+
return key in self.additional_properties
|