Skip to content

Commit

Permalink
Correct handling of radio stations when browsing media. Fixes #3
Browse files Browse the repository at this point in the history
  • Loading branch information
Jon Kristian Nilsen committed Mar 1, 2023
1 parent e250495 commit fb0fddb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
20 changes: 12 additions & 8 deletions custom_components/casatunes/browse_media.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
class UnknownMediaType(BrowseError):
"""Unknown media type."""

CT_COLLECTION = 8
CT_ALLOWSELECT = 8192

BROWSE_LIMIT = 1000

Expand Down Expand Up @@ -48,23 +50,25 @@ async def item_payload(casa_server, item):
else await casa_server.data.get_image(image_id)
)

media_content_id = item["ID"]
flags = item["Flags"]

if item.get("QueueType") == "NONE":
if (flags & CT_COLLECTION) and (flags & CT_ALLOWSELECT):
media_content_type = "library"
media_class = MEDIA_CLASS_PLAYLIST
can_play = True
can_expand = True
elif (flags & CT_COLLECTION):
media_content_type = "library"
media_class = MEDIA_CLASS_DIRECTORY
can_play = False
can_expand = True
elif item.get("Track"):
else:
media_content_type = "track"
media_class = MEDIA_CLASS_TRACK
can_expand = False
can_play = True
else:
media_content_type = "library"
media_class = MEDIA_CLASS_PLAYLIST
can_play = True
can_expand = True

media_content_id = item["ID"]

payload = {
"title": title,
Expand Down
2 changes: 1 addition & 1 deletion custom_components/casatunes/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"config_flow": true,
"documentation": "https://github.com/jonkristian/casatunes",
"issue_tracker": "https://github.com/jonkristian/casatunes/issues",
"version": "0.1.4",
"version": "0.1.5",
"requirements": [
"pycasatunes==0.1.2"
],
Expand Down

0 comments on commit fb0fddb

Please sign in to comment.