-
Notifications
You must be signed in to change notification settings - Fork 119
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
don't show duplicated tags as strings '[x, x]' #54
Comments
python-mpd was actually exposing multi-value tags as a list, which is fine I think. But I'm not sure this is relevant to to merge duplicated tag values at the module level. For instance here is how I handle it in my client: class Track:
"""
Track object.
Instanciate with Player replies.
"""
def __init__(self, **kwargs):
self.title = self.artist = self.album = self.albumartist = ''
self.__dict__.update(**kwargs)
# have tags been collapsed?
self.collapsed_tags = list()
# Needed for multiple tag values which returns a list instead of a string
self.collapse_tags()
def collapse_tags(self):
"""
Necessary to deal with tags defined multiple times.
These entries are set as lists instead of strings.
"""
for tag, value in self.__dict__.items():
if isinstance(value, list):
self.collapsed_tags.append(tag)
self.__dict__.update({tag: ', '.join(set(value))}) |
I could not reproduce your bug. I have added a test here, where it returns a list. I have also tried:
|
I seriously don't know what i tested last night, but you are right... i guess mark this as invalid :P |
sometimes tags in mpd protocol can be duplicates of one another.
This esp. happens if one tagged his library using beets.
This is how raw protocol serves those tags:
in python-mpd2 the 2 "track" values will be represented as one string value:
python-mpd2 could check for key:value on parsing and if multi-values for one key are identical simply merge them. Otherwise represent them as a list.
Alternatively represent all duplicate tags as lists, even if all values are identical. Personally I prefer the first option :)
The text was updated successfully, but these errors were encountered: