diff --git a/custom_components/yahoofinance/const.py b/custom_components/yahoofinance/const.py index 21e1a75..f03cd36 100755 --- a/custom_components/yahoofinance/const.py +++ b/custom_components/yahoofinance/const.py @@ -153,7 +153,7 @@ "accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7", "accept-encoding": "gzip,deflate,br,zstd", "accept-language": "en-US,en;q=0.9", - "user-agent": "Mozilla/5.0 (Linux; Android) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.109 Safari/537.36 CrKey/1.54.248666", + "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36", } """ Headers for all other requests. """ diff --git a/custom_components/yahoofinance/coordinator.py b/custom_components/yahoofinance/coordinator.py index 8612781..137cee5 100755 --- a/custom_components/yahoofinance/coordinator.py +++ b/custom_components/yahoofinance/coordinator.py @@ -98,6 +98,9 @@ async def try_get_crumb_cookies(self) -> str | None: ) return None + if self.cookies_missing(): + _LOGGER.error("Attempting to get crumb but have no cookies") + await self.try_crumb_page() return self.crumb @@ -122,7 +125,10 @@ async def initial_navigation(self, url: str) -> ConsentData | None: if response.status != HTTPStatus.OK: _LOGGER.error( - "Failed to navigate to %s, status=%d", url, response.status + "Failed to navigate to %s, status=%d, reason=%s", + url, + response.status, + response.reason, ) return None @@ -170,7 +176,11 @@ async def process_consent(self, consent_data: ConsentData) -> bool: # 200 if response.status != HTTPStatus.OK: - _LOGGER.error("Failed to post consent %d", response.status) + _LOGGER.error( + "Failed to post consent %d, reason=%s", + response.status, + response.reason, + ) return False if response.cookies: @@ -204,6 +214,7 @@ async def try_crumb_page(self) -> str | None: GET_CRUMB_URL, headers=REQUEST_HEADERS, timeout=aiohttp.ClientTimeout(total=REQUEST_TIMEOUT), + cookies=self.cookies, ) as response: _LOGGER.debug("Crumb response status: %d, %s", response.status, response) @@ -215,7 +226,11 @@ async def try_crumb_page(self) -> str | None: _LOGGER.debug("Crumb page reported %s", self.crumb) return self.crumb - _LOGGER.error("Crumb request responded with status=%d", response.status) + _LOGGER.error( + "Crumb request responded with status=%d, reason=%s", + response.status, + response.reason, + ) if response.status == 429: # Ideally we would want to use the seconds passed back in the header