Respect `artist_credit` when importing
Description
Fixes #5010. Fixes #5633.
I've started with the most naive solution - this is essentially the same piece of logic in five places - as I'm not yet feeling comfortable to mess with AlbumInfo/TrackInfo, nor have I found an optimal place to do so. Some pointers on centralizing this (if it makes sense?) are welcome!
I would proceed adding the tests after the initial feedback. Thanks!
To Do
- [x] ~Documentation~
- [ ] Changelog
- [ ] Tests
Thank you for the PR! The changelog has not been updated, so here is a friendly reminder to check if you need to add an entry.
Codecov Report
:x: Patch coverage is 44.44444% with 10 lines in your changes missing coverage. Please review.
:white_check_mark: Project coverage is 63.72%. Comparing base (e3574a7) to head (0d2ef50).
:warning: Report is 38 commits behind head on master.
:rocket: New features to boost your workflow:
- :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
@mikeroll that is indeed a lot of duplication. I think a better approach would be to define an attribute on TrackInfo / AlbumInfo:
@property
def artist(self) -> str | None:
artist_credit = (
self["artist_credit"] if beets.config["artist_credit"] else None
)
return artist_credit or self["artist"]
@artist.setter
def artist(self, value: str) -> None:
self["artist"] = value
Let me first refactor these two classes to isolate common functionality into a common Info class where you will be able to define this attribute! I'd already done this in my fork a while ago so I just need to find the relevant commit and open a PR with it.
@mikeroll forgot to mention that my PR has already been merged. Try to rebase on master try my suggestion above