-
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
Make %aunique
work with -f/--format
options.
#3043
Conversation
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.
Looks great! Thank you!! Here’s one small comment.
beets/library.py
Outdated
@@ -1395,6 +1395,8 @@ def get_album(self, item_or_id): | |||
""" | |||
if isinstance(item_or_id, int): | |||
album_id = item_or_id | |||
elif isinstance(item_or_id, Album): | |||
album_id = item_or_id.id |
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.
If this function can now accept Album objects, maybe we should update the docstring to reflect that? (Also, I don’t quite see where the call is that makes this change necessary—maybe that call should be rewritten to just use the Album object it already has instead of going to the database to get another identical copy?)
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.
The call to lib.get_album()
comes from tmpl_aunique where self.item
can be either an Item or an Album.
I couldn't think of a clean way of refactoring that method. I suppose lib.get_album()
, if given an Album, could just return the same object. That would prevent hitting the database twice.
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.
How about using lib.get_album(album_id)
? In your improved version of tmpl_aunique
, we now have an album_id
variable already. That won't prevent hitting the database twice, but it will avoid expanding the responsibilities of get_album
.
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.
Good idea! Pushed a new commit.
Awesome. Looks perfect. 🎉 🚀 🐭 |
This should fix #3042. Let's see if Travis gives the thumbs up...