Minor cleanup of comments, typing and gitignore

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

No files matched your search

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