mirror of
https://github.com/beetbox/beets.git
synced 2025-12-06 16:42:42 +01:00
Fixed issues where empty strings would break the search api of various
metadata plugins.
This commit is contained in:
parent
a27cf64d4f
commit
e5d5ce1c77
5 changed files with 54 additions and 5 deletions
|
|
@ -457,6 +457,16 @@ class BeatportPlugin(MetadataSourcePlugin):
|
||||||
# Strip medium information from query, Things like "CD1" and "disk 1"
|
# Strip medium information from query, Things like "CD1" and "disk 1"
|
||||||
# can also negate an otherwise positive result.
|
# can also negate an otherwise positive result.
|
||||||
query = re.sub(r"\b(CD|disc)\s*\d+", "", query, flags=re.I)
|
query = re.sub(r"\b(CD|disc)\s*\d+", "", query, flags=re.I)
|
||||||
|
|
||||||
|
# query may be empty strings
|
||||||
|
# We want to skip the lookup in this case.
|
||||||
|
if not query.strip():
|
||||||
|
self._log.debug(
|
||||||
|
"Empty search query after preprocessing, skipping {.data_source}.",
|
||||||
|
self,
|
||||||
|
)
|
||||||
|
return
|
||||||
|
|
||||||
for beatport_release in self.client.search(query, "release"):
|
for beatport_release in self.client.search(query, "release"):
|
||||||
if beatport_release is None:
|
if beatport_release is None:
|
||||||
continue
|
continue
|
||||||
|
|
@ -522,8 +532,18 @@ class BeatportPlugin(MetadataSourcePlugin):
|
||||||
"""
|
"""
|
||||||
return self.get_artist(artists=artists, id_key=0, name_key=1)
|
return self.get_artist(artists=artists, id_key=0, name_key=1)
|
||||||
|
|
||||||
def _get_tracks(self, query):
|
def _get_tracks(self, query: str):
|
||||||
"""Returns a list of TrackInfo objects for a Beatport query."""
|
"""Returns a list of TrackInfo objects for a Beatport query."""
|
||||||
|
|
||||||
|
# query may be empty strings
|
||||||
|
# We want to skip the lookup in this case.
|
||||||
|
if not query.strip():
|
||||||
|
self._log.debug(
|
||||||
|
"Empty search query after preprocessing, skipping {.data_source}.",
|
||||||
|
self,
|
||||||
|
)
|
||||||
|
return []
|
||||||
|
|
||||||
bp_tracks = self.client.search(query, release_type="track")
|
bp_tracks = self.client.search(query, release_type="track")
|
||||||
tracks = [self._get_track_info(x) for x in bp_tracks]
|
tracks = [self._get_track_info(x) for x in bp_tracks]
|
||||||
return tracks
|
return tracks
|
||||||
|
|
|
||||||
|
|
@ -231,7 +231,10 @@ class DiscogsPlugin(MetadataSourcePlugin):
|
||||||
return track_info
|
return track_info
|
||||||
|
|
||||||
def item_candidates(
|
def item_candidates(
|
||||||
self, item: Item, artist: str, title: str
|
self,
|
||||||
|
item: Item,
|
||||||
|
artist: str,
|
||||||
|
title: str,
|
||||||
) -> Iterable[TrackInfo]:
|
) -> Iterable[TrackInfo]:
|
||||||
albums = self.candidates([item], artist, title, False)
|
albums = self.candidates([item], artist, title, False)
|
||||||
|
|
||||||
|
|
@ -291,6 +294,15 @@ class DiscogsPlugin(MetadataSourcePlugin):
|
||||||
# can also negate an otherwise positive result.
|
# can also negate an otherwise positive result.
|
||||||
query = re.sub(r"(?i)\b(CD|disc|vinyl)\s*\d+", "", query)
|
query = re.sub(r"(?i)\b(CD|disc|vinyl)\s*\d+", "", query)
|
||||||
|
|
||||||
|
# query may be empty strings
|
||||||
|
# We want to skip the lookup in this case.
|
||||||
|
if not query.strip():
|
||||||
|
self._log.debug(
|
||||||
|
"Empty search query after preprocessing, skipping {.data_source}.",
|
||||||
|
self,
|
||||||
|
)
|
||||||
|
return []
|
||||||
|
|
||||||
try:
|
try:
|
||||||
results = self.discogs_client.search(query, type="release")
|
results = self.discogs_client.search(query, type="release")
|
||||||
results.per_page = self.config["search_limit"].get()
|
results.per_page = self.config["search_limit"].get()
|
||||||
|
|
|
||||||
|
|
@ -807,6 +807,11 @@ class MusicBrainzPlugin(MetadataSourcePlugin):
|
||||||
self._log.debug(
|
self._log.debug(
|
||||||
"Searching for MusicBrainz {}s with: {!r}", query_type, filters
|
"Searching for MusicBrainz {}s with: {!r}", query_type, filters
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if not filters:
|
||||||
|
self._log.debug("No valid filters provided, skipping search.")
|
||||||
|
return []
|
||||||
|
|
||||||
try:
|
try:
|
||||||
method = getattr(musicbrainzngs, f"search_{query_type}s")
|
method = getattr(musicbrainzngs, f"search_{query_type}s")
|
||||||
res = method(limit=self.config["search_limit"].get(), **filters)
|
res = method(limit=self.config["search_limit"].get(), **filters)
|
||||||
|
|
|
||||||
|
|
@ -434,6 +434,13 @@ class SpotifyPlugin(
|
||||||
filters=filters, query_string=query_string
|
filters=filters, query_string=query_string
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if not query.strip():
|
||||||
|
self._log.debug(
|
||||||
|
"Empty search query after applying filters, skipping {.data_source}.",
|
||||||
|
self,
|
||||||
|
)
|
||||||
|
return []
|
||||||
|
|
||||||
self._log.debug("Searching {.data_source} for '{}'", self, query)
|
self._log.debug("Searching {.data_source} for '{}'", self, query)
|
||||||
try:
|
try:
|
||||||
response = self._handle_response(
|
response = self._handle_response(
|
||||||
|
|
|
||||||
|
|
@ -15,13 +15,18 @@ New features:
|
||||||
|
|
||||||
Bug fixes:
|
Bug fixes:
|
||||||
|
|
||||||
|
- :doc:`plugins/discogs`, :doc:`plugins/beatport`, :doc:`plugins/spotify`,
|
||||||
|
:doc:`plugins/musicbrainz`: Fix an issue where no metadata in a file would
|
||||||
|
crash the import process :bug:`6060`
|
||||||
|
|
||||||
For packagers:
|
For packagers:
|
||||||
|
|
||||||
Other changes:
|
Other changes:
|
||||||
|
|
||||||
- Standardized ``search_*`` parameter handling in autotag matchers. Manual album and
|
- Standardized ``search_*`` parameter handling in autotag matchers. Manual album
|
||||||
singleton searches now behave consistently: when the prompt does not specify a
|
and singleton searches now behave consistently: when the prompt does not
|
||||||
search query, the system defaults to using the corresponding metadata value.
|
specify a search query, the system defaults to using the corresponding
|
||||||
|
metadata value.
|
||||||
|
|
||||||
2.5.1 (October 14, 2025)
|
2.5.1 (October 14, 2025)
|
||||||
------------------------
|
------------------------
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue