Replace wrong domain returned from xbox api 2.0 (#47021)
* Change solution to use yarl lib * Add check if base url needs changing * Actively remove padding query instead of omitting * Fixed popping the wrong query * Change explaination about removing mode query
This commit is contained in:
parent
09bafafee2
commit
5bba532dd4
1 changed files with 13 additions and 1 deletions
|
@ -1,6 +1,8 @@
|
|||
"""Base Sensor for the Xbox Integration."""
|
||||
from typing import Optional
|
||||
|
||||
from yarl import URL
|
||||
|
||||
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
||||
|
||||
from . import PresenceData, XboxUpdateCoordinator
|
||||
|
@ -44,7 +46,17 @@ class XboxBaseSensorEntity(CoordinatorEntity):
|
|||
if not self.data:
|
||||
return None
|
||||
|
||||
return self.data.display_pic.replace("&mode=Padding", "")
|
||||
# Xbox sometimes returns a domain that uses a wrong certificate which creates issues
|
||||
# with loading the image.
|
||||
# The correct domain is images-eds-ssl which can just be replaced
|
||||
# to point to the correct image, with the correct domain and certificate.
|
||||
# We need to also remove the 'mode=Padding' query because with it, it results in an error 400.
|
||||
url = URL(self.data.display_pic)
|
||||
if url.host == "images-eds.xboxlive.com":
|
||||
url = url.with_host("images-eds-ssl.xboxlive.com")
|
||||
query = dict(url.query)
|
||||
query.pop("mode", None)
|
||||
return str(url.with_query(query))
|
||||
|
||||
@property
|
||||
def entity_registry_enabled_default(self) -> bool:
|
||||
|
|
Loading…
Add table
Reference in a new issue