devialet 1.5.2__tar.gz → 1.5.4__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: devialet
3
- Version: 1.5.2
3
+ Version: 1.5.4
4
4
  Summary: Devialet API
5
5
  Home-page: https://github.com/fwestenberg/devialet
6
6
  Download-URL: https://github.com/fwestenberg/devialet/releases/latest
@@ -10,7 +10,7 @@ NORMAL_INPUTS = {
10
10
  "Digital left": "digital_left", #Arch only
11
11
  "Digital right": "digital_right", #Arch only
12
12
  "Line": "line", #Arch only
13
- "Online": "upnp",
13
+ "UPnP": "upnp",
14
14
  "Optical": "optical", #Phantom I, Dialog (Mono)
15
15
  "Optical left": "optical_left", #Phantom I (Stereo)
16
16
  "Optical right": "optical_right", #Phantom I (Stereo)
@@ -1,4 +1,4 @@
1
- """Support for Devialet Phantom speakers."""
1
+ """Support for Devialet Phantom speakers1."""
2
2
  from __future__ import annotations
3
3
 
4
4
  import asyncio
@@ -58,6 +58,9 @@ class DevialetApi:
58
58
  self._source_state = await self._async_get_request(UrlSuffix.GET_CURRENT_SOURCE)
59
59
  # The source state call is enough to find out if the device is available (On or Off)
60
60
  if not self._is_available:
61
+ # Set upnp to none, so discovery will find the new port when it's online again
62
+ self._upnp_device = None
63
+ self._dmr_device = None
61
64
  return True
62
65
 
63
66
  if self._sources is None:
@@ -556,7 +559,7 @@ class DevialetApi:
556
559
  source=("0.0.0.0", 0))
557
560
  LOGGER.debug("Discovering UPnP device for %s", self._host)
558
561
 
559
- async def async_play_url_source(self, media_url: str, media_title: str, meta_data: Union[None, str, Mapping] = None) -> bool:
562
+ async def async_play_url_source(self, media_url: str, media_title: str, meta_data: Union[None, str, Mapping] = None):
560
563
  """Play media uri over UPnP."""
561
564
  if not self.upnp_available:
562
565
  LOGGER.error("No UPnP location discovered")
@@ -570,8 +573,10 @@ class DevialetApi:
570
573
  LOGGER.debug("Action result: %s", str(result))
571
574
  except UpnpActionResponseError as a:
572
575
  LOGGER.error("Error playing %s: %s", media_title, a.error_desc)
576
+ return
573
577
  except UpnpXmlParseError as x:
574
578
  LOGGER.error("Error playing %s %s", media_title, x.text)
579
+ return
575
580
 
576
581
  await self.async_upnp_play()
577
582
 
@@ -591,3 +596,26 @@ class DevialetApi:
591
596
  return
592
597
  except UpnpXmlParseError:
593
598
  return
599
+
600
+ async def async_get_upnp_media_title(self, url: str) -> str | None:
601
+ """Call the media URL with the HEAD method to get ICY metadata."""
602
+ try:
603
+ async with self._session.head(
604
+ url=url, allow_redirects=False, timeout=2, headers={"Icy-MetaData": "1"}
605
+ ) as response:
606
+ LOGGER.debug(
607
+ "Host %s: HTTP Response data: %s",
608
+ self._host,
609
+ response.headers,
610
+ )
611
+ title:str = response.headers.get("icy-name")
612
+ return title
613
+
614
+ except aiohttp.ClientConnectorError:
615
+ return
616
+ except asyncio.TimeoutError:
617
+ return
618
+ except TypeError:
619
+ return
620
+ except Exception: # pylint: disable=bare-except
621
+ return
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: devialet
3
- Version: 1.5.2
3
+ Version: 1.5.4
4
4
  Summary: Devialet API
5
5
  Home-page: https://github.com/fwestenberg/devialet
6
6
  Download-URL: https://github.com/fwestenberg/devialet/releases/latest
@@ -3,7 +3,7 @@ from distutils.core import setup
3
3
  setup(
4
4
  name='devialet',
5
5
  packages=['devialet'],
6
- version='1.5.2',
6
+ version='1.5.4',
7
7
  license='MIT',
8
8
  description='Devialet API',
9
9
  long_description_content_type="text/markdown",
File without changes
File without changes
File without changes
File without changes