Actually use the unexpected_content translation;
and handle the associated exception everywhere
This commit is contained in:
1 parent
091ed1422c
commit
53d14d3dd7
2 files changed
+9
-15
No files matched your search
+1
-1
@@ -214,7 +214,7 @@ default_translation: Translation = {
|
|||||||
},
|
},
|
||||||
"login": {
|
"login": {
|
||||||
"unexpected_content": (
|
"unexpected_content": (
|
||||||
"Unexpected content type returned instead of JSON, usually due to being redirected. "
|
"Unexpected content type returned, usually due to being redirected. "
|
||||||
"Do you need to login for internet access?"
|
"Do you need to login for internet access?"
|
||||||
),
|
),
|
||||||
"incorrect_login_pass": "Incorrect username or password.",
|
"incorrect_login_pass": "Incorrect username or password.",
|
||||||
|
|||||||
@@ -165,6 +165,14 @@ class Twitch:
|
|||||||
return 0
|
return 0
|
||||||
return self.games[game]
|
return self.games[game]
|
||||||
|
|
||||||
|
async def run(self):
|
||||||
|
try:
|
||||||
|
await self._run()
|
||||||
|
except ExitRequest:
|
||||||
|
pass
|
||||||
|
except aiohttp.ContentTypeError as exc:
|
||||||
|
raise MinerException(_("login", "unexpected_content")) from exc
|
||||||
|
|
||||||
async def _run(self):
|
async def _run(self):
|
||||||
"""
|
"""
|
||||||
Main method that runs the whole client.
|
Main method that runs the whole client.
|
||||||
@@ -394,13 +402,6 @@ class Twitch:
|
|||||||
break
|
break
|
||||||
await self._state_change.wait()
|
await self._state_change.wait()
|
||||||
|
|
||||||
async def run(self):
|
|
||||||
try:
|
|
||||||
await self._run()
|
|
||||||
except ExitRequest:
|
|
||||||
pass
|
|
||||||
# post-main-loop code goes here
|
|
||||||
|
|
||||||
async def _watch_sleep(self, delay: float) -> None:
|
async def _watch_sleep(self, delay: float) -> None:
|
||||||
# we use wait_for here to allow an asyncio.sleep-like that can be ended prematurely
|
# we use wait_for here to allow an asyncio.sleep-like that can be ended prematurely
|
||||||
self._watching_restart.clear()
|
self._watching_restart.clear()
|
||||||
@@ -739,17 +740,10 @@ class Twitch:
|
|||||||
payload.pop("authy_token", None)
|
payload.pop("authy_token", None)
|
||||||
payload.pop("twitchguard_code", None)
|
payload.pop("twitchguard_code", None)
|
||||||
for attempt in range(2):
|
for attempt in range(2):
|
||||||
try:
|
|
||||||
async with self.request(
|
async with self.request(
|
||||||
"POST", "https://passport.twitch.tv/login", json=payload
|
"POST", "https://passport.twitch.tv/login", json=payload
|
||||||
) as response:
|
) as response:
|
||||||
login_response: JsonType = await response.json()
|
login_response: JsonType = await response.json()
|
||||||
except aiohttp.ContentTypeError as exc:
|
|
||||||
raise MinerException(
|
|
||||||
"Unexpected content type returned instead of JSON, "
|
|
||||||
"usually due to being redirected. "
|
|
||||||
"Do you need to login for internet access?"
|
|
||||||
) from exc
|
|
||||||
|
|
||||||
# Feed this back in to avoid running into CAPTCHA if possible
|
# Feed this back in to avoid running into CAPTCHA if possible
|
||||||
if "captcha_proof" in login_response:
|
if "captcha_proof" in login_response:
|
||||||
|
|||||||
Reference in new issue
Block a user