Commit graph

10772 commits

Author SHA1 Message Date
wisp3rwind
af70b75670 fetchart/artresizer: Improve comments & docstrings, avoid os.stat if
possible

slight enhancements on top of https://github.com/beetbox/beets/pull/3560
2021-03-23 12:04:30 +01:00
David Swarbrick
07b5e69f40 fetchart/artresizer: add max_filesize support (#3560)
Squashed from the PR, relevant commit messages follow below:

Added file size option to artresizer

 - In line with comments on PR, adjusted the ArtResizer API to add
   functionality to "resize to X bytes" through `max_filesize` arg

 - Adjustment to changelog.rst to include max_filesize change to ArtResizer
   and addition of new plugin.

Added explicit tests for PIL & Imagemagick Methods

 - Checks new resizing functions do reduce the filesize of images

Expose max_filesize logic to fetchart plugin

- Add syspath escaping for OS cross compatibility
- Return smaller PIL image even if max filesize not reached.
- Test resize logic against known smaller filesize (//2)
- Pass integer (not float) quality argument to PIL
- Remove Pillow from dependencies
- Implement "max_filesize" fetchart option, including
  logic to resize and rescale if maxwidth is also set.

Added tests & documentation for fetchart additions.

Tests now check that a target filesize is reached with a
higher initial quality (a difficult check to pass).

With a starting quality of 95% PIL takes 4 iterations to succeed
in lowering the example cover image to 90% its original size.
To cover all bases, the PIL loop has been changed to 5 iterations
in the worst case, and the documentation altered to reflect the
50% loss in quality this implies. This seems reasonable as users
concerned about performance would most likely be persuaded to
install ImageMagick, or remove the maximum filesize constraint.
The previous 30% figure was arbitrary.
2021-03-23 12:00:14 +01:00
wisp3rwind
64dc3ec2a2 plugins: Python 3.10 compatibility
In

766c8b190b from [1]

a slight hack was introduced that allowed to add new arguments to
plugin events without breaking legacy plugins that did not feature
those arguments in the signature of their handler functions.

When improving logging management for plugins in

327b62b610 from [2]

this hack was removed, to be restored with

7f34c101d7 from [3]

Now in addition to inspecting the function signature, an assumption is
made about the string message of the TypeError that occurs for legacy
handler functions (namely, that it start with func.__name__).

In Python 3.10, the TypeError uses func.__qualname__ [4], however, due
to the patch [5]. Thus, checking whether the TypeError is due to an
outdated function signature or something internal to the handler fais.

As a fix, instead of using __name__ or __qualname__ depending on Python
version, let's just revert to the old hack from [1], I'm not seeing a
significant advantage in [3].  The latter might be a bit faster since it
doesn't construct a new dict for each call, but only for legacy calls in
the excption handler. I doubt that really matters, and if it does, we
should try to think of a better fix than inspecting error messages with
no guarantees about their content in such a central place in the code.

[1] https://github.com/beetbox/beets/pull/652
[2] https://github.com/beetbox/beets/pull/1320
[3] https://github.com/beetbox/beets/pull/1359
[4] https://docs.python.org/3.10/glossary.html#term-qualified-name
[5] https://bugs.python.org/issue40679
2021-03-23 09:51:44 +01:00
Benedikt
fdd1deed22
Merge pull request #3896 from wisp3rwind/ci_nightly
ci: also run on latest Python alpha, but allow failure
2021-03-23 09:30:36 +01:00
wisp3rwind
78808e4654 ci: also run on latest Python alpha, but allow failure 2021-03-23 09:18:56 +01:00
Benedikt
8648e9b518
Merge pull request #3895 from wisp3rwind/ci_reduce_skips
ci: install ffmpeg for replaygain tests; show skipped tests
2021-03-23 09:00:26 +01:00
Adrian Sampson
2d9f0cc522
Merge pull request #3894 from wisp3rwind/setup_py_improvements
setup.py: add 3.9 classifier, add note about ffmpeg dep for replaygain
2021-03-22 19:51:45 -04:00
wisp3rwind
68fa03a5eb ci: install ffmpeg for replaygain tests; show skipped tests
We lost the ability to show skipped tests when transitioning to gh
actions. As it turns out, all of the replaygain tests were being
skipped, so as a start, try to install at least one backend.
2021-03-22 19:07:34 +01:00
wisp3rwind
89624cf0a1 setup.py: add 3.9 classifier, add note about ffmpeg dep for replaygain 2021-03-22 19:04:49 +01:00
Jack Wilsdon
2399a4215d
Merge pull request #3234 from jackwilsdon/fix-import-set-equals
Allow equals within import --set value
2021-03-22 16:23:43 +00:00
Jack Wilsdon
01bc32e50e Allow equals within import --set value 2021-03-22 15:26:14 +00:00
Adrian Sampson
d7c556f7d1
Remove stray cue plugin (fix #3892) 2021-03-20 09:04:03 -04: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
Benedikt
8353c831d1
Merge pull request #3889 from wisp3rwind/pr_fix_repr_deadlock
Avoid deadlocks in Item.__repr__
2021-03-18 22:39:30 +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
3d5142433f avoid deadlocks in Item.__repr__ 2021-03-18 18:05:19 +01:00
Benedikt
aa7d724aa4
Merge pull request #3886 from wisp3rwind/optimize_show_model_changes
slight performance optimization for ui.show_model_changes
2021-03-18 18:02:23 +01:00
Benedikt
0061229023
Merge pull request #3887 from wisp3rwind/fix_item_keys
when iterating over item keys, do not return duplicates
2021-03-18 18:01:34 +01:00
Benedikt
eea5c6d1f0
Merge pull request #3888 from wisp3rwind/pr_rg_cleanup
replaygain: remove debugging leftovers
2021-03-18 18:00:41 +01:00
wisp3rwind
feb5041f57 replaygain: remove debugging leftovers 2021-03-18 14:29:28 +01:00
wisp3rwind
a3a2678494 slight performance optimization for ui.show_model_changes
I didn't actually benchmark this, but creating new FormattedItemMapping
views in each iteration of the loop appeared like a rather inefficient
way of doing things. In reality, this is probably completely irrelevant,
since one would usually not show huge numbers of changed Models at a
time.
2021-03-18 12:41:59 +01:00
wisp3rwind
5183fc53ad when iterating over item keys, do not return duplicates
... for keys that exist both as Item and Album fields
2021-03-18 12:29:39 +01:00
Adrian Sampson
42d9a54ae6
Merge pull request #3885 from nicksellen/fix/no-ascii-encode
Remove ascii encode step
2021-03-17 07:58:48 -04:00
Graham Cobb
39cb013bd3
Merge pull request #3883 from GrahamCobb/bareasc
Experimental "bare-ASCII" matching query
2021-03-17 11:06:31 +00:00
Nick Sellen
6dc1f6414d
Remove ascii encoding step now library is fixed 2021-03-17 09:06:35 +00:00
Graham R. Cobb
c3485b5b04 Remove unnecessary call to format.
Signed-off-by: Graham R. Cobb <g+beets@cobb.uk.net>
2021-03-16 22:36:42 +00:00
Graham R. Cobb
b0110fa224 Try again to fix unidecode_list for python2 support
Signed-off-by: Graham R. Cobb <g+beets@cobb.uk.net>
2021-03-16 16:40:43 +00:00
Graham R. Cobb
cad2c055c5 Make unicode handling explicit, to support python 2 and 3.
Add link to Unidecode library in docs.

Signed-off-by: Graham R. Cobb <g+beets@cobb.uk.net>
2021-03-16 16:29:57 +00:00
Graham Cobb
4b9c9d0a5f
doc improvement as suggested by @sampsyo
Co-authored-by: Adrian Sampson <adrian@radbox.org>
2021-03-16 15:30:43 +00:00
Graham Cobb
2df3765521
Tidy doc as suggested by @sampsyo
Co-authored-by: Adrian Sampson <adrian@radbox.org>
2021-03-16 15:29:35 +00:00
Graham R. Cobb
0078b02085 Python2 support for bareasc command
Signed-off-by: Graham R. Cobb <g+beets@cobb.uk.net>
2021-03-16 14:50:51 +00:00
Graham R. Cobb
d1ec7b4b70 Add `bareasc` command to display entries with the unidecode transformation
applied.

Signed-off-by: Graham R. Cobb <g+beets@cobb.uk.net>
2021-03-16 11:57:52 +00:00
Graham R. Cobb
06b6b72e0e Add credit to Unidecode library into bareasc docs.
Signed-off-by: Graham R. Cobb <g+beets@cobb.uk.net>
2021-03-15 22:52:14 +00:00
Graham R. Cobb
f4fccfa05c Add documentation for bareasc to the plugins index.
Signed-off-by: Graham R. Cobb <g+beets@cobb.uk.net>
2021-03-15 15:53:14 +00:00
Graham R. Cobb
341a0a0adf Added documentation and changelog for bareasc.
Signed-off-by: Graham R. Cobb <g+beets@cobb.uk.net>
2021-03-15 15:34:58 +00:00
Graham R. Cobb
fab7a27e9f Add a couple more tests and make lint happy.
Signed-off-by: Graham R. Cobb <g+beets@cobb.uk.net>
2021-03-15 12:43:58 +00:00
Graham R. Cobb
dcbe622b76 Oops, use in for matching! (It was late last night!)
Signed-off-by: Graham R. Cobb <g+beets@cobb.uk.net>
2021-03-15 10:25:19 +00:00
Graham R. Cobb
80048e7153 Specify unicode, for python2
Signed-off-by: Graham R. Cobb <g+beets@cobb.uk.net>
2021-03-15 09:11:17 +00:00
Graham R. Cobb
7dd1ee3fab Remove debugging print.
Signed-off-by: Graham R. Cobb <g+beets@cobb.uk.net>
2021-03-15 01:09:50 +00:00
Graham R. Cobb
0c612f408b Create plugin for "bare-ASCII" matching query
Signed-off-by: Graham R. Cobb <g+beets@cobb.uk.net>
2021-03-15 00:55:14 +00:00
Adrian Sampson
c4347960ea
Merge pull request #3877 from GrahamCobb/web-readonly
Web readonly
2021-03-12 17:51:57 -05:00
Graham R. Cobb
4ffe9a2c45 Fixed bug where readonly value was not being read from config file.
Also simplified the setup of the `readonly` value in the tests which
fixes a test ordering issue found using --random-order.

Signed-off-by: Graham R. Cobb <g+beets@cobb.uk.net>
2021-03-12 17:58:35 +00:00
Benedikt
feb305f8fc
Merge pull request #3873 from akshgpt7/chore-refactor-issues
Refactor code quality issues
2021-03-12 01:00:43 +01:00
Graham R. Cobb
680ccdcd96 Documentation and changelog for web `readonly` option fixing #3870.
Signed-off-by: Graham R. Cobb <g+beets@cobb.uk.net>
2021-03-11 23:09:51 +00:00
Graham R. Cobb
23c8d61104 Add tests for patch operations
Signed-off-by: Graham R. Cobb <g+beets@cobb.uk.net>
2021-03-11 22:55:42 +00:00
Graham R. Cobb
51d22b765e Add tests for delete operations
Signed-off-by: Graham R. Cobb <g+beets@cobb.uk.net>
2021-03-11 18:02:38 +00:00
Graham R. Cobb
4a9652a9e4 Only allow DELETE or PATCH operations if "readonly" is set to true.
Note: default is false which is a **NOT BACKWARDS COMPATIBLE** change.

Signed-off-by: Graham R. Cobb <g+beets@cobb.uk.net>
2021-03-11 18:02:38 +00:00
Graham R. Cobb
a74cc4b269 Merge remote-tracking branch 'upstream/master' 2021-03-11 17:59:52 +00:00