-
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
Lastgenre: New config option keep_existing
#4982
base: master
Are you sure you want to change the base?
Conversation
I'd request a review from you @sampsyo since I think you initially created it. Also @rain0r would be good since 5 years ago they added the In short: I think I fixed the plugin to now really reflect what's documented. Any nitpicking in my code or functionality-wise is appreciated. One question already. Here we do not state that a When I started out with using this plugin I was confused a verry long time about this option. As far as I understand it now: It doesn't do anything since it is default. So why keep it? Or is having a I think the both of you decided these options should look like that around here: #3220 (comment) |
Thanks for the extra context, @JOJ0! About the existence of |
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 for the ping!! Here are a couple of straightforward comments.
1e81209
to
89ae925
Compare
89ae925
to
31ce30d
Compare
I'd like to pull out this conversation #4982 (comment) into a new thread, to make it more obvious for others as well. I think it could be a broader discussion of where this plugin should go. Basically we were talking about the current So from my point of view, the main problem with the current behaviour when The following idea would require a new config setting as well as a whole new branch of behaviour (Case 3): Case 1
Case 2
keep any string in present genre tag, only write last.fm genres when empty Case 3
keep present genres when whitelisted and add new last.fm genres (this is a new branch of behaviour and needs to be coded, I think there is open feature requests for it. Update: Something was feature-requested, but it might not be exactly as I'm proposing here: #4750) Case 4
cleanup only - keep present genres when whitelisted but don't add new last.fm genres; Only when genre is empty, add last.fm genres. That last combination is weird though....but it's what I proposed for Which of these would now make sense to be the new default? The new @sampsyo brainstorming request 🧐 |
Some more context / cross-linking: The initial reason why I got my hands dirty with this plugin was when I realised that comma separated multi-genres where not recognized: #4751 (comment) Here @arsaboo requests a feature that goes in direction of Case 3 above: #4750 |
So, we have two config options - Case 1: overwrite all, only fresh last.fm genres remain force: yes
keep_allowed: no Case 2: Since force: no
keep_allowed: no Case 3: keep present genres when whitelisted and add new last.fm genres force: yes
keep_allowed: yes Case 4: keep any string in the present genre tag; only write last.fm genres when empty. This will not touch pre-existing genre tags. force: no
keep_allowed: yes Thus, Case 4 seems like the best default choice. It does not affect existing genre tags and updates the empty ones. Case 3, on the other hand, is the most useful one (at least for me). |
This brainstorming honestly sounds great, y'all. It is indeed really weird that the |
Ähem I might be slow or too tired already. Which of those 4 cases are now different from my proposal @arsaboo ? Sorry I must have missed it! Help! :-) |
Not different....just a little more explicit about the |
fb9f58d
to
c12b26b
Compare
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. |
Hi @arsaboo! I finally managed to find time to almost finish this PR. The general behaviour and docs of the new config options combinations are finished. If you want to, an "early" review would be super helpful. Since it probably also for you is a long time ago it might be interesting what you think if you read through the docs. Is it 100% clear what force/keep_allowed options do? Certainly but only if you have the time, some playing around and checking if it also really works that way would be great. Thanks a ton! |
@JOJ0 this is AWESOME 🎉🎉 The docs look reasonably clear. I will play with this. The debug logs are great to see what is going on. |
796a3bf
to
a56098f
Compare
217aa33
to
8138708
Compare
Co-authored-by: Šarūnas Nejus <[email protected]>
e5ccab9
to
1e14904
Compare
optimize by checking for config once and simplify tags list slicing. Remove _format_tags method. Co-authored-by: Šarūnas Nejus <[email protected]>
Useless variables that only were introduced for temporary debug logging while refactoring earlier. Get rid of them. Co-authored-by: Šarūnas Nejus <[email protected]>
is configured.
This reverts commit cfc4c98.
7c9b593
to
83ab8cb
Compare
and clarify in _resolve_genre docstring.
Prevents potential type erros when handing over to _to_delimited_genre_string.
- If the keep_existing option is set, just remember everything for now. - Dedup happening later on via _combine... _resolve_genres... - Even knowing if whitelist or not is not important at this point.
f-string, list comprehension, remove redundant vars.
5f85506
to
c958a37
Compare
To be honest, yes it is a little confusing. I have considered a single option, many times. I thought it through often and always came to the same conclusion: I like when tools follow certain usability patterns. For example in beets we have Finally I mean we can discuss again what would be the best default for Also, to make docs less confusing what do you think about formatting/structuring them similar to how I propose the new option in this PR's description headline "Details & Docs"
I simply ignored typing. Thanks for the hints. I think I catched all of the new ones. While I'm at it, I could even add them for all the existing ones. Or leave that for another PR, not sure. Hmm but I do see a lot of mypy warnings in the github diff, so I guess I should handle all those?
Thanks so much for an amazing review, there was a lot of room for improvement. Your suggestions encouraged to me to touch things that I did not initially take the time to even understand entirely and I think a lot is improved now and thanks to a not bad test coverage in the plugin I'm quite sure I didn't introduce new bugs (but we'll see, there always are some ;-) |
- Rename method _dedup_genre, since it's only used for finalizing/polishing existing genres. - Return separator-delimited string already. - Decide on not passing "separator" to methods, it's a config setting available throughout the plugin. Assign to variable where useful for readability though. - In the force branch, remove re-assigning keep_genres to empty list. - Fix a test. Existing genres are "polished" now, which means: configured title_case is applied. - Fix/add type hints on all touched and new methods
Thanks GitHub for breaking workflows out of thin air.
This reverts commit f617d23.
988dd79
to
ac4529b
Compare
in completion script.
Description (moved)
Initially this PR included fixes which moved to a separate PR #5582
Description
force
option. Previously disabling the option had "incomplete" behaviour:,
), thus it failed erased all existing genres and overwrote with new ones.This didn't feel like a typical behaviour of a
force
option, which this PR tries to improve as follows...String-separated multi-genres are now compiled into a list and depending on the
whitelist
option are kept and enriched with freshly fetched last.fm genres.If force is off, pre-populated tags are not touched.
A lot of refactoring was done, some absolutely required, some as a preparation for future work on the plugin.
The main processing function
_get_genre
was massively overhauled and got a newpytest.mark.parametrize
test which includes much more test cases.Details & Docs
Back in 2023-09 we decided on an additional option named
keep_allowed
, details on what we came up with: #4982 (comment)):My final conclusion is to change that option name to
keep_existing
, which feels slightly more self-explanatory. I also decided on Setup 3 (see below) as the default because:keep-existing
also enabled by default it feels like a pretty common use-case.Setup 1
Overwrite all. Only fresh last.fm genres remain.
Setup 2
Add new last.fm genres when empty. Present tags stay untouched.
Setup 3 (default)
Add new last.fm genres. Combine genres in present tags with new ones
(depending on the
whitelist
setting, allowed or any).To Do
_get_genre
tests usingpytest.mark.parametrize
and add new test-cases.