mirror of
https://github.com/beetbox/beets.git
synced 2025-12-24 01:25:47 +01:00
Add configurable search_limit to Spotify and Deezer plugins
This commit is contained in:
parent
b1c93552a3
commit
d00d51e0bf
5 changed files with 16 additions and 3 deletions
|
|
@ -49,6 +49,10 @@ class DeezerPlugin(SearchApiMetadataSourcePlugin[IDResponse]):
|
|||
album_url = "https://api.deezer.com/album/"
|
||||
track_url = "https://api.deezer.com/track/"
|
||||
|
||||
def __init__(self) -> None:
|
||||
super().__init__()
|
||||
self.config.add({"search_limit": 5})
|
||||
|
||||
def commands(self):
|
||||
"""Add beet UI commands to interact with Deezer."""
|
||||
deezer_update_cmd = ui.Subcommand(
|
||||
|
|
@ -263,7 +267,7 @@ class DeezerPlugin(SearchApiMetadataSourcePlugin[IDResponse]):
|
|||
self,
|
||||
query,
|
||||
)
|
||||
return response_data
|
||||
return response_data[: self.config["search_limit"].get()]
|
||||
|
||||
def deezerupdate(self, items: Sequence[Item], write: bool):
|
||||
"""Obtain rank information from Deezer."""
|
||||
|
|
|
|||
|
|
@ -138,6 +138,7 @@ class SpotifyPlugin(
|
|||
"client_id": "4e414367a1d14c75a5c5129a627fcab8",
|
||||
"client_secret": "f82bdc09b2254f1a8286815d02fd46dc",
|
||||
"tokenfile": "spotify_token.json",
|
||||
"search_limit": 5,
|
||||
}
|
||||
)
|
||||
self.config["client_id"].redact = True
|
||||
|
|
@ -454,7 +455,7 @@ class SpotifyPlugin(
|
|||
self,
|
||||
query,
|
||||
)
|
||||
return response_data
|
||||
return response_data[: self.config["search_limit"].get()]
|
||||
|
||||
def commands(self) -> list[ui.Subcommand]:
|
||||
# autotagger import command
|
||||
|
|
|
|||
|
|
@ -32,6 +32,8 @@ New features:
|
|||
``played_ratio_threshold``, to allow configuring the percentage the song must
|
||||
be played for it to be counted as played instead of skipped.
|
||||
- :doc:`plugins/web`: Display artist and album as part of the search results.
|
||||
- :doc:`plugins/spotify` :doc:`plugins/deezer`: Add new configuration option
|
||||
``search_limit`` to limit the number of results returned by search queries.
|
||||
|
||||
Bug fixes:
|
||||
|
||||
|
|
|
|||
|
|
@ -27,7 +27,11 @@ Configuration
|
|||
-------------
|
||||
|
||||
This plugin can be configured like other metadata source plugins as described in
|
||||
:ref:`metadata-source-plugin-configuration`.
|
||||
:ref:`metadata-source-plugin-configuration`. In addition, the following
|
||||
configuration options are provided.
|
||||
|
||||
- **search_limit**: The maximum number of results to return from Deezer for each
|
||||
search query. Default: ``5``.
|
||||
|
||||
The default options should work as-is, but there are some options you can put in
|
||||
config.yaml under the ``deezer:`` section:
|
||||
|
|
|
|||
|
|
@ -98,6 +98,8 @@ config.yaml under the ``spotify:`` section:
|
|||
enhance search results in some cases, but in general, it is not recommended.
|
||||
For instance ``artist:deadmau5 album:4×4`` will be converted to
|
||||
``artist:deadmau5 album:4x4`` (notice ``×!=x``). Default: ``no``.
|
||||
- **search_limit**: The maximum number of results to return from Spotify for
|
||||
each search query. Default: ``5``.
|
||||
|
||||
Here's an example:
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue