hamcws 0.2.2__tar.gz → 0.2.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.
|
@@ -23,6 +23,10 @@ class MediaServerInfo:
|
|
|
23
23
|
self.name = resp_dict.get('FriendlyName', 'Unknown')
|
|
24
24
|
self.platform = resp_dict.get('Platform', 'Unknown')
|
|
25
25
|
self.updated_at = datetime.datetime.utcnow()
|
|
26
|
+
try:
|
|
27
|
+
self.__version_tokens: list[int] = [int(v) for v in self.version.split('.', 3)]
|
|
28
|
+
except:
|
|
29
|
+
self.__version_tokens: list[int] = [0, 0, 0]
|
|
26
30
|
|
|
27
31
|
def __str__(self):
|
|
28
32
|
return f'{self.name} [{self.version}]'
|
|
@@ -32,6 +36,10 @@ class MediaServerInfo:
|
|
|
32
36
|
return self.name == other.name and self.version == other.version
|
|
33
37
|
return False
|
|
34
38
|
|
|
39
|
+
@property
|
|
40
|
+
def supports_audio_path_direct(self) -> bool:
|
|
41
|
+
return self.__version_tokens[0] > 33 or (self.__version_tokens[0] == 33 and self.__version_tokens[2] >= 33)
|
|
42
|
+
|
|
35
43
|
|
|
36
44
|
class PlaybackInfo:
|
|
37
45
|
|
|
@@ -644,7 +652,8 @@ class MediaServer:
|
|
|
644
652
|
async def get_current_playlist(self, fields: list[str] | None = None, zone: Zone | str | None = None) -> list[dict]:
|
|
645
653
|
""" Get the current playlist."""
|
|
646
654
|
if not fields:
|
|
647
|
-
fields = ['Key', 'Name', 'Media Type', 'Media Sub Type', 'Series', 'Season', 'Episode', 'Artist', 'Album',
|
|
655
|
+
fields = ['Key', 'Name', 'Media Type', 'Media Sub Type', 'Series', 'Season', 'Episode', 'Artist', 'Album',
|
|
656
|
+
'Track #',
|
|
648
657
|
'Dimensions', 'HDR Format', 'Duration']
|
|
649
658
|
ok, resp = await self._conn.get_as_json_list('Playback/Playlist',
|
|
650
659
|
params={'Fields': ','.join(fields),
|
|
@@ -769,8 +778,27 @@ class MediaServer:
|
|
|
769
778
|
except UnsupportedRequestError:
|
|
770
779
|
return []
|
|
771
780
|
|
|
781
|
+
async def get_audio_path_direct(self, zone: Zone | str | None = None) -> AudioPath:
|
|
782
|
+
""" Get the audio path of the given zone. """
|
|
783
|
+
|
|
784
|
+
def _parse(text: str) -> tuple[bool, AudioPath]:
|
|
785
|
+
root = ElementTree.fromstring(text)
|
|
786
|
+
is_ok = root.attrib['Status'] == 'OK'
|
|
787
|
+
if not is_ok or not root:
|
|
788
|
+
return False, AudioPath()
|
|
789
|
+
direct = False
|
|
790
|
+
for child in root:
|
|
791
|
+
if child.attrib['Name'] == 'Direct':
|
|
792
|
+
direct = child.text == 'yes'
|
|
793
|
+
break
|
|
794
|
+
return is_ok, AudioPath(direct)
|
|
795
|
+
|
|
796
|
+
ok, resp = await self._conn.get('Playback/AudioPathDirect', _parse, params=self.__zone_params(zone))
|
|
797
|
+
return resp
|
|
798
|
+
|
|
772
799
|
async def get_audio_path(self, zone: Zone | str | None = None) -> AudioPath:
|
|
773
800
|
""" Get the audio path of the given zone. """
|
|
801
|
+
|
|
774
802
|
def _parse(text: str) -> tuple[bool, AudioPath]:
|
|
775
803
|
root = ElementTree.fromstring(text)
|
|
776
804
|
is_ok = root.attrib['Status'] == 'OK'
|
|
@@ -938,7 +966,8 @@ def _parse_search(search: str) -> tuple[list[MediaType], list[MediaSubType]]:
|
|
|
938
966
|
return [m for m in mt if m], [m for m in mst if m]
|
|
939
967
|
|
|
940
968
|
|
|
941
|
-
def convert_browse_rules(rules: list[BrowseRule], flat: bool = False, infer_media_types: bool = True) -> list[
|
|
969
|
+
def convert_browse_rules(rules: list[BrowseRule], flat: bool = False, infer_media_types: bool = True) -> list[
|
|
970
|
+
BrowsePath]:
|
|
942
971
|
""" Convert the rules into a tree of paths. """
|
|
943
972
|
paths: list[BrowsePath] = []
|
|
944
973
|
all_paths: list[BrowsePath] = []
|
|
@@ -978,7 +1007,7 @@ def parse_browse_paths_from_text(input_rules: list[str]) -> list[BrowsePath]:
|
|
|
978
1007
|
vals = input_rule.split('|', 2)
|
|
979
1008
|
names = vals[0].split(',')
|
|
980
1009
|
for idx, name in enumerate(names):
|
|
981
|
-
full_name = '\\'.join(names[0: idx+1])
|
|
1010
|
+
full_name = '\\'.join(names[0: idx + 1])
|
|
982
1011
|
match = next((rule for rule in browse_rules if rule.name == full_name), None)
|
|
983
1012
|
if not match:
|
|
984
1013
|
match = BrowseRule(full_name, "", "")
|
|
File without changes
|
|
File without changes
|
|
File without changes
|