Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
Core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mirrored_repos
HomeAssistant
Core
Commits
d4f38099
Unverified
Commit
d4f38099
authored
2 months ago
by
peteS-UK
Committed by
GitHub
2 months ago
Browse files
Options
Downloads
Patches
Plain Diff
Small fix to allow playing of expandable favorites on Squeezebox (#134572)
parent
9f2cb7bf
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
homeassistant/components/squeezebox/browse_media.py
+6
-4
6 additions, 4 deletions
homeassistant/components/squeezebox/browse_media.py
tests/components/squeezebox/conftest.py
+3
-0
3 additions, 0 deletions
tests/components/squeezebox/conftest.py
with
9 additions
and
4 deletions
homeassistant/components/squeezebox/browse_media.py
+
6
−
4
View file @
d4f38099
...
@@ -115,6 +115,7 @@ async def build_item_response(
...
@@ -115,6 +115,7 @@ async def build_item_response(
item_type
=
CONTENT_TYPE_TO_CHILD_TYPE
[
search_type
]
item_type
=
CONTENT_TYPE_TO_CHILD_TYPE
[
search_type
]
children
=
[]
children
=
[]
list_playable
=
[]
for
item
in
result
[
"
items
"
]:
for
item
in
result
[
"
items
"
]:
item_id
=
str
(
item
[
"
id
"
])
item_id
=
str
(
item
[
"
id
"
])
item_thumbnail
:
str
|
None
=
None
item_thumbnail
:
str
|
None
=
None
...
@@ -131,7 +132,7 @@ async def build_item_response(
...
@@ -131,7 +132,7 @@ async def build_item_response(
child_media_class
=
CONTENT_TYPE_MEDIA_CLASS
[
MediaType
.
ALBUM
]
child_media_class
=
CONTENT_TYPE_MEDIA_CLASS
[
MediaType
.
ALBUM
]
can_expand
=
True
can_expand
=
True
can_play
=
True
can_play
=
True
elif
item
[
"
hasitems
"
]:
elif
item
[
"
hasitems
"
]
and
not
item
[
"
isaudio
"
]
:
child_item_type
=
"
Favorites
"
child_item_type
=
"
Favorites
"
child_media_class
=
CONTENT_TYPE_MEDIA_CLASS
[
"
Favorites
"
]
child_media_class
=
CONTENT_TYPE_MEDIA_CLASS
[
"
Favorites
"
]
can_expand
=
True
can_expand
=
True
...
@@ -139,8 +140,8 @@ async def build_item_response(
...
@@ -139,8 +140,8 @@ async def build_item_response(
else
:
else
:
child_item_type
=
"
Favorites
"
child_item_type
=
"
Favorites
"
child_media_class
=
CONTENT_TYPE_MEDIA_CLASS
[
MediaType
.
TRACK
]
child_media_class
=
CONTENT_TYPE_MEDIA_CLASS
[
MediaType
.
TRACK
]
can_expand
=
False
can_expand
=
item
[
"
hasitems
"
]
can_play
=
True
can_play
=
item
[
"
isaudio
"
]
and
item
.
get
(
"
url
"
)
if
artwork_track_id
:
=
item
.
get
(
"
artwork_track_id
"
):
if
artwork_track_id
:
=
item
.
get
(
"
artwork_track_id
"
):
if
internal_request
:
if
internal_request
:
...
@@ -166,6 +167,7 @@ async def build_item_response(
...
@@ -166,6 +167,7 @@ async def build_item_response(
thumbnail
=
item_thumbnail
,
thumbnail
=
item_thumbnail
,
)
)
)
)
list_playable
.
append
(
can_play
)
if
children
is
None
:
if
children
is
None
:
raise
BrowseError
(
f
"
Media not found:
{
search_type
}
/
{
search_id
}
"
)
raise
BrowseError
(
f
"
Media not found:
{
search_type
}
/
{
search_id
}
"
)
...
@@ -179,7 +181,7 @@ async def build_item_response(
...
@@ -179,7 +181,7 @@ async def build_item_response(
children_media_class
=
media_class
[
"
children
"
],
children_media_class
=
media_class
[
"
children
"
],
media_content_id
=
search_id
,
media_content_id
=
search_id
,
media_content_type
=
search_type
,
media_content_type
=
search_type
,
can_play
=
search_type
!=
"
Favorites
"
,
can_play
=
any
(
list_playable
)
,
children
=
children
,
children
=
children
,
can_expand
=
True
,
can_expand
=
True
,
)
)
...
...
This diff is collapsed.
Click to expand it.
tests/components/squeezebox/conftest.py
+
3
−
0
View file @
d4f38099
...
@@ -137,6 +137,7 @@ async def mock_async_browse(
...
@@ -137,6 +137,7 @@ async def mock_async_browse(
"
title
"
:
"
Fake Item 1
"
,
"
title
"
:
"
Fake Item 1
"
,
"
id
"
:
FAKE_VALID_ITEM_ID
,
"
id
"
:
FAKE_VALID_ITEM_ID
,
"
hasitems
"
:
False
,
"
hasitems
"
:
False
,
"
isaudio
"
:
True
,
"
item_type
"
:
child_types
[
media_type
],
"
item_type
"
:
child_types
[
media_type
],
"
artwork_track_id
"
:
"
b35bb9e9
"
,
"
artwork_track_id
"
:
"
b35bb9e9
"
,
"
url
"
:
"
file:///var/lib/squeezeboxserver/music/track_1.mp3
"
,
"
url
"
:
"
file:///var/lib/squeezeboxserver/music/track_1.mp3
"
,
...
@@ -145,6 +146,7 @@ async def mock_async_browse(
...
@@ -145,6 +146,7 @@ async def mock_async_browse(
"
title
"
:
"
Fake Item 2
"
,
"
title
"
:
"
Fake Item 2
"
,
"
id
"
:
FAKE_VALID_ITEM_ID
+
"
_2
"
,
"
id
"
:
FAKE_VALID_ITEM_ID
+
"
_2
"
,
"
hasitems
"
:
media_type
==
"
favorites
"
,
"
hasitems
"
:
media_type
==
"
favorites
"
,
"
isaudio
"
:
True
,
"
item_type
"
:
child_types
[
media_type
],
"
item_type
"
:
child_types
[
media_type
],
"
image_url
"
:
"
http://lms.internal:9000/html/images/favorites.png
"
,
"
image_url
"
:
"
http://lms.internal:9000/html/images/favorites.png
"
,
"
url
"
:
"
file:///var/lib/squeezeboxserver/music/track_2.mp3
"
,
"
url
"
:
"
file:///var/lib/squeezeboxserver/music/track_2.mp3
"
,
...
@@ -153,6 +155,7 @@ async def mock_async_browse(
...
@@ -153,6 +155,7 @@ async def mock_async_browse(
"
title
"
:
"
Fake Item 3
"
,
"
title
"
:
"
Fake Item 3
"
,
"
id
"
:
FAKE_VALID_ITEM_ID
+
"
_3
"
,
"
id
"
:
FAKE_VALID_ITEM_ID
+
"
_3
"
,
"
hasitems
"
:
media_type
==
"
favorites
"
,
"
hasitems
"
:
media_type
==
"
favorites
"
,
"
isaudio
"
:
True
,
"
album_id
"
:
FAKE_VALID_ITEM_ID
if
media_type
==
"
favorites
"
else
None
,
"
album_id
"
:
FAKE_VALID_ITEM_ID
if
media_type
==
"
favorites
"
else
None
,
"
url
"
:
"
file:///var/lib/squeezeboxserver/music/track_3.mp3
"
,
"
url
"
:
"
file:///var/lib/squeezeboxserver/music/track_3.mp3
"
,
},
},
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment