Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions TikTokLive/client/web/routes/fetch_room_id_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ async def fetch_user_room_data(cls, web: TikTokHTTPClient, unique_id: str) -> di
:param web: The TikTokHTTPClient client to use
:param unique_id: The user to check
:return: The user's room info
:raises FailedParseRoomIdError: If TikTok returns a non-JSON or blocked response

"""

Expand All @@ -51,11 +52,17 @@ async def fetch_user_room_data(cls, web: TikTokHTTPClient, unique_id: str) -> di
)
)

response_json: dict = response.json()

try:
response_json: dict = response.json()
except ValueError:
raise FailedParseRoomIdError(
f"TikTok returned a non-JSON response for '{unique_id}' "
f"(HTTP {response.status_code}). You are likely being rate-limited "
f"or temporarily blocked by TikTok."
) from None

# Invalid user
if response_json["message"] == "user_not_found":
if response_json.get("message") == "user_not_found":
raise UserNotFoundError(
unique_id,
(
Expand Down