beetbox / beetbox/beets

scrub plugin: preserve tags

Open
#1,514 4 comments 0 reactions 0 assignees View on GitHub
discussion scrub
Dominant language
Python
Stars
15.7k
Forks
2.1k
Avg merge
4d 21h
Merged PRs (30d)
31

Description

I just happened to run into the following issue: One of my plugins taps into the `write` event to [preserve the file's year tag](https://github.com/sampsyo/beets/issues/1498). In the event handler, I read the file's tags again, constructing a `MediaFile` object. While `import`ing new songs, I noticed that the properties of those MediaFiles were returning `None` (e.g. `mf.year == None`), although they should contain valid values. Turns out that disabling the `scrub` plugin fixes this.
Now what I think is happening here is that the `scrub` plugin comes into action and deletes the file's meta data right before my other plugin kicks in, only to find empty tags.

IMO there are two ways to fix this:
- Make the execution order of plugins configurable (probably a smart idea anyways, but could be a big chunk of work)
- Use a white list in `scrub`, permitting to preserve listed tags. Something along the lines of:

```
scrub:
auto: yes
preserve: art comments year
```

I am not sure about the former, but the latter seems not too difficult to achieve. Similar to what we do with the cover art on a manual `scrub` operation: Save listed tags → clear tag frame → restore preserved tags. This would be a more generalized approach to solving #571.

Contributor guide

Open the contributing guide

Research direction

Start by reading the scrub plugin implementation and the handling of the write event, then compare it with the existing manual scrub behavior that preserves cover art. Determine how a configured list such as `preserve: art comments year` should be applied during automatic scrubbing, and verify that plugins reading MediaFile tags during import still see the preserved values.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cli
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.