Commit graph

152 commits

Author SHA1 Message Date
Šarūnas Nejus
85a17ee503
Reformat the codebase 2024-09-21 11:57:48 +01:00
Šarūnas Nejus
249d49942e
Make a change to test 2024-06-14 16:04:15 +01:00
Maxr1998
e64ee0b0cd
beetsplug: Error out on conflicts in template functions
Raises an exception if multiple plugins provide template functions for the same field.

Closes #5002, supersedes #5003.
2023-12-16 16:38:32 +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
J0J0 Todos
284180ec75 Refactor MetadataSourcePlugin._get_id()
and put to use in Spotify plugin.

- Make _get_id() a staticmethod usable from outside a metadata source plugin.
- id_regex now has to be passed as an argument instead of assuming it is
  accessible via an instance variable (self.id_regex).
- In the Spotify plugin, import spotify_id_regex from util.id_extractors
2023-03-08 18:12:31 +01:00
J0J0 Todos
f1794e8709 Support generators in MetadataSourcePlugin.get_artist method 2023-01-03 09:08:31 +01:00
J0J0 Todos
1b0f49fc3b Simplify MetadataSourcePlugin.get_artist method
- Originally a list of "artists" was generated and joined together to a final
  string later.
- This simplifies by concatinating to a final string within the main loop.
- Also this commit gets rid of a mysterious replacement code (` ,' -> ',')
2023-01-03 09:08:21 +01:00
J0J0 Todos
fddeecb29f Add join_key arg to source plugin get_artist method
Add an optional argument to MetadataSourcePlugin.get_artist method that enables
making use of a field containing a keyword supposed to be used to combine
artists together into a single string like "Feat.", "And", "Vs." and so on.
2023-01-02 13:47:31 +01:00
Andrew Rogl
910354a6c6 fix unused import and flake8 2021-08-25 19:07:55 +10:00
Andrew Rogl
6d1316f463 pyupgrade beets dir 2021-08-25 16:05:28 +10:00
Adrian Sampson
07742a5f39
Remove unnecessary temporaries 2021-08-21 13:29:25 -04:00
Adrian Sampson
75c41c0546
Remove most six.PY2 checks 2021-08-19 16:45:11 -04: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
Sam Thursfield
3fec6d347a Use caching in plugins.find_plugins()
This function is called from library.Item._getters(), making it a hot
path when exporting data. We cache plugin instances but previously we
reran `import` for each module on each call. We now return the cached
values providing a speed boost for `beet export`.

This has a small effect on `beet ls` speed: for me it went 11.00s ->
10.40.

It had a significant effect on `beet export` speed when combined with
https://github.com/beetbox/beets/pull/3762/.

Before:

    $ time /home/sam/.local/bin/beet 'export' '--library' '--format' 'jsonlines' '--include-keys' 'artist,title,path,mb_artistid,mb_trackid' 'artist+ title+' > /dev/null
    Executed in   25.13 secs

After:

    $ time /home/sam/.local/bin/beet 'export' '--library' '--format' 'jsonlines' '--include-keys' 'artist,title,path,mb_artistid,mb_trackid' 'artist+ title+' > /dev/null
    Executed in   10.49 secs
2020-12-15 14:16:09 +01:00
x1ppy
3c08911794 Add missing extra_tags parameter to MetadataSourcePlugin (#3540) 2020-04-07 12:12:50 -04:00
x1ppy
19d6dfc8f3 Support extra tags for MusicBrainz queries 2020-03-20 14:13:40 -04:00
Rahul Ahuja
11e00c549b Exclude empty albums from candidates 2019-10-06 00:07:23 -07:00
Rahul Ahuja
52961d71f5
Add defaults to docstring 2019-10-05 16:30:24 -07:00
Rahul Ahuja
19f045290e Fix docstring wording 2019-10-05 15:55:45 -07:00
Rahul Ahuja
a07972d02a Fix docstring wording 2019-10-05 15:53:41 -07:00
Rahul Ahuja
e2c63d4901 Improve docstring wording 2019-10-05 15:25:48 -07:00
Rahul Ahuja
ce90b2aae5 Improve documentation 2019-10-05 15:07:20 -07:00
Rahul Ahuja
14b8f30ead Appease flake8 2019-10-03 19:13:40 -07:00
Rahul Ahuja
a1885a571b Add documentation, fix circular import 2019-10-03 19:03:04 -07:00
Rahul Ahuja
f14137fcc2 Add BPSyncPlugin 2019-10-03 18:04:12 -07:00
Rahul Ahuja
ed80e915fe Move get_distance --> beets.plugins 2019-09-11 00:07:43 -07:00
Rahul Ahuja
876c0f733f Appease flake8 2019-09-10 23:52:35 -07:00
Rahul Ahuja
2b0cf3e002 Try absolute import 2019-09-10 22:39:06 -07:00
Rahul Ahuja
84b13475e0 Move get_distance to beets.autotag 2019-09-09 19:13:24 -07:00
Rahul Ahuja
1de0af669d Try absolute import 2019-09-09 18:45:12 -07:00
Rahul Ahuja
c531b1628e Avoid circular import 2019-09-09 18:28:20 -07:00
Rahul Ahuja
732e372ed2 Rename/move to plugins.MetadataSourcePlugin, fix formatting 2019-09-09 17:31:42 -07:00
Carl Suster
a82002e6c1 confit: replace with confuse in core beets 2019-06-01 09:51:56 +10:00
Carl Suster
546bf3af7e mediafile: import from standalone module 2019-05-29 09:35:14 +10:00
Carl Suster
4be2e1b5e6 Remove beets.util.inspect wrapper 2019-04-02 10:22:47 +11:00
Vladimir Zhelezov
520befb30a Fix #2826: introduce beets.util.inspect wrapper 2019-03-05 08:31:44 +01:00
Vladimir Zhelezov
3eb5907da8 Merge branch 'master' of https://github.com/beetbox/beets into 2826-deprecation-warnings 2019-03-04 21:01:19 +01:00
Adrian Sampson
22c8289269 Support plugin-provided named queries 2019-02-17 13:49:54 -05:00
Vladimir Zhelezov
3e0b2ad146 Fix #2826
Test for major Python version and use inspect.getargspec() or
inspect.getfullargspec() respectively to silence deprecation warnings in
Python 3
2018-12-10 08:40:32 +01:00
Adrian Sampson
bac8faad78 Resolve W605: invalid escape sequence
This came up in lots of regexes that weren't using "raw" literals.
2018-08-13 10:41:01 -04:00
wisp3rwind
318f0c4d16 Advanced fetchart source config: pep8 2018-02-24 11:26:50 +01:00
wordofglass
5a043f28bd Advanced fetchart source config: add validation function 2018-02-24 11:26:50 +01:00
wordofglass
971584b4b2 Improve readability of plugins.sanitize_choices 2018-02-24 11:26:50 +01:00
Michal Koutenský
1bb1bca779 Move the logging wrapper code into a helper function 2018-02-21 15:54:37 +01:00
Michal Koutenský
b140f249c1 Allow plugins to define early import stage functions 2018-02-19 10:45:47 +01:00
wordofglass
bb5629ea1d Remove untyped except statements 2017-04-29 00:05:20 +02:00
nathdwek@laptop
6e3a9d9bc5 collect search results from plugins with yield 2016-11-21 13:39:44 +01:00
nathdwek@laptop
a7fed5b2c4 plugins: document notify_info_yielded 2016-11-21 10:15:51 +01:00
nathdwek@laptop
2b468c1872 plugins: make the signature of notify_info_yielded clearer 2016-11-21 10:15:51 +01:00
nathdwek@laptop
91d1aa9763 plugins: rename notify_info_received->notify_info_yielded 2016-11-21 10:15:51 +01:00