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

Grouping count command #50

Open
mxjeff opened this issue Feb 16, 2015 · 4 comments
Open

Grouping count command #50

mxjeff opened this issue Feb 16, 2015 · 4 comments

Comments

@mxjeff
Copy link
Collaborator

mxjeff commented Feb 16, 2015

The grouping version of count command behave unexpectedly IMHO:

>>> cli = mpd.MPDClient()
>>> cli.connect(host='/run/mpd/socket', port=42)
>>> cli.count('group', 'albumartist')
{'albumartist': ['art00', 'art01',…], 
 'playtime': ['123', '321', …],
 'songs': ['1', '2',…]}
>>> #  idem with:
>>> cli.count('genre', 'Rock', 'group', 'albumartist')

I would expect a list of object of that kind instead:

>>> cli.count('group', 'albumartist')
[ {'albumartist': 'art00', 'playtime': '123', 'songs': '1'},
  {'albumartist': 'art01', 'playtime': '321', 'songs': '2'},
…]

This object does not require extra processing to link grouping values with its playtime/songs stats.

I had a quick look at the raw MPD output, I think this might be tricky since the delimiter changes depending on the function signature. I don't have a straight forward solution to submit.

That's it
Thanks for your work

@Mic92
Copy link
Owner

Mic92 commented Feb 16, 2015

it could use the first key received on the wire as delimiter.

@mxjeff
Copy link
Collaborator Author

mxjeff commented Feb 16, 2015

I don't see how to do it without changing or writing an alternative _read_objects method.

Another solution might be to give all possible delimiters, or a smaller set of them and let users append tags they might need. For instance:

# in mpd.py
COUNT_GROUPING = ['artist', 'albumartist', 'album', 'genre']
.
 .
  .
    def _fetch_count(self):
        return self._fetch_objects(COUNT_GROUPING)

Then it could be easily extend like that:

>>> mpd.COUNT_GROUPING += [MyGroupingTag]
>>> cli.count('group', MyGroupingTag]

@mxjeff
Copy link
Collaborator Author

mxjeff commented Feb 23, 2015

I've added a example of a grouping count command in my repo, ref. count#50.

@Mic92
Copy link
Owner

Mic92 commented Feb 25, 2015

sorry for the delay. I will have a look at it tomorrow.

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

Successfully merging a pull request may close this issue.

2 participants