-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
chroma: Bias toward looking up more relevant releases using date/country #3020
Conversation
Uses match:preferred:countries/original_year: config options to determine whether the releases should be sorted by their respective fields. The behaviour is the same as before when the default config is used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! This looks good, although I have a few comments inline. And could you please also add a changelog entry?
beetsplug/chroma.py
Outdated
year = date.get('year', 9999) | ||
month = date.get('month', 99) | ||
day = date.get('day', 99) | ||
key = '{0:04d}{1:02d}{2:02d}'.format(year, month, day) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any particular reason this produces a string instead of a tuple? Python will happily sort tuples indexwise:
>>> sorted([(1,2,3), (1,1,1)])
[(1, 1, 1), (1, 2, 3)]
beetsplug/chroma.py
Outdated
@@ -88,16 +113,24 @@ def acoustid_match(log, path): | |||
return None | |||
_acoustids[path] = result['id'] | |||
|
|||
# Get recording and releases from the result. | |||
# Get recording and releases from the result, | |||
# sorted by date and/or country depending on 'match'>'preferred' config. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We usually name config options using dot syntax. For example, "the match.preferred configuration option" here. Also, looks like this comment needs to get rewrapped.
beetsplug/chroma.py
Outdated
for recording in result['recordings']: | ||
recording_ids.append(recording['id']) | ||
if 'releases' in recording: | ||
release_ids += [rel['id'] for rel in recording['releases']] | ||
releases.extend(recording['releases']) | ||
country_patterns = config['match']['preferred']['countries'].as_str_seq() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A comment here might be in order to introduce the reason for all this sorting business.
Looks great; thanks!! ✨ |
Allow releases from Acoustid lookup to be sorted by date/country
#3017