Skip to content

Commit

Permalink
Fix known_hosts for older chromecasts (#762)
Browse files Browse the repository at this point in the history
* Fix known_hosts for older chromecasts

* Fix lint errors

* Move logic

* Remove timeout changes and add comment

* Move udn get
  • Loading branch information
domenipavec authored Nov 21, 2023
1 parent 8e86fbe commit 358604f
Showing 1 changed file with 22 additions and 8 deletions.
30 changes: 22 additions & 8 deletions pychromecast/dial.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,14 +178,26 @@ def get_device_info( # pylint: disable=too-many-locals
try:
if services is None:
services = [ServiceInfo(SERVICE_TYPE_HOST, (host, 8009))]
_, status = _get_status(
services,
zconf,
"/setup/eureka_info?params=device_info,name",
True,
timeout,
context,
)

# Try connection with SSL first, and if it fails fall back to non-SSL
try:
_, status = _get_status(
services,
zconf,
"/setup/eureka_info?params=device_info,name",
True,
timeout / 2,
context,
)
except (urllib.error.HTTPError, urllib.error.URLError):
_, status = _get_status(
services,
zconf,
"/setup/eureka_info?params=device_info,name",
False,
timeout / 2,
context,
)

cast_type = CAST_TYPE_CHROMECAST
display_supported = True
Expand All @@ -205,6 +217,8 @@ def get_device_info( # pylint: disable=too-many-locals
model_name = device_info.get("model_name", model_name)
manufacturer = device_info.get("manufacturer", manufacturer)
udn = device_info.get("ssdp_udn", None)
else:
udn = status.get("ssdp_udn", None)

if not display_supported:
cast_type = CAST_TYPE_AUDIO
Expand Down

0 comments on commit 358604f

Please sign in to comment.