Minor cleanup of comments, typing and gitignore

This commit is contained in:
DevilXD
2022-12-23 13:17:47 +01:00
parent 28c0f8b75e
commit 7dc474286f
4 changed files with 11 additions and 8 deletions

2
.gitignore vendored
View File

@@ -11,7 +11,7 @@ __pycache__
# Dev files
/env
/cache
/*.jar
log.txt
cookies.jar
settings.json
/lang/English.json

View File

@@ -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:

6
gui.py
View File

@@ -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

View File

@@ -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)