Move ClientType into Twitch class as an attribute

This allows us to use the base URL as specified in ClientInfo for
requests made to Twitch.

Previously, we'd hardcode "www.twitch.tv" as the base URL to make
channel-related requests, but because we're currently spoofing the
mobile client, that would always cause a HTTP redirect to m.twitch.tv.

This change avoids that HTTP redirect, and potentially saves a whopping
150 ms (or more 😱) when making channel-related requests.

Co-authored-by: DevilXD <4180725+DevilXD@users.noreply.github.com>
This commit is contained in:
guihkxandDevilXD authored and DevilXD committed 2024-02-14 14:51:37 +01:00
1 parent d7c2c8d5c3
commit dbd3cd82a0
3 files changed
+36 -33

No files matched your search

+2 -2
View File
@@ -9,7 +9,7 @@ from typing import Any, SupportsInt, TYPE_CHECKING
from utils import invalidate_cache, json_minify, Game
from exceptions import MinerException, RequestException
from constants import BASE_URL, GQL_OPERATIONS, ONLINE_DELAY, URLType
from constants import GQL_OPERATIONS, ONLINE_DELAY, URLType
if TYPE_CHECKING:
from twitch import Twitch
@@ -151,7 +151,7 @@ class Channel:
@property
def url(self) -> URLType:
return URLType(f"{BASE_URL}/{self._login}")
return URLType(f"{self._twitch._client_type.CLIENT_URL}/{self._login}")
@property
def iid(self) -> str: