More URLs cleanup
This commit is contained in:
1 parent
9ad0979d0e
commit
25bc398ec1
3 files changed
+15
-13
No files matched your search
+1
-4
@@ -20,11 +20,8 @@ TopicProcess: TypeAlias = "abc.Callable[[int, JsonType], Any]"
|
|||||||
# Values
|
# Values
|
||||||
MAX_WEBSOCKETS = 8
|
MAX_WEBSOCKETS = 8
|
||||||
WS_TOPICS_LIMIT = 50
|
WS_TOPICS_LIMIT = 50
|
||||||
# URLs
|
# Misc
|
||||||
BASE_URL = "https://twitch.tv"
|
BASE_URL = "https://twitch.tv"
|
||||||
WEBSOCKET_URL = "wss://pubsub-edge.twitch.tv/v1"
|
|
||||||
GQL_URL = "https://gql.twitch.tv/gql"
|
|
||||||
# Misc for Twitch
|
|
||||||
CLIENT_ID = "kimne78kx3ncx6brgo4mv6wki5h1ko"
|
CLIENT_ID = "kimne78kx3ncx6brgo4mv6wki5h1ko"
|
||||||
USER_AGENT = (
|
USER_AGENT = (
|
||||||
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) "
|
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) "
|
||||||
|
|||||||
@@ -23,7 +23,6 @@ from inventory import DropsCampaign
|
|||||||
from utils import task_wrapper, timestamp, AwaitableValue, OrderedSet
|
from utils import task_wrapper, timestamp, AwaitableValue, OrderedSet
|
||||||
from exceptions import RequestException, LoginException, CaptchaRequired
|
from exceptions import RequestException, LoginException, CaptchaRequired
|
||||||
from constants import (
|
from constants import (
|
||||||
GQL_URL,
|
|
||||||
BASE_URL,
|
BASE_URL,
|
||||||
CLIENT_ID,
|
CLIENT_ID,
|
||||||
USER_AGENT,
|
USER_AGENT,
|
||||||
@@ -824,12 +823,16 @@ class Twitch:
|
|||||||
) from cause
|
) from cause
|
||||||
|
|
||||||
async def gql_request(self, op: GQLOperation) -> JsonType:
|
async def gql_request(self, op: GQLOperation) -> JsonType:
|
||||||
headers = {
|
|
||||||
"Authorization": f"OAuth {self._access_token}",
|
|
||||||
"Client-Id": CLIENT_ID,
|
|
||||||
}
|
|
||||||
gql_logger.debug(f"GQL Request: {op}")
|
gql_logger.debug(f"GQL Request: {op}")
|
||||||
async with self.request("POST", GQL_URL, json=op, headers=headers) as response:
|
async with self.request(
|
||||||
|
"POST",
|
||||||
|
"https://gql.twitch.tv/gql",
|
||||||
|
json=op,
|
||||||
|
headers={
|
||||||
|
"Authorization": f"OAuth {self._access_token}",
|
||||||
|
"Client-Id": CLIENT_ID,
|
||||||
|
}
|
||||||
|
) as response:
|
||||||
response_json: JsonType = await response.json()
|
response_json: JsonType = await response.json()
|
||||||
gql_logger.debug(f"GQL Response: {response_json}")
|
gql_logger.debug(f"GQL Response: {response_json}")
|
||||||
return response_json
|
return response_json
|
||||||
|
|||||||
+5
-3
@@ -15,7 +15,7 @@ except ModuleNotFoundError as exc:
|
|||||||
|
|
||||||
from exceptions import MinerException
|
from exceptions import MinerException
|
||||||
from utils import task_wrapper, create_nonce, AwaitableValue
|
from utils import task_wrapper, create_nonce, AwaitableValue
|
||||||
from constants import WEBSOCKET_URL, PING_INTERVAL, PING_TIMEOUT, MAX_WEBSOCKETS, WS_TOPICS_LIMIT
|
from constants import PING_INTERVAL, PING_TIMEOUT, MAX_WEBSOCKETS, WS_TOPICS_LIMIT
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from twitch import Twitch
|
from twitch import Twitch
|
||||||
@@ -110,10 +110,12 @@ class Websocket:
|
|||||||
async def _handle(self):
|
async def _handle(self):
|
||||||
# ensure we're logged in before connecting
|
# ensure we're logged in before connecting
|
||||||
await self._twitch.wait_until_login()
|
await self._twitch.wait_until_login()
|
||||||
self.set_status("Connecting...")
|
|
||||||
ws_logger.info(f"Websocket[{self._idx}] connecting...")
|
ws_logger.info(f"Websocket[{self._idx}] connecting...")
|
||||||
|
self.set_status("Connecting...")
|
||||||
# Connect/Reconnect loop
|
# Connect/Reconnect loop
|
||||||
async for websocket in websocket_connect(WEBSOCKET_URL, ssl=True, ping_interval=None):
|
async for websocket in websocket_connect(
|
||||||
|
"wss://pubsub-edge.twitch.tv/v1", ssl=True, ping_interval=None
|
||||||
|
):
|
||||||
# 3 minutes of max backoff
|
# 3 minutes of max backoff
|
||||||
websocket.BACKOFF_MAX = 3 * 60 # type: ignore
|
websocket.BACKOFF_MAX = 3 * 60 # type: ignore
|
||||||
self._ws.set(websocket)
|
self._ws.set(websocket)
|
||||||
|
|||||||
Reference in new issue
Block a user