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

Use flexible attributes as aunique keys #3553

Closed
gregforcey opened this issue Apr 16, 2020 · 1 comment · Fixed by #4140
Closed

Use flexible attributes as aunique keys #3553

gregforcey opened this issue Apr 16, 2020 · 1 comment · Fixed by #4140
Labels
feature features we would like to implement

Comments

@gregforcey
Copy link

gregforcey commented Apr 16, 2020

Use case

I would like to be able to use flexible attributes as aunique keys for disambiguation. One use case of this would be when having multiple versions of the same album in different resolutions: 16/44 and 24/96, for example. In this case beets should treat the same album in different resolutions as a different album and thus not add the disambiguators at the end of the album name if this occurs.

Solution

Something like the following is how it should be implemented:

aunique:
    keys: original_year albumartist album album_bitdepth album_samplerate
    disambiguators: albumtype label catalognum albumdisambig releasegroupdisambig
    bracket: '{}'

album_fields:  
      album_bitdepth: |
       total = 0
       for item in items:
           total += item.bitdepth
       return round(total / len(items))
    album_samplerate: |
       total = 0
       for item in items:
           total += item.samplerate
       return round(total / len(items) / 1000)

Alternatives

I posted a question in the forums and it was suggested I file a feature request. I don't believe there are any alternatives

Related issue

#2678

@gregforcey gregforcey changed the title Use custom fields as aunique keys Use flexible attributes as aunique keys Apr 16, 2020
@sampsyo sampsyo added the feature features we would like to implement label Apr 16, 2020
@sampsyo
Copy link
Member

sampsyo commented Apr 16, 2020

Thanks!!

For posterity: I linked in the aforementioned forum thread where the change would have to take place. When constructing a MatchQuery, the aunique template function would need to possibly set the fast parameter to False for non-fixed attributes.

drizzt added a commit to drizzt/beets that referenced this issue May 2, 2020

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
drizzt added a commit to drizzt/beets that referenced this issue May 2, 2020
jcassette added a commit to jcassette/beets that referenced this issue Nov 11, 2021
jcassette added a commit to jcassette/beets that referenced this issue Nov 11, 2021
jcassette added a commit to jcassette/beets that referenced this issue Nov 11, 2021
sampsyo added a commit that referenced this issue Nov 11, 2021
Use slow queries for flexible attributes in aunique (fix #2678, close #3553)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature features we would like to implement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants