Commit graph

12644 commits

Author SHA1 Message Date
J0J0 Todos
44901873f7 Clarify log-label: keep any, no-force 2025-01-21 17:04:03 +01:00
J0J0 Todos
d5cf376a51 Include lower-casing in _get_existing already
since we don't use it for early-returning no-force-existing genres
anymore.
2025-01-21 17:04:03 +01:00
J0J0 Todos
8da98e52ee Further clarify lastgenre log-labels
state if whitelist was applied or any genre is accepted.
2025-01-21 17:04:03 +01:00
J0J0 Todos
6e6a0ad9a9 Return empty tuple instead of disabling type issue 2025-01-21 17:04:03 +01:00
J0J0 Todos
c9187b40bd Don't uselessly split/join early returned genres 2025-01-21 17:04:03 +01:00
J0J0 Todos
169ec20a2f Remove unused _polish_existing_genres 2025-01-21 17:04:03 +01:00
J0J0 Todos
3cc2a5e2c6 Fix Tuple with tuple in sources property 2025-01-21 17:04:03 +01:00
J0J0 Todos
5d94eb3e13 Fix _get_genre docstring 2025-01-21 17:04:03 +01:00
J0J0 Todos
7ff06df17c Simplify _get_existing_genres()
Co-authored-by: Šarūnas Nejus <snejus@protonmail.com>
2025-01-21 17:04:03 +01:00
J0J0 Todos
c3f0abd61c Fix docstring _resolve_genres
Co-authored-by: Šarūnas Nejus <snejus@protonmail.com>
2025-01-21 17:04:03 +01:00
J0J0 Todos
bb3f9c53c2 lastgenre new defaults, remove config sanity check 2025-01-21 17:04:03 +01:00
J0J0 Todos
4e8948d7ca Rework new & refine existing lastgenre docs chapters
and describe according to new defaults: force and keep_existing
DISABLED, ensuring failsafe operation out of the box.
2025-01-21 17:04:03 +01:00
J0J0 Todos
ca5e471f05 Refactor again _last_lookup 2025-01-21 17:04:03 +01:00
J0J0 Todos
ec10507fab Return as-is if no-force 2025-01-21 17:04:03 +01:00
J0J0 Todos
6e3f5b3127 Fix type hints, Refactor existing genres method
- 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
2025-01-21 17:04:03 +01:00
J0J0 Todos
ed68bc019b Refactor _get_genre, simplify _combine_genre 2025-01-21 17:04:03 +01:00
J0J0 Todos
4580757c8e Simplify _last_lookup()
f-string, list comprehension, remove redundant vars.
2025-01-21 17:04:03 +01:00
J0J0 Todos
f16e671ff6 Simplify _get_genre keep_existing conditional
- 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.
2025-01-21 17:04:03 +01:00
J0J0 Todos
f698f21a28 Ensure _resolve returns list, add type hint
Prevents potential type erros when handing over to
_to_delimited_genre_string.
2025-01-21 17:04:03 +01:00
J0J0 Todos
d358a24ed9 Remove redundant unique_list call in _combine
and clarify in _resolve_genre docstring.
2025-01-21 17:04:02 +01:00
J0J0 Todos
2a80a10aa8 Use util.unique_list in fav of deduplicate 2025-01-21 17:04:02 +01:00
J0J0 Todos
79b5379dce Refactor and rename _is_valid() helper 2025-01-21 17:04:02 +01:00
J0J0 Todos
14974533e8 Revert "Quickfix constant msgpack poetry issue"
This reverts commit cfc4c9866bd7be8856b35bfbb62fd778bfd9054e.
2025-01-21 17:04:02 +01:00
J0J0 Todos
e1fe6fd3d0 Prevent album genre inherit only when source:track
is configured.
2025-01-21 17:04:02 +01:00
J0J0 Todos
bd0c02437a Apply temp logging leftover review suggestions
Useless variables that only were introduced for temporary debug logging
while refactoring earlier. Get rid of them.

Co-authored-by: Šarūnas Nejus <snejus@protonmail.com>
2025-01-21 17:04:02 +01:00
J0J0 Todos
b476560d76 Integrate _format_tag in _to_delimited_...
optimize by checking for config once and simplify tags list slicing.
Remove _format_tags method.

Co-authored-by: Šarūnas Nejus <snejus@protonmail.com>
2025-01-21 17:04:02 +01:00
J0J0 Todos
593f5460b6 Apply type hint suggestions from review
Co-authored-by: Šarūnas Nejus <snejus@protonmail.com>
2025-01-21 17:04:02 +01:00
J0J0 Todos
6b41743b91 Polish 'fetched last.fm tags' debug message
The best place to log what we actually fetched from last.fm seems to be
here in _combine_and_label_genres. Leave out the existing genres we also
receive in this function - less is more.
2025-01-21 17:04:02 +01:00
J0J0 Todos
8d43517a71 Remove all lastgenre temporary debug logging 2025-01-21 17:04:02 +01:00
J0J0 Todos
847b7260b4 Fix most popular track genre fetching (VA albums) 2025-01-21 17:04:02 +01:00
J0J0 Todos
1aca3989d7 Fix previous temp log messages 2025-01-21 17:04:02 +01:00
J0J0 Todos
da98d37632 Temporary debug messages in _sort_by_depth 2025-01-21 17:04:02 +01:00
J0J0 Todos
a717998587 Add a temporary log around whitelist setup 2025-01-21 17:04:02 +01:00
J0J0 Todos
a49f12b110 Final lastgenre docs changes 2025-01-21 17:04:02 +01:00
J0J0 Todos
37fc1b6b7f Final lastgenre plugin linting 2025-01-21 17:04:02 +01:00
J0J0 Todos
6cd000750a _resolve_genre as list tests, add test_to_delimited_string
- Adapt tests to _resolve_genres returning a list with not yet formatted genres.
- Rename and adapt test_count -> test_to_delimited_string. Note that the
  new function does not apply whitelist, prefer anything. It just cuts
  to count and formats!
2025-01-21 17:04:02 +01:00
J0J0 Todos
13ae699230 Fix _dedup_genre, ensure lower case
otherwise deduplicate() can't handle it.
2025-01-21 17:04:02 +01:00
J0J0 Todos
dd3a74ca4d Fix lastgenre limit to count test
- No idea where a missing separator (which is default) could
  happen...just set it explicitely.
- Since we now refactored fetch_genre to returning a list we can add
  mock multiple fetched gernes easier.
2025-01-21 17:04:02 +01:00
J0J0 Todos
569ba73016 Refactor again _combine_and_label_genres 2025-01-21 17:04:02 +01:00
J0J0 Todos
3d036473e7 lastgenre _is_allowed detailed logging
- Add detailed debug logging to learn when and why things go wrong here.
- Shorten docstring
2025-01-21 17:04:02 +01:00
J0J0 Todos
b4590ec3e0 Fix/add lastgenre fallback tests 2025-01-21 17:04:02 +01:00
J0J0 Todos
50e2619ed2 Refactor lastgenre mocked fetchers return list 2025-01-21 17:04:02 +01:00
J0J0 Todos
9f5b4badb2 Handle genres as list, count/format/str helper
- Return fetched genres as a list from _resolve_genres().
- Format, limit to count and join to delimited string in helper
  function.
- Fix docstring.
- Leave a couple of temporary debug messages.
- Fix original genre fallback - just keep as-is.
2025-01-21 17:04:02 +01:00
J0J0 Todos
5e6d9170d7 Fix lastgenre "count" issue
When original genres were kept (keep_existing option), the final genre
count was "off". The reason was that reducing genres to that count is
handled in _resolve_genre which wasn't run.

- This fixes it by ensuring a run of _resolve_genre in
  _combine_and_label_genres.
- There is a small caveat though: New genres have been run through
  _resolve_genres already. When they are combined with the old ones,
  they run through it again. Let's take this into account for now and
  hope performance doesn't suffer too much.
2025-01-21 17:04:02 +01:00
J0J0 Todos
3e452e7b76 lastgenre test _get_genre for renamed keep_existing
and decide to use the original default whitelist instead of trying to
mock it. Some of the existing tests do it that way as well.
2025-01-21 17:04:02 +01:00
J0J0 Todos
d0abc0d830 Rename lastgenre option, refactor, new default
- Refactor and simplify logic of _get_genre()
- Add a config validation function.
- New default force: yes, keep_existing: yes (closest to original
  behaviour)
2025-01-21 17:04:02 +01:00
J0J0 Todos
998f2f8984 Rewrite docs for keep_allowed/existing change 2025-01-21 17:04:02 +01:00
J0J0 Todos
4c7d0c98cf Clarify lastgenre _is_allowed docstring 2025-01-21 17:04:02 +01:00
J0J0 Todos
90c48ea8cf Temporary lastgenre debug messages for @arsaboo 2025-01-21 17:04:02 +01:00
J0J0 Todos
1c14574e85 Add lastgenre testcase with unicode \0 separator 2025-01-21 17:04:02 +01:00