Skip to content

Commit a770a2f

Browse files
committed
musicbrainz: Rename searchlimit config option to search_limit
1 parent 4ef7b23 commit a770a2f

File tree

3 files changed

+23
-7
lines changed

3 files changed

+23
-7
lines changed

beetsplug/musicbrainz.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,14 @@
1818

1919
import traceback
2020
from collections import Counter
21+
from contextlib import suppress
2122
from functools import cached_property
2223
from itertools import product
2324
from typing import TYPE_CHECKING, Any, Iterable, Sequence
2425
from urllib.parse import urljoin
2526

2627
import musicbrainzngs
28+
from confuse.exceptions import NotFoundError
2729

2830
import beets
2931
import beets.autotag.hooks
@@ -373,7 +375,7 @@ def __init__(self):
373375
"https": False,
374376
"ratelimit": 1,
375377
"ratelimit_interval": 1,
376-
"searchlimit": 5,
378+
"search_limit": 5,
377379
"genres": False,
378380
"external_ids": {
379381
"discogs": False,
@@ -385,6 +387,15 @@ def __init__(self):
385387
"extra_tags": [],
386388
},
387389
)
390+
# TODO: Remove in 3.0.0
391+
with suppress(NotFoundError):
392+
self.config["search_limit"] = self.config["match"][
393+
"searchlimit"
394+
].get()
395+
self._log.warning(
396+
"'musicbrainz.searchlimit' option is deprecated and will be "
397+
"removed in 3.0.0. Use 'musicbrainz.search_limit' instead."
398+
)
388399
hostname = self.config["host"].as_str()
389400
https = self.config["https"].get(bool)
390401
# Only call set_hostname when a custom server is configured. Since
@@ -801,7 +812,7 @@ def _search_api(
801812
)
802813
try:
803814
method = getattr(musicbrainzngs, f"search_{query_type}s")
804-
res = method(limit=self.config["searchlimit"].get(int), **filters)
815+
res = method(limit=self.config["search_limit"].get(int), **filters)
805816
except musicbrainzngs.MusicBrainzError as exc:
806817
raise MusicBrainzAPIError(
807818
exc, f"{query_type} search", filters, traceback.format_exc()

docs/changelog.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2546,7 +2546,7 @@ Major new features and bigger changes:
25462546
analysis tool. Thanks to :user:`jmwatte`. :bug:`1343`
25472547
- A new ``filesize`` field on items indicates the number of bytes in the file.
25482548
:bug:`1291`
2549-
- A new :ref:`searchlimit` configuration option allows you to specify how many
2549+
- A new :ref:`search_limit` configuration option allows you to specify how many
25502550
search results you wish to see when looking up releases at MusicBrainz during
25512551
import. :bug:`1245`
25522552
- The importer now records the data source for a match in a new flexible

docs/plugins/musicbrainz.rst

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ Default
2727
https: no
2828
ratelimit: 1
2929
ratelimit_interval: 1.0
30-
searchlimit: 5
30+
search_limit: 5
3131
extra_tags: []
3232
genres: no
3333
external_ids:
@@ -82,16 +82,21 @@ make the import process quicker.
8282

8383
Default: ``yes``.
8484

85-
.. _searchlimit:
85+
.. _search_limit:
8686

87-
searchlimit
88-
+++++++++++
87+
search_limit
88+
++++++++++++
8989

9090
The number of matches returned when sending search queries to the MusicBrainz
9191
server.
9292

9393
Default: ``5``.
9494

95+
searchlimit
96+
+++++++++++
97+
98+
.. deprecated:: 2.4 Use `search_limit`_.
99+
95100
.. _extra_tags:
96101

97102
extra_tags

0 commit comments

Comments
 (0)