Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Containers and options #13

Open
Patrick-17 opened this issue Feb 24, 2020 · 0 comments
Open

Containers and options #13

Patrick-17 opened this issue Feb 24, 2020 · 0 comments

Comments

@Patrick-17
Copy link

Patrick-17 commented Feb 24, 2020

pyheos version with the issue: 6.0

**Python version and environment:**3.7 - windows 10 64

Description of problem:
Good morning, everyone,

I'm trying to develop a python 3.7 application to drive a denon ceol n10 Heos chain.
The pyheos library is great because it offers almost the whole toolkit to do this.
However, I'm encountering small difficulties with some pyheos elements.

Problem 1

Indeed, the browsecontainer function is not implemented in source.py.
Browsecontainer requires to pass both source_id and container_id parameters, whereas browse only requests source_id.
Moreover, the payload in response to browsecontainer does not return source_id (it is in the question, but heosource does not return source_id).
don't flip it. And finally, when exploring a local or remote server, only the first level of container
contains a source_id, then to go down in the folder hierarchy you have to use the same source_id.
The solution to this problem is relatively simple, here is what I propose to integrate:

1 in source.py

async def browsecontainer(self,lesid) -> 'Sequence[HeosSource]':
"""Browse the contents of the current source container.""""
if not self._source_id,self:
self._source_id = lesid
items = await self._commands.browsecontainer(self._source_id,self._container_id)
return [HeosSource(self._commands, item) for item in items]

2 in command.py

async def browsecontainer(self, source_id: int,container_id: int) -> Sequence[dict]:
"""Browse a music source container."""
params = {
'sid': source_id, 'cid': container_id
}
response = await self._connection.command(
const.COMMAND_BROWSE, params)
return response.payload

Problem 2

Some commands (such as browsecontainer for example) return a response containing a third
part: Options.
For the containers this option is 21 and allows to know if a container is playable or not.
In other cases the option allows to display other choices like add to the list, or add to favorites etc...
Is it possible to integrate the option in the answer and if so how?

Below is an excerpt from the Heos Cli4.4.4 Browse Source Containers documentation
Command: heos://browse/browse?sid=source_id&cid=container_id&range=start#, end#
Attribute Description Enumeration
sid Source id returned by 'get_music_sources'
command
N/A
cid Container id returned by 'browse' or'search' command
N/A
range Range is start and end record index toreturn. Range parameter is optional.
Omitting range parameter returns allrecords up to a maximum of either 50 or100 records per response.The default maximum number of recordsdepend on the service type.
range starts from 0
count Total number of items available in the container.
NOTE: count value of '0' indicates unknown container size. Controllers
needs to query until the return payload is empty (returned attribute is 0).
0 - unknown

1 - valid count
returned Number of items returned in current response
N/A
id (options) Options available for current browse level Various options are presented as part of
'Browse Source container' command
response.
Supported options under each browse
menu depends on service type and container type.Possible options under browse menu are
listed below:
1 - Add Track to Library
2 - Add Album to Library
3 - Add Station to Library
4 - Add Playlist to Library
5 - Remove Track from Library
6 - Remove Album from Library
7 - Remove Station from Library
8 - Remove Playlist from Library
13 - Create New Station
19 - Add to HEOS Favorites
21 - Playable Container
The following are valid media types:
song
station
genre
artist
album
container
Note: A "yes" for the "container" field as well as the "playable" field implies that the container supports adding all media items to the play queue. Adding all media items of the container to the play queue is performed through "Add containers to queue"command. Note:
The option '21 - Playable Container' indicates that the container that is serving the tracks is playable. This option is mainly helpful with the Windows media share. With the Windows media container, HEOS can't determine if a container has playable tracks or not until the container is browsed for its items. When this option appears in browse response, the Controller software could add a virtual item i.e.
'Play all Tracks' along with presenting tracks in the container. When user selects the virtual item, the controller software could then send play command to play the container.
Note: Following response provides examples of the various media types. The actual response will depend on the source browsed and the hierarchy supported by that source.
Thank you for any suggestions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant