beets icon indicating copy to clipboard operation
beets copied to clipboard

Respect `artist_credit` when importing

Open mikeroll opened this issue 7 months ago • 4 comments

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

mikeroll avatar Aug 06 '25 21:08 mikeroll

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.

github-actions[bot] avatar Aug 06 '25 21:08 github-actions[bot]

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.

Files with missing lines Patch % Lines
beets/autotag/distance.py 50.00% 2 Missing and 2 partials :warning:
beets/ui/commands.py 42.85% 2 Missing and 2 partials :warning:
beets/autotag/match.py 33.33% 1 Missing and 1 partial :warning:
:rocket: New features to boost your workflow:
  • :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

codecov[bot] avatar Aug 06 '25 21:08 codecov[bot]

@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.

snejus avatar Aug 25 '25 23:08 snejus

@mikeroll forgot to mention that my PR has already been merged. Try to rebase on master try my suggestion above

snejus avatar Sep 27 '25 12:09 snejus