devialet 1.5.3__tar.gz → 1.5.5__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.
- {devialet-1.5.3 → devialet-1.5.5}/PKG-INFO +1 -1
- {devialet-1.5.3 → devialet-1.5.5}/devialet/devialet_api.py +27 -16
- {devialet-1.5.3 → devialet-1.5.5}/devialet.egg-info/PKG-INFO +1 -1
- {devialet-1.5.3 → devialet-1.5.5}/setup.py +1 -1
- {devialet-1.5.3 → devialet-1.5.5}/LICENSE +0 -0
- {devialet-1.5.3 → devialet-1.5.5}/README.md +0 -0
- {devialet-1.5.3 → devialet-1.5.5}/devialet/__init__.py +0 -0
- {devialet-1.5.3 → devialet-1.5.5}/devialet/const.py +0 -0
- {devialet-1.5.3 → devialet-1.5.5}/devialet.egg-info/SOURCES.txt +0 -0
- {devialet-1.5.3 → devialet-1.5.5}/devialet.egg-info/dependency_links.txt +0 -0
- {devialet-1.5.3 → devialet-1.5.5}/devialet.egg-info/requires.txt +0 -0
- {devialet-1.5.3 → devialet-1.5.5}/devialet.egg-info/top_level.txt +0 -0
- {devialet-1.5.3 → devialet-1.5.5}/setup.cfg +0 -0
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
"""Support for Devialet Phantom
|
|
1
|
+
"""Support for Devialet Phantom speakers1."""
|
|
2
2
|
from __future__ import annotations
|
|
3
3
|
|
|
4
4
|
import asyncio
|
|
5
5
|
import datetime
|
|
6
6
|
import json
|
|
7
7
|
import re
|
|
8
|
-
from typing import Mapping, Union
|
|
9
8
|
|
|
10
9
|
import aiohttp
|
|
11
10
|
from async_upnp_client.aiohttp import AiohttpRequester
|
|
@@ -58,6 +57,9 @@ class DevialetApi:
|
|
|
58
57
|
self._source_state = await self._async_get_request(UrlSuffix.GET_CURRENT_SOURCE)
|
|
59
58
|
# The source state call is enough to find out if the device is available (On or Off)
|
|
60
59
|
if not self._is_available:
|
|
60
|
+
# Set upnp to none, so discovery will find the new port when it's online again
|
|
61
|
+
self._upnp_device = None
|
|
62
|
+
self._dmr_device = None
|
|
61
63
|
return True
|
|
62
64
|
|
|
63
65
|
if self._sources is None:
|
|
@@ -67,9 +69,6 @@ class DevialetApi:
|
|
|
67
69
|
self._night_mode = await self._async_get_request(UrlSuffix.GET_NIGHT_MODE)
|
|
68
70
|
self._equalizer = await self._async_get_request(UrlSuffix.GET_EQUALIZER)
|
|
69
71
|
|
|
70
|
-
if self.source == "upnp":
|
|
71
|
-
return True
|
|
72
|
-
|
|
73
72
|
try:
|
|
74
73
|
self._media_duration = self._source_state["metadata"]["duration"]
|
|
75
74
|
except (KeyError, TypeError):
|
|
@@ -559,25 +558,37 @@ class DevialetApi:
|
|
|
559
558
|
source=("0.0.0.0", 0))
|
|
560
559
|
LOGGER.debug("Discovering UPnP device for %s", self._host)
|
|
561
560
|
|
|
562
|
-
async def async_play_url_source(self,
|
|
561
|
+
async def async_play_url_source(self, media_id: str, mime_type: str, media_title: str, default_title: bool=False) -> bool:
|
|
563
562
|
"""Play media uri over UPnP."""
|
|
564
563
|
if not self.upnp_available:
|
|
565
564
|
LOGGER.error("No UPnP location discovered")
|
|
566
565
|
return
|
|
567
566
|
|
|
567
|
+
if default_title:
|
|
568
|
+
media_title = await self.async_get_upnp_media_title(media_id) or media_title
|
|
569
|
+
|
|
570
|
+
metadata = (
|
|
571
|
+
await self.dmr_device.construct_play_media_metadata(
|
|
572
|
+
media_url=media_id,
|
|
573
|
+
media_title=media_title,
|
|
574
|
+
mime_type=mime_type
|
|
575
|
+
)
|
|
576
|
+
)
|
|
577
|
+
|
|
568
578
|
service = self._upnp_device.service(AV_TRANSPORT)
|
|
569
579
|
set_uri = service.action("SetAVTransportURI")
|
|
570
580
|
|
|
571
581
|
try:
|
|
572
|
-
result = await set_uri.async_call(InstanceID=0, CurrentURI=
|
|
582
|
+
result = await set_uri.async_call(InstanceID=0, CurrentURI=media_id, CurrentURIMetaData=metadata)
|
|
573
583
|
LOGGER.debug("Action result: %s", str(result))
|
|
574
584
|
except UpnpActionResponseError as a:
|
|
575
585
|
LOGGER.error("Error playing %s: %s", media_title, a.error_desc)
|
|
586
|
+
return False
|
|
576
587
|
except UpnpXmlParseError as x:
|
|
577
588
|
LOGGER.error("Error playing %s %s", media_title, x.text)
|
|
589
|
+
return False
|
|
578
590
|
|
|
579
591
|
await self.async_upnp_play()
|
|
580
|
-
await self._async_get_upnp_metadata(media_url) # Devialet does not support UPnP metadata
|
|
581
592
|
|
|
582
593
|
async def async_upnp_play(self) -> None:
|
|
583
594
|
"""Send the play command over UPnP."""
|
|
@@ -596,25 +607,25 @@ class DevialetApi:
|
|
|
596
607
|
except UpnpXmlParseError:
|
|
597
608
|
return
|
|
598
609
|
|
|
599
|
-
async def
|
|
610
|
+
async def async_get_upnp_media_title(self, url: str) -> str | None:
|
|
600
611
|
"""Call the media URL with the HEAD method to get ICY metadata."""
|
|
601
612
|
try:
|
|
602
613
|
async with self._session.head(
|
|
603
|
-
url=url, allow_redirects=False, timeout=2, headers={"Icy-MetaData": 1}
|
|
614
|
+
url=url, allow_redirects=False, timeout=2, headers={"Icy-MetaData": "1"}
|
|
604
615
|
) as response:
|
|
605
616
|
LOGGER.debug(
|
|
606
617
|
"Host %s: HTTP Response data: %s",
|
|
607
618
|
self._host,
|
|
608
619
|
response.headers,
|
|
609
620
|
)
|
|
610
|
-
title:str = response.headers.get("icy-name")
|
|
611
|
-
|
|
621
|
+
title:str = response.headers.get("icy-description") or response.headers.get("icy-name")
|
|
622
|
+
return title
|
|
612
623
|
|
|
613
624
|
except aiohttp.ClientConnectorError:
|
|
614
|
-
return
|
|
625
|
+
return
|
|
615
626
|
except asyncio.TimeoutError:
|
|
616
|
-
return
|
|
627
|
+
return
|
|
617
628
|
except TypeError:
|
|
618
|
-
return
|
|
629
|
+
return
|
|
619
630
|
except Exception: # pylint: disable=bare-except
|
|
620
|
-
return
|
|
631
|
+
return
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|