diff --git a/.gitignore b/.gitignore index 535b0d7..86d1a68 100644 --- a/.gitignore +++ b/.gitignore @@ -11,7 +11,7 @@ __pycache__ # Dev files /env /cache +/*.jar log.txt -cookies.jar settings.json /lang/English.json diff --git a/constants.py b/constants.py index 485b360..4b7961e 100644 --- a/constants.py +++ b/constants.py @@ -6,8 +6,7 @@ from pathlib import Path from copy import deepcopy from enum import Enum, auto from datetime import timedelta -from collections import namedtuple -from typing import Any, Dict, Literal, NewType, TYPE_CHECKING +from typing import Any, Dict, Literal, NamedTuple, NewType, TYPE_CHECKING from yarl import URL @@ -85,7 +84,11 @@ FILE_FORMATTER = logging.Formatter( datefmt="%Y-%m-%d %H:%M:%S", ) OUTPUT_FORMATTER = logging.Formatter("{levelname}: {message}", style='{', datefmt="%H:%M:%S") -ClientInfo = namedtuple("ClientInfo", ["CLIENT_ID", "USER_AGENT"]) + + +class ClientInfo(NamedTuple): + CLIENT_ID: str + USER_AGENT: str class ClientType: diff --git a/gui.py b/gui.py index f50b181..ab47ba7 100644 --- a/gui.py +++ b/gui.py @@ -474,10 +474,10 @@ class LoginForm: self._pass_entry.get(), self._token_entry.get().strip(), ) - # basic input data validation + # basic input data validation: 3-25 characters in length, only ascii and underscores if ( - not 3 <= len(login_data.username) <= 25 # 3-25 characters in length - and re.match(r'^[a-zA-Z0-9_]+$', login_data.username) # only ascii and underscores + not 3 <= len(login_data.username) <= 25 + and re.match(r'^[a-zA-Z0-9_]+$', login_data.username) ): self.clear(login=True) continue diff --git a/twitch.py b/twitch.py index 5d45088..721e453 100644 --- a/twitch.py +++ b/twitch.py @@ -444,7 +444,7 @@ class _AuthState: jar = cast(aiohttp.CookieJar, session.cookie_jar) if not self._hasattrs("client_version", "device_id"): async with self._twitch.request( - "GET", BASE_URL, headers=self.headers() # (user_agent=ANDROID_USER_AGENT) + "GET", BASE_URL, headers=self.headers() ) as response: page_html = await response.text("utf8") match = re.search(r'twilightBuildID="([-a-z0-9]+)"', page_html)