Save cookies as soon as available

This commit is contained in:
DevilXD committed 2021-12-04 16:07:57 +01:00
1 parent 65069c1963
commit 6df1fe98f4
1 file changed
+3 -2
+3 -2
View File
@@ -318,7 +318,7 @@ class Twitch:
return return
# looks like we're missing something # looks like we're missing something
print("Logging in") print("Logging in")
jar = self._session.cookie_jar jar = cast(aiohttp.CookieJar, self._session.cookie_jar)
while True: while True:
cookie = jar.filter_cookies("https://twitch.tv") # type: ignore cookie = jar.filter_cookies("https://twitch.tv") # type: ignore
if not cookie: if not cookie:
@@ -346,8 +346,9 @@ class Twitch:
self._user_id = cookie["persistent"] = validate_response["user_id"] self._user_id = cookie["persistent"] = validate_response["user_id"]
self._is_logged_in.set() self._is_logged_in.set()
print(f"Login successful, User ID: {self._user_id}") print(f"Login successful, User ID: {self._user_id}")
# update our cookie # update our cookie and save it
jar.update_cookies(cookie, URL("https://twitch.tv")) jar.update_cookies(cookie, URL("https://twitch.tv"))
jar.save(COOKIES_PATH)
async def gql_request(self, op: GQLOperation) -> Dict[str, Any]: async def gql_request(self, op: GQLOperation) -> Dict[str, Any]:
await self.check_login() await self.check_login()