Commit graph

261 commits

Author SHA1 Message Date
Šarūnas Nejus
4260162d44
Remove all Python 2 references 2025-07-08 11:37:34 +01:00
Šarūnas Nejus
7cada1c9f8
Remove no-op decargs 2025-07-08 11:37:33 +01:00
Šarūnas Nejus
fdc1aba603
Replace typing.cast with explicit type definitions and ignore TC006 2025-05-07 20:39:33 +01:00
Šarūnas Nejus
5c81f94cf7
Move imports required for typing under the TYPE_CHECKING block 2024-12-10 06:10:04 +00:00
Šarūnas Nejus
161b0522bb
Update deprecated imports 2024-12-10 06:10:04 +00:00
Šarūnas Nejus
7ef1b61070
Replace Union types by PEP604 pipe character 2024-12-10 06:10:04 +00:00
Šarūnas Nejus
51f9dd229e
Use PEP585 lowercase collections typing annotations 2024-12-10 06:10:03 +00:00
Šarūnas Nejus
85a17ee503
Reformat the codebase 2024-09-21 11:57:48 +01:00
Šarūnas Nejus
19470f3d76
Use native os.cpu_count
os.cpu_count has only been available since Python 3.4
2024-06-16 00:52:38 +01:00
Šarūnas Nejus
f388ff6ec1
Replace py3_path with builtin os.fsdecode
`os.fsdecode` has only been available since Python 3.2.
2024-06-16 00:52:37 +01:00
Arav K.
549fea14cd [util/pipeline] use 'Queue' without generics
Apparently Python 3.8 does not support generic type parameters on the
built-in 'queue.Queue' type?
2024-06-12 15:59:31 +02:00
Arav K.
d3bdf137ea Resolve some 'mypy' errors 2024-06-12 15:58:00 +02:00
Serene-Arc
83242fd7cf Apply formatting 2024-03-01 15:21:25 +10:00
wisp3rwind
05383a0dab replaygain: typings
also, minor clean-up (remove unused function after_version, f-string
conversion)
2023-11-05 08:25:39 +01:00
Serene-Arc
a6e5201ff3 Apply formatting tools to all files
This is 'the big one', which touches every file so that it all conforms
to the given standard.
2023-10-22 09:53:18 +10:00
wisp3rwind
3965858ac1 replaygain: apply review feedback: fixup previous refactor, improve tests
by adding files which are not completely silent, thus hitting a different
code path in some calculations

The sample files were generated using
> sox -n whitenoise.flac synth 00:00:02 whitenoise
> ffmpeg -i whitenoise.flac whitenoise.opus
> ffmpeg -i whitenoise.flac whitenoise.mp3
2023-07-22 12:47:19 +02:00
wisp3rwind
b8be2af11d replaygain: in Gst backend, pass paths instead of items around
This is a preparation for moving the Gst calculation to multiprocessing
worker threads. Passing only the file paths to the worker threads instead of
synchronizing the entire `Item`s (i.e. minimizing the data that is
shared between the processes) hopefully helps to prevent any issues with
this approach.
2023-07-22 12:47:19 +02:00
wisp3rwind
fa37085493 replaygain: in ffmpeg backend refactor album gain calculation
now that we have the `track_results` upfront, some simplifications are
possible
2023-07-22 12:47:19 +02:00
wisp3rwind
76f6c86291 replaygain: in ffmpeg backend, analyse items upfront, then summarize...
...album gains. This is in preparation for parallelizing the track
analysis, and computing the album values in the plugin's "main thread"
once all items are done.
2023-07-22 12:47:19 +02:00
wisp3rwind
545ed6f385 replaygain: log album name for album tasks
doesn't seem to be very useful to log the _list of items_ here
2023-07-22 12:47:19 +02:00
wisp3rwind
7ec7a0d362 replaygain: avoid hasattr in favor of None values
to check for an optional ThreadPool. Seems more idiomatic and readable.
2023-07-22 12:47:19 +02:00
Adrian Sampson
675dd7b9a9
Add logging for command output on errors 2022-10-01 16:08:32 -07:00
Adrian Sampson
9803939a1c
replaygain: Fix error handling for parallel runs
The parallelism strategy in #3478, in retrospect, used a pretty funky
way to deal with exceptions in the asynchronous work---since
`apply_async` has an `error_callback` parameter that's meant for exactly
this. The problem is that the wrapped function would correctly log the
exception *and then return `None`*, confusing any downstream code.
Instead of just adding `None`-awareness to the callback, let's just
avoid running the callback altogether in the case of an error.
2022-10-01 15:47:41 -07:00
Adrian Sampson
c5e68f5643
Adapt to pycodestyle changes 2022-07-30 19:54:24 -04:00
wisp3rwind
8572e9bcec replaygain: add docstrings 2022-01-22 14:00:32 +01:00
wisp3rwind
d19cc593e3 replaygain: better types to represent peak methods
thanks @ybnd in review https://github.com/beetbox/beets/pull/3996 for
this suggestion to properly represent the sum type
2022-01-22 14:00:32 +01:00
wisp3rwind
80f7c58e5a replaygain test: add basic per_disc testcase
The per_disc codepath is currently not exercised at all by the tests.
This test is not very meaningful, but better than nothing.
2022-01-22 14:00:32 +01:00
wisp3rwind
a2df6df9da replaygain: store_track, store_album are methods on *Task
Also, add a convenience function `store()` that dispatches two the
either of the two methods. This will be useful later, when rewriting the
parallel code (but doesn't simplify the code now).
2022-01-22 14:00:32 +01:00
wisp3rwind
9ead9cdbb8 replaygain: pass the write flag explicitly
The variable was previously captured by the closure. This is in
preparation for moving these nested functions elsewhere.
2022-01-22 14:00:32 +01:00
wisp3rwind
ad75cbf4a5 replaygain: Flatten data structures
Now that we have the *Task objects, the AlbumGain tuple can be removed.
2022-01-22 14:00:32 +01:00
wisp3rwind
67d85d18ad replaygain: introduce Task objects to bundle the state related to computations
Renames *GainHandler -> *Task and instead of having a singleton
instance, creates a *Task object for each album/item to process. The
advantage is that now, related data can be bundled in the instance,
instead of passing multiple arguments around.
2022-01-22 14:00:32 +01:00
wisp3rwind
ae3e95f9d3 replaygain: Convert the ad-hoc tag_specific_values to classes
The plugin has loads of indirection and nested functions which make it
really hard to reason about. The larger picture here is that I'd like to make
the code more manageable before reworking the parallelism issues.

In particular, instead of manually implementing an interface using a
function that returns a tuple of function pointers, this commit creates proper
classes. Again, no functionality is changed, this only moves code
around.
2022-01-22 14:00:32 +01:00
wisp3rwind
edf2bda1ce replaygain: store backend name as class attribute
Doesn't change any functionality, but appears a little cleaner to me.
2022-01-22 14:00:32 +01:00
wisp3rwind
96025c6de6 replaygain: avoid determining the method again and again 2022-01-22 14:00:32 +01:00
wisp3rwind
3eb49fca2e replaygain: clarify docs for overwrite/force and actually respect it correctly
The code used to always check the 'overwrite' config value, while that
should only apply during imports. The manual 'replaygain' command has it's
own '-f' flag.

The logic for this flag was changed quite a few times recently, see

https://github.com/beetbox/beets/pull/3816
https://github.com/beetbox/beets/issues/3872
https://github.com/beetbox/beets/pull/3890

but apparently we (me and @ybnd) never really got it right...
If it is some comfort, the logic was never correct in the first place.
2022-01-22 14:00:32 +01:00
wisp3rwind
6689502854 replaygain: rewrite long conditionals in a more imperative manner (2/2)
This is significantly easier to parse (for me, at least).
Also, void building some lists inside of any(...) in the process.
2022-01-22 14:00:32 +01:00
wisp3rwind
356a775c5e replaygain: rewrite long conditionals in a more imperative manner (1/2)
This is significantly easier to parse (for me, at least).
Also, void building some lists inside of any(...) in the process.
2022-01-22 14:00:32 +01:00
wisp3rwind
807f124ef8 really remove all six imports
apparently, pyupgrade didn't know how to handle these...
2022-01-20 00:26:01 +01:00
Andrew Rogl
ee4268dabb Remove unused imports
Fix imports
Fix formatting
2021-08-26 20:59:48 +10:00
Andrew Rogl
1ec87a3bdd pyupgrade beetsplug and tests
All tests working
More tidy up to be done
2021-08-26 19:12:51 +10:00
Benedikt
e5f1cca8a3
Merge pull request #3890 from wisp3rwind/pr_rg_import_fixes
replaygain: fix write/force flags on import
2021-03-18 22:42:42 +01:00
Benedikt
c8c73cc789
Merge pull request #3891 from wisp3rwind/pr_rg_de-nest
replaygain: don't nest functions when there's no need to
2021-03-18 22:41:13 +01:00
wisp3rwind
d3ec2106cd replaygain: fix write/force flags on import
This restores old behaviour.
2021-03-18 18:37:15 +01:00
wisp3rwind
0125fdf415 replaygain: don't nest functions when there's no need to 2021-03-18 18:31:00 +01:00
wisp3rwind
feb5041f57 replaygain: remove debugging leftovers 2021-03-18 14:29:28 +01:00
Aksh Gupta
79858975a9 chore: refactor code quality issues 2021-03-11 08:45:42 +05:30
Samuel Cook
ff4cec2e69
Removes support for bs1770gain.
References in the documentation to this plugin were removed in
beetbox/beets#3127 (beetbox/beets#3130) but no actual code
changes were made.

This PR removes support for this dependency entirely.
2021-01-27 17:42:18 -08:00
ybnd
eb8ba838e5 Check 'auto' on import_begin 2020-12-22 12:45:28 +01:00
ybnd
93101e7ea6 Disable replaygain parallelism during import 2020-12-21 19:19:20 +01:00
ybnd
12db40fa67 Remove .get() when checking config values 2020-12-21 08:50:39 +01:00