Skip to content

Commit

Permalink
Changed the way to search for a script with a variables
Browse files Browse the repository at this point in the history
  • Loading branch information
vmakeev committed Apr 16, 2023
1 parent aaebba1 commit 62c0a9c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions custom_components/tplink_easy_smart/client/coreapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
AUTH_TOO_MANY_USERS: Final = "auth_too_many_users"
AUTH_SESSION_TIMEOUT: Final = "auth_session_timeout"

_SCRIPT_REGEX = r".*<script>(.*)<\/script>\s*<html>"
_SCRIPT_REGEX = r".*<script>(.*)<\/script>"
_VARIABLES_REGEX = r".*var\s+(?P<variable>[a-zA-Z0-9_]+)\s*=\s*(?P<value>[^;]+);\s*"
_ARRAY_VALUES_REGEX = r"\s*new\s*Array\s*\((?P<items>[^\)]+)\)"

Expand Down Expand Up @@ -121,7 +121,7 @@ def _get_variables(page: str) -> dict[str, str]:
if not script_match:
return result

script_content = script_match.group(1)
script_content = script_match.group(0)

for variable_match in re.finditer(_VARIABLES_REGEX, script_content):
variable = variable_match.group("variable")
Expand Down

0 comments on commit 62c0a9c

Please sign in to comment.