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.
Files changed (103) hide show
  1. tikdataapi/__init__.py +8 -0
  2. tikdataapi/api/__init__.py +1 -0
  3. tikdataapi/api/account/__init__.py +1 -0
  4. tikdataapi/api/account/get_me.py +144 -0
  5. tikdataapi/api/billing/__init__.py +1 -0
  6. tikdataapi/api/billing/create_checkout.py +215 -0
  7. tikdataapi/api/billing/list_packs.py +144 -0
  8. tikdataapi/api/hashtags/__init__.py +1 -0
  9. tikdataapi/api/hashtags/get_hashtag.py +220 -0
  10. tikdataapi/api/hashtags/get_hashtag_videos.py +250 -0
  11. tikdataapi/api/music/__init__.py +1 -0
  12. tikdataapi/api/music/get_music.py +234 -0
  13. tikdataapi/api/music/get_music_videos.py +254 -0
  14. tikdataapi/api/playlists/__init__.py +1 -0
  15. tikdataapi/api/playlists/get_playlist_videos.py +258 -0
  16. tikdataapi/api/search/__init__.py +1 -0
  17. tikdataapi/api/search/search_hashtags.py +261 -0
  18. tikdataapi/api/search/search_live.py +258 -0
  19. tikdataapi/api/search/search_music.py +260 -0
  20. tikdataapi/api/search/search_users.py +276 -0
  21. tikdataapi/api/search/search_videos.py +260 -0
  22. tikdataapi/api/users/__init__.py +1 -0
  23. tikdataapi/api/users/get_user.py +222 -0
  24. tikdataapi/api/users/get_user_followers.py +266 -0
  25. tikdataapi/api/users/get_user_following.py +266 -0
  26. tikdataapi/api/users/get_user_live.py +236 -0
  27. tikdataapi/api/users/get_user_playlists.py +276 -0
  28. tikdataapi/api/users/get_user_reposts.py +266 -0
  29. tikdataapi/api/users/get_user_videos.py +254 -0
  30. tikdataapi/api/users/get_users.py +247 -0
  31. tikdataapi/api/users/get_users_videos.py +259 -0
  32. tikdataapi/api/videos/__init__.py +1 -0
  33. tikdataapi/api/videos/get_comment_replies.py +260 -0
  34. tikdataapi/api/videos/get_comments.py +258 -0
  35. tikdataapi/api/videos/get_related_videos.py +247 -0
  36. tikdataapi/api/videos/get_trending_videos.py +238 -0
  37. tikdataapi/api/videos/get_video.py +218 -0
  38. tikdataapi/api/videos/get_video_transcript.py +247 -0
  39. tikdataapi/api/videos/get_videos.py +235 -0
  40. tikdataapi/client.py +268 -0
  41. tikdataapi/errors.py +16 -0
  42. tikdataapi/models/__init__.py +117 -0
  43. tikdataapi/models/batch_error.py +104 -0
  44. tikdataapi/models/batch_error_code.py +15 -0
  45. tikdataapi/models/batch_meta.py +127 -0
  46. tikdataapi/models/batch_meta_cache.py +11 -0
  47. tikdataapi/models/comment.py +163 -0
  48. tikdataapi/models/comment_author.py +97 -0
  49. tikdataapi/models/comment_page.py +130 -0
  50. tikdataapi/models/create_checkout_body.py +63 -0
  51. tikdataapi/models/create_checkout_body_pack.py +11 -0
  52. tikdataapi/models/create_checkout_response_200.py +97 -0
  53. tikdataapi/models/error.py +78 -0
  54. tikdataapi/models/error_body.py +107 -0
  55. tikdataapi/models/error_body_code.py +22 -0
  56. tikdataapi/models/get_me_response_200.py +88 -0
  57. tikdataapi/models/get_users_body.py +61 -0
  58. tikdataapi/models/get_users_videos_body.py +72 -0
  59. tikdataapi/models/get_videos_body.py +61 -0
  60. tikdataapi/models/hashtag.py +124 -0
  61. tikdataapi/models/hashtag_response.py +122 -0
  62. tikdataapi/models/hashtag_summary.py +98 -0
  63. tikdataapi/models/hashtag_summary_page.py +130 -0
  64. tikdataapi/models/list_packs_response_200.py +103 -0
  65. tikdataapi/models/list_packs_response_200_data_item.py +88 -0
  66. tikdataapi/models/list_packs_response_200_rate_limits_item.py +70 -0
  67. tikdataapi/models/live_room.py +142 -0
  68. tikdataapi/models/live_room_author.py +90 -0
  69. tikdataapi/models/live_room_page.py +130 -0
  70. tikdataapi/models/live_room_response.py +124 -0
  71. tikdataapi/models/meta.py +108 -0
  72. tikdataapi/models/meta_cache.py +10 -0
  73. tikdataapi/models/music.py +107 -0
  74. tikdataapi/models/music_detail.py +172 -0
  75. tikdataapi/models/music_response.py +124 -0
  76. tikdataapi/models/music_summary.py +137 -0
  77. tikdataapi/models/music_summary_page.py +130 -0
  78. tikdataapi/models/not_found_reason.py +12 -0
  79. tikdataapi/models/playlist.py +114 -0
  80. tikdataapi/models/playlist_author.py +86 -0
  81. tikdataapi/models/playlist_page.py +130 -0
  82. tikdataapi/models/problem.py +131 -0
  83. tikdataapi/models/transcript.py +128 -0
  84. tikdataapi/models/transcript_response.py +124 -0
  85. tikdataapi/models/transcript_segment.py +77 -0
  86. tikdataapi/models/user.py +207 -0
  87. tikdataapi/models/user_batch.py +145 -0
  88. tikdataapi/models/user_page.py +130 -0
  89. tikdataapi/models/user_response.py +126 -0
  90. tikdataapi/models/user_summary.py +152 -0
  91. tikdataapi/models/user_summary_page.py +130 -0
  92. tikdataapi/models/user_videos.py +96 -0
  93. tikdataapi/models/user_videos_batch.py +145 -0
  94. tikdataapi/models/video.py +297 -0
  95. tikdataapi/models/video_batch.py +145 -0
  96. tikdataapi/models/video_page.py +130 -0
  97. tikdataapi/models/video_response.py +122 -0
  98. tikdataapi/models/video_type.py +9 -0
  99. tikdataapi/py.typed +1 -0
  100. tikdataapi/types.py +54 -0
  101. tikdataapi-0.1.0.dist-info/METADATA +148 -0
  102. tikdataapi-0.1.0.dist-info/RECORD +103 -0
  103. tikdataapi-0.1.0.dist-info/WHEEL +4 -0
@@ -0,0 +1,98 @@
1
+ from __future__ import annotations
2
+
3
+ import datetime
4
+ from collections.abc import Mapping
5
+ from typing import Any, TypeVar
6
+
7
+ from attrs import define as _attrs_define
8
+ from attrs import field as _attrs_field
9
+
10
+ T = TypeVar("T", bound="HashtagSummary")
11
+
12
+
13
+ @_attrs_define
14
+ class HashtagSummary:
15
+ """A hashtag found by hashtag search. TikTok gives a logged-out visitor no hashtag search, so the
16
+ counts are of the videos of the general search for the query, not of all of TikTok. For the totals of
17
+ TikTok (all videos, all views), read `/v1/hashtags/{name}`.
18
+
19
+ Attributes:
20
+ name (str): Without `#`, in lower case: the name that `/v1/hashtags/{name}` takes. Example: recipe.
21
+ url (str): Example: https://www.tiktok.com/tag/recipe.
22
+ result_videos (int): The videos of the search results that use this hashtag. Example: 6.
23
+ result_plays (int): The sum of the plays of those videos. Example: 18400000.
24
+ collected_at (datetime.datetime): When we read the newest of those videos from TikTok. Example:
25
+ 2026-12-03T20:00:00Z.
26
+ """
27
+
28
+ name: str
29
+ url: str
30
+ result_videos: int
31
+ result_plays: int
32
+ collected_at: datetime.datetime
33
+ additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
34
+
35
+ def to_dict(self) -> dict[str, Any]:
36
+ name = self.name
37
+
38
+ url = self.url
39
+
40
+ result_videos = self.result_videos
41
+
42
+ result_plays = self.result_plays
43
+
44
+ collected_at = self.collected_at.isoformat()
45
+
46
+ field_dict: dict[str, Any] = {}
47
+ field_dict.update(self.additional_properties)
48
+ field_dict.update(
49
+ {
50
+ "name": name,
51
+ "url": url,
52
+ "result_videos": result_videos,
53
+ "result_plays": result_plays,
54
+ "collected_at": collected_at,
55
+ }
56
+ )
57
+
58
+ return field_dict
59
+
60
+ @classmethod
61
+ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
62
+ d = dict(src_dict)
63
+ name = d.pop("name")
64
+
65
+ url = d.pop("url")
66
+
67
+ result_videos = d.pop("result_videos")
68
+
69
+ result_plays = d.pop("result_plays")
70
+
71
+ collected_at = datetime.datetime.fromisoformat(d.pop("collected_at"))
72
+
73
+ hashtag_summary = cls(
74
+ name=name,
75
+ url=url,
76
+ result_videos=result_videos,
77
+ result_plays=result_plays,
78
+ collected_at=collected_at,
79
+ )
80
+
81
+ hashtag_summary.additional_properties = d
82
+ return hashtag_summary
83
+
84
+ @property
85
+ def additional_keys(self) -> list[str]:
86
+ return list(self.additional_properties.keys())
87
+
88
+ def __getitem__(self, key: str) -> Any:
89
+ return self.additional_properties[key]
90
+
91
+ def __setitem__(self, key: str, value: Any) -> None:
92
+ self.additional_properties[key] = value
93
+
94
+ def __delitem__(self, key: str) -> None:
95
+ del self.additional_properties[key]
96
+
97
+ def __contains__(self, key: str) -> bool:
98
+ 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.hashtag_summary import HashtagSummary
15
+
16
+
17
+ T = TypeVar("T", bound="HashtagSummaryPage")
18
+
19
+
20
+ @_attrs_define
21
+ class HashtagSummaryPage:
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[HashtagSummary]):
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[HashtagSummary]
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.hashtag_summary import HashtagSummary # 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 = HashtagSummary.from_dict(data_item_data)
98
+
99
+ data.append(data_item)
100
+
101
+ next_cursor = d.pop("next_cursor", UNSET)
102
+
103
+ hashtag_summary_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
+ hashtag_summary_page.additional_properties = d
114
+ return hashtag_summary_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,103 @@
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.list_packs_response_200_data_item import ListPacksResponse200DataItem
13
+ from ..models.list_packs_response_200_rate_limits_item import ListPacksResponse200RateLimitsItem
14
+
15
+
16
+ T = TypeVar("T", bound="ListPacksResponse200")
17
+
18
+
19
+ @_attrs_define
20
+ class ListPacksResponse200:
21
+ """
22
+ Attributes:
23
+ data (list[ListPacksResponse200DataItem] | Unset):
24
+ rate_limits (list[ListPacksResponse200RateLimitsItem] | Unset): Requests per second by the total paid over the
25
+ account's life. The limit only goes up.
26
+ """
27
+
28
+ data: list[ListPacksResponse200DataItem] | Unset = UNSET
29
+ rate_limits: list[ListPacksResponse200RateLimitsItem] | Unset = UNSET
30
+ additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
31
+
32
+ def to_dict(self) -> dict[str, Any]:
33
+ data: list[dict[str, Any]] | Unset = UNSET
34
+ if not isinstance(self.data, Unset):
35
+ data = []
36
+ for data_item_data in self.data:
37
+ data_item = data_item_data.to_dict()
38
+ data.append(data_item)
39
+
40
+ rate_limits: list[dict[str, Any]] | Unset = UNSET
41
+ if not isinstance(self.rate_limits, Unset):
42
+ rate_limits = []
43
+ for rate_limits_item_data in self.rate_limits:
44
+ rate_limits_item = rate_limits_item_data.to_dict()
45
+ rate_limits.append(rate_limits_item)
46
+
47
+ field_dict: dict[str, Any] = {}
48
+ field_dict.update(self.additional_properties)
49
+ field_dict.update({})
50
+ if data is not UNSET:
51
+ field_dict["data"] = data
52
+ if rate_limits is not UNSET:
53
+ field_dict["rate_limits"] = rate_limits
54
+
55
+ return field_dict
56
+
57
+ @classmethod
58
+ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
59
+ from ..models.list_packs_response_200_data_item import ListPacksResponse200DataItem # noqa: PLC0415
60
+ from ..models.list_packs_response_200_rate_limits_item import ListPacksResponse200RateLimitsItem # noqa: PLC0415
61
+
62
+ d = dict(src_dict)
63
+ _data = d.pop("data", UNSET)
64
+ data: list[ListPacksResponse200DataItem] | Unset = UNSET
65
+ if _data is not UNSET:
66
+ data = []
67
+ for data_item_data in _data:
68
+ data_item = ListPacksResponse200DataItem.from_dict(data_item_data)
69
+
70
+ data.append(data_item)
71
+
72
+ _rate_limits = d.pop("rate_limits", UNSET)
73
+ rate_limits: list[ListPacksResponse200RateLimitsItem] | Unset = UNSET
74
+ if _rate_limits is not UNSET:
75
+ rate_limits = []
76
+ for rate_limits_item_data in _rate_limits:
77
+ rate_limits_item = ListPacksResponse200RateLimitsItem.from_dict(rate_limits_item_data)
78
+
79
+ rate_limits.append(rate_limits_item)
80
+
81
+ list_packs_response_200 = cls(
82
+ data=data,
83
+ rate_limits=rate_limits,
84
+ )
85
+
86
+ list_packs_response_200.additional_properties = d
87
+ return list_packs_response_200
88
+
89
+ @property
90
+ def additional_keys(self) -> list[str]:
91
+ return list(self.additional_properties.keys())
92
+
93
+ def __getitem__(self, key: str) -> Any:
94
+ return self.additional_properties[key]
95
+
96
+ def __setitem__(self, key: str, value: Any) -> None:
97
+ self.additional_properties[key] = value
98
+
99
+ def __delitem__(self, key: str) -> None:
100
+ del self.additional_properties[key]
101
+
102
+ def __contains__(self, key: str) -> bool:
103
+ return key in self.additional_properties
@@ -0,0 +1,88 @@
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
+ from ..types import UNSET, Unset
10
+
11
+ T = TypeVar("T", bound="ListPacksResponse200DataItem")
12
+
13
+
14
+ @_attrs_define
15
+ class ListPacksResponse200DataItem:
16
+ """
17
+ Attributes:
18
+ name (str | Unset): Example: starter.
19
+ usd (int | Unset): Example: 10.
20
+ credits_ (int | Unset): Example: 80000.
21
+ buyable (bool | Unset):
22
+ """
23
+
24
+ name: str | Unset = UNSET
25
+ usd: int | Unset = UNSET
26
+ credits_: int | Unset = UNSET
27
+ buyable: bool | Unset = UNSET
28
+ additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
29
+
30
+ def to_dict(self) -> dict[str, Any]:
31
+ name = self.name
32
+
33
+ usd = self.usd
34
+
35
+ credits_ = self.credits_
36
+
37
+ buyable = self.buyable
38
+
39
+ field_dict: dict[str, Any] = {}
40
+ field_dict.update(self.additional_properties)
41
+ field_dict.update({})
42
+ if name is not UNSET:
43
+ field_dict["name"] = name
44
+ if usd is not UNSET:
45
+ field_dict["usd"] = usd
46
+ if credits_ is not UNSET:
47
+ field_dict["credits"] = credits_
48
+ if buyable is not UNSET:
49
+ field_dict["buyable"] = buyable
50
+
51
+ return field_dict
52
+
53
+ @classmethod
54
+ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
55
+ d = dict(src_dict)
56
+ name = d.pop("name", UNSET)
57
+
58
+ usd = d.pop("usd", UNSET)
59
+
60
+ credits_ = d.pop("credits", UNSET)
61
+
62
+ buyable = d.pop("buyable", UNSET)
63
+
64
+ list_packs_response_200_data_item = cls(
65
+ name=name,
66
+ usd=usd,
67
+ credits_=credits_,
68
+ buyable=buyable,
69
+ )
70
+
71
+ list_packs_response_200_data_item.additional_properties = d
72
+ return list_packs_response_200_data_item
73
+
74
+ @property
75
+ def additional_keys(self) -> list[str]:
76
+ return list(self.additional_properties.keys())
77
+
78
+ def __getitem__(self, key: str) -> Any:
79
+ return self.additional_properties[key]
80
+
81
+ def __setitem__(self, key: str, value: Any) -> None:
82
+ self.additional_properties[key] = value
83
+
84
+ def __delitem__(self, key: str) -> None:
85
+ del self.additional_properties[key]
86
+
87
+ def __contains__(self, key: str) -> bool:
88
+ return key in self.additional_properties
@@ -0,0 +1,70 @@
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
+ from ..types import UNSET, Unset
10
+
11
+ T = TypeVar("T", bound="ListPacksResponse200RateLimitsItem")
12
+
13
+
14
+ @_attrs_define
15
+ class ListPacksResponse200RateLimitsItem:
16
+ """
17
+ Attributes:
18
+ paid_usd (int | Unset): Example: 10.
19
+ requests_per_second (int | Unset): Example: 20.
20
+ """
21
+
22
+ paid_usd: int | Unset = UNSET
23
+ requests_per_second: int | Unset = UNSET
24
+ additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
25
+
26
+ def to_dict(self) -> dict[str, Any]:
27
+ paid_usd = self.paid_usd
28
+
29
+ requests_per_second = self.requests_per_second
30
+
31
+ field_dict: dict[str, Any] = {}
32
+ field_dict.update(self.additional_properties)
33
+ field_dict.update({})
34
+ if paid_usd is not UNSET:
35
+ field_dict["paid_usd"] = paid_usd
36
+ if requests_per_second is not UNSET:
37
+ field_dict["requests_per_second"] = requests_per_second
38
+
39
+ return field_dict
40
+
41
+ @classmethod
42
+ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
43
+ d = dict(src_dict)
44
+ paid_usd = d.pop("paid_usd", UNSET)
45
+
46
+ requests_per_second = d.pop("requests_per_second", UNSET)
47
+
48
+ list_packs_response_200_rate_limits_item = cls(
49
+ paid_usd=paid_usd,
50
+ requests_per_second=requests_per_second,
51
+ )
52
+
53
+ list_packs_response_200_rate_limits_item.additional_properties = d
54
+ return list_packs_response_200_rate_limits_item
55
+
56
+ @property
57
+ def additional_keys(self) -> list[str]:
58
+ return list(self.additional_properties.keys())
59
+
60
+ def __getitem__(self, key: str) -> Any:
61
+ return self.additional_properties[key]
62
+
63
+ def __setitem__(self, key: str, value: Any) -> None:
64
+ self.additional_properties[key] = value
65
+
66
+ def __delitem__(self, key: str) -> None:
67
+ del self.additional_properties[key]
68
+
69
+ def __contains__(self, key: str) -> bool:
70
+ return key in self.additional_properties
@@ -0,0 +1,142 @@
1
+ from __future__ import annotations
2
+
3
+ import datetime
4
+ from collections.abc import Mapping
5
+ from typing import TYPE_CHECKING, Any, TypeVar
6
+
7
+ from attrs import define as _attrs_define
8
+ from attrs import field as _attrs_field
9
+
10
+ from ..types import UNSET, Unset
11
+
12
+ if TYPE_CHECKING:
13
+ from ..models.live_room_author import LiveRoomAuthor
14
+
15
+
16
+ T = TypeVar("T", bound="LiveRoom")
17
+
18
+
19
+ @_attrs_define
20
+ class LiveRoom:
21
+ """A live room of TikTok: an entry of a live search, or the live state of an account. No stream
22
+ addresses. For an account that is not live, `live` is `false` and the room fields (`room_id`,
23
+ `title`, `viewers`, `started_at`, `cover_url`) are absent.
24
+
25
+ Attributes:
26
+ live (bool): `true`: the room is live now.
27
+ author (LiveRoomAuthor): The account that hosts a live room.
28
+ collected_at (datetime.datetime): When we read this room from TikTok. A room from cache keeps the time of its
29
+ own read. Example: 2026-12-03T19:45:00Z.
30
+ room_id (str | Unset): The id of the room. Absent when the account is not live. Example: 7578012345678901234.
31
+ title (str | Unset): Example: Cooking dinner.
32
+ viewers (int | Unset): Viewers in the room now. Example: 1250.
33
+ started_at (datetime.datetime | Unset): When the live began. Example: 2026-12-03T19:02:11Z.
34
+ cover_url (str | Unset): Signed image address; it stops working after some days.
35
+ """
36
+
37
+ live: bool
38
+ author: LiveRoomAuthor
39
+ collected_at: datetime.datetime
40
+ room_id: str | Unset = UNSET
41
+ title: str | Unset = UNSET
42
+ viewers: int | Unset = UNSET
43
+ started_at: datetime.datetime | Unset = UNSET
44
+ cover_url: str | Unset = UNSET
45
+ additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
46
+
47
+ def to_dict(self) -> dict[str, Any]:
48
+ live = self.live
49
+
50
+ author = self.author.to_dict()
51
+
52
+ collected_at = self.collected_at.isoformat()
53
+
54
+ room_id = self.room_id
55
+
56
+ title = self.title
57
+
58
+ viewers = self.viewers
59
+
60
+ started_at: str | Unset = UNSET
61
+ if not isinstance(self.started_at, Unset):
62
+ started_at = self.started_at.isoformat()
63
+
64
+ cover_url = self.cover_url
65
+
66
+ field_dict: dict[str, Any] = {}
67
+ field_dict.update(self.additional_properties)
68
+ field_dict.update(
69
+ {
70
+ "live": live,
71
+ "author": author,
72
+ "collected_at": collected_at,
73
+ }
74
+ )
75
+ if room_id is not UNSET:
76
+ field_dict["room_id"] = room_id
77
+ if title is not UNSET:
78
+ field_dict["title"] = title
79
+ if viewers is not UNSET:
80
+ field_dict["viewers"] = viewers
81
+ if started_at is not UNSET:
82
+ field_dict["started_at"] = started_at
83
+ if cover_url is not UNSET:
84
+ field_dict["cover_url"] = cover_url
85
+
86
+ return field_dict
87
+
88
+ @classmethod
89
+ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
90
+ from ..models.live_room_author import LiveRoomAuthor # noqa: PLC0415
91
+
92
+ d = dict(src_dict)
93
+ live = d.pop("live")
94
+
95
+ author = LiveRoomAuthor.from_dict(d.pop("author"))
96
+
97
+ collected_at = datetime.datetime.fromisoformat(d.pop("collected_at"))
98
+
99
+ room_id = d.pop("room_id", UNSET)
100
+
101
+ title = d.pop("title", UNSET)
102
+
103
+ viewers = d.pop("viewers", UNSET)
104
+
105
+ _started_at = d.pop("started_at", UNSET)
106
+ started_at: datetime.datetime | Unset
107
+ if isinstance(_started_at, Unset):
108
+ started_at = UNSET
109
+ else:
110
+ started_at = datetime.datetime.fromisoformat(_started_at)
111
+
112
+ cover_url = d.pop("cover_url", UNSET)
113
+
114
+ live_room = cls(
115
+ live=live,
116
+ author=author,
117
+ collected_at=collected_at,
118
+ room_id=room_id,
119
+ title=title,
120
+ viewers=viewers,
121
+ started_at=started_at,
122
+ cover_url=cover_url,
123
+ )
124
+
125
+ live_room.additional_properties = d
126
+ return live_room
127
+
128
+ @property
129
+ def additional_keys(self) -> list[str]:
130
+ return list(self.additional_properties.keys())
131
+
132
+ def __getitem__(self, key: str) -> Any:
133
+ return self.additional_properties[key]
134
+
135
+ def __setitem__(self, key: str, value: Any) -> None:
136
+ self.additional_properties[key] = value
137
+
138
+ def __delitem__(self, key: str) -> None:
139
+ del self.additional_properties[key]
140
+
141
+ def __contains__(self, key: str) -> bool:
142
+ return key in self.additional_properties