TikTokLive.client.web.routes package
Submodules
TikTokLive.client.web.routes.fetch_gift_list module
- exception TikTokLive.client.web.routes.fetch_gift_list.FailedFetchGiftListError(*args: str)
Bases:
TikTokLiveErrorThrown when a request to the gift list endpoint fails
- class TikTokLive.client.web.routes.fetch_gift_list.FetchGifListRoute(web: TikTokHTTPClient)
Bases:
ClientRouteRetrieve the gift list from TikTok
TikTokLive.client.web.routes.fetch_image_data module
- class TikTokLive.client.web.routes.fetch_image_data.FetchImageDataRoute(web: TikTokHTTPClient)
Bases:
ClientRouteFetch an image from the TikTok CDN
TikTokLive.client.web.routes.fetch_is_live module
- class TikTokLive.client.web.routes.fetch_is_live.FetchIsLiveRoute(web: TikTokHTTPClient)
Bases:
ClientRouteCheck if a given user is alive through their unique_id or room_id
- async fetch_is_live_room_ids(*room_ids: int) List[bool]
Check whether a list of room_id’s are currently live
- Parameters:
room_ids – The room_id’s to check
- Returns:
Whether they are alive, in the order they were sent
- async fetch_is_live_unique_id(unique_id: str) bool
Check whether a given user is live
- Parameters:
unique_id – The unique_id of the user
- Returns:
Whether they are live
- Raises:
InvalidLiveUser
- exception TikTokLive.client.web.routes.fetch_is_live.InvalidFetchIsLiveRequest(*args: str)
Bases:
TikTokLiveErrorThrown when the user fails to specify either a room ID or unique ID
- exception TikTokLive.client.web.routes.fetch_is_live.MissingRoomIdInResponse(*args: str)
Bases:
TikTokLiveErrorThrown when no entries are returned from the Room ID live method. This occurs when passing a nonexistent Room ID or when being detected by TikTok.
TikTokLive.client.web.routes.fetch_room_id_api module
- class TikTokLive.client.web.routes.fetch_room_id_api.FetchRoomIdAPIRoute(web: TikTokHTTPClient)
Bases:
ClientRouteRoute to retrieve the room ID for a user
- async classmethod fetch_user_room_data(web: TikTokHTTPClient, unique_id: str) dict
Fetch user room from the API (not the same as room info)
- Parameters:
web – The TikTokHTTPClient client to use
unique_id – The user to check
- Returns:
The user’s room info
- classmethod parse_room_id(data: dict) str
Parse the room ID from livestream API response
- Parameters:
data – The data to parse
- Returns:
The user’s room id
- Raises:
UserOfflineError if the user is offline
- Raises:
FailedParseRoomIdError if the user data does not exist
TikTokLive.client.web.routes.fetch_room_id_live_html module
- exception TikTokLive.client.web.routes.fetch_room_id_live_html.FailedParseRoomIdError(*args: str)
Bases:
TikTokLiveErrorThrown when the Room ID cannot be parsed
- class TikTokLive.client.web.routes.fetch_room_id_live_html.FetchRoomIdLiveHTMLRoute(web: TikTokHTTPClient)
Bases:
ClientRouteRoute to retrieve the room ID for a user
- SIGI_PATTERN: Pattern = re.compile('<script id="SIGI_STATE" type="application/json">(.*?)</script>')
- classmethod parse_room_id(html: str) str
Parse the room ID from livestream HTML
- Parameters:
html – The HTML to parse from https://tiktok.com/@<unique_id>/live
- Returns:
The user’s room id
- Raises:
UserOfflineError if the user is offline
- Raises:
FailedParseRoomIdError if the user does not exist
TikTokLive.client.web.routes.fetch_room_info module
- exception TikTokLive.client.web.routes.fetch_room_info.FailedFetchRoomInfoError(*args: str)
Bases:
TikTokLiveErrorThrown if Room info request fails
- class TikTokLive.client.web.routes.fetch_room_info.FetchRoomInfoRoute(web: TikTokHTTPClient)
Bases:
ClientRouteRetrieve the room info payload of a livestream room
- exception TikTokLive.client.web.routes.fetch_room_info.InvalidFetchRoomInfoPayload(*args: str)
Bases:
TikTokLiveError
TikTokLive.client.web.routes.fetch_signed_websocket module
- class TikTokLive.client.web.routes.fetch_signed_websocket.FetchSignedWebSocketRoute(web: TikTokHTTPClient)
Bases:
ClientRouteCall the signature server to receive the TikTok websocket URL
TikTokLive.client.web.routes.fetch_user_unique_id module
- exception TikTokLive.client.web.routes.fetch_user_unique_id.FailedParseAppInfo(*args: str)
Bases:
TikTokLiveErrorThrown when the App Info cannot be parsed
- exception TikTokLive.client.web.routes.fetch_user_unique_id.FailedResolveUserId(*args: str)
Bases:
TikTokLiveErrorThrown when the User ID cant be resolved
- class TikTokLive.client.web.routes.fetch_user_unique_id.FetchUserUniqueIdRoute(web: TikTokHTTPClient)
Bases:
ClientRouteRoute to retrieve the room ID for a user
- APP_INFO_PATTERN: Pattern = re.compile('<script id="__UNIVERSAL_DATA_FOR_REHYDRATION__" type="application/json">(.*?)</script>')
- classmethod parse_app_info(html: str) str
Parse the room ID from livestream HTML
- Parameters:
html – The HTML to parse from https://tiktok.com/@<user_id>
- Returns:
The unique_id of a User ID
TikTokLive.client.web.routes.fetch_video_data module
- exception TikTokLive.client.web.routes.fetch_video_data.DuplicateDownloadError(*args: str)
Bases:
TikTokLiveErrorThrown when attempting to start a duplicate download on a video you are already downloading
- class TikTokLive.client.web.routes.fetch_video_data.FetchVideoDataRoute(web: TikTokHTTPClient)
Bases:
ClientRouteTikTok route to record the livestream video in real-time
- property ffmpeg: FFmpeg | None
Return a copy of the FFmpeg class, which is only defined while recording
- Returns:
Copy of the class or None
- property is_recording: bool
Check if the route is currently in use to record the Live
- Returns:
Recording status
- property output_filename: str | None
Get the output filename
- Returns:
output filename or None
- start(**kwargs) None
Alias for calling the class itself, starts a recording
- Parameters:
kwargs – Kwargs to pass to __call__
- Returns:
None
- stop() None
Stop a livestream recording if it is ongoing
- Returns:
None
- class TikTokLive.client.web.routes.fetch_video_data.VideoFetchFormat(*values)
Bases:
EnumTikTok-supported video recording formats
- CMAF = 'cmaf'
- FLV = 'flv'
- HLS = 'hls'
- class TikTokLive.client.web.routes.fetch_video_data.VideoFetchQuality(*values)
Bases:
EnumVideo quality selection for stream downloads
- HD = 'hd'
High definition (540p, vbrate-1,000,000)
- LD = 'ld'
Low definition (480p, vbrate-500,000)
- ORIGIN = 'origin'
Original definition (N/A, vbrate-N/A)
- SD = 'sd'
Standard definition (480p, vbrate-800,000)
- UHD = 'uhd'
Ultra-high definition (720p, vbrate-1,000,000)
TikTokLive.client.web.routes.send_room_chat module
- class TikTokLive.client.web.routes.send_room_chat.SendRoomChatRoute(web: TikTokHTTPClient)
Bases:
ClientRoute