mirror of
https://github.com/beetbox/beets.git
synced 2025-12-06 08:39:17 +01:00
discogs: add configurable search_limit
This commit is contained in:
parent
3a663ad52e
commit
9242db04a5
3 changed files with 21 additions and 10 deletions
|
|
@ -73,6 +73,7 @@ class DiscogsPlugin(BeetsPlugin):
|
|||
"separator": ", ",
|
||||
"index_tracks": False,
|
||||
"append_style_genre": False,
|
||||
"search_limit": 5,
|
||||
}
|
||||
)
|
||||
self.config["apikey"].redact = True
|
||||
|
|
@ -257,8 +258,8 @@ class DiscogsPlugin(BeetsPlugin):
|
|||
)
|
||||
if track_result:
|
||||
candidates.append(track_result)
|
||||
# first 10 results, don't overwhelm with options
|
||||
return candidates[:10]
|
||||
|
||||
return candidates
|
||||
|
||||
def album_for_id(self, album_id):
|
||||
"""Fetches an album by its Discogs ID and returns an AlbumInfo object
|
||||
|
|
@ -303,8 +304,9 @@ class DiscogsPlugin(BeetsPlugin):
|
|||
query = re.sub(r"(?i)\b(CD|disc|vinyl)\s*\d+", "", query)
|
||||
|
||||
try:
|
||||
releases = self.discogs_client.search(query, type="release").page(1)
|
||||
|
||||
results = self.discogs_client.search(query, type="release")
|
||||
results.per_page = self.config["search_limit"].as_number()
|
||||
releases = results.page(1)
|
||||
except CONNECTION_ERRORS:
|
||||
self._log.debug(
|
||||
"Communication error while searching for {0!r}",
|
||||
|
|
@ -312,9 +314,7 @@ class DiscogsPlugin(BeetsPlugin):
|
|||
exc_info=True,
|
||||
)
|
||||
return []
|
||||
return [
|
||||
album for album in map(self.get_album_info, releases[:5]) if album
|
||||
]
|
||||
return map(self.get_album_info, releases)
|
||||
|
||||
def get_master_year(self, master_id):
|
||||
"""Fetches a master release given its Discogs ID and returns its year
|
||||
|
|
|
|||
|
|
@ -17,6 +17,8 @@ New features:
|
|||
:bug:`4605`
|
||||
* :doc:`plugins/web`: Show notifications when a track plays. This uses the
|
||||
Media Session API to customize media notifications.
|
||||
* :doc:`plugins/discogs`: Add configurable ``search_limit`` option to
|
||||
limit the number of results returned by the Discogs metadata search queries.
|
||||
|
||||
Bug fixes:
|
||||
|
||||
|
|
|
|||
|
|
@ -101,11 +101,20 @@ This option is useful when importing classical music.
|
|||
|
||||
Other configurations available under ``discogs:`` are:
|
||||
|
||||
- **append_style_genre**: Appends the Discogs style (if found) to the genre tag. This can be useful if you want more granular genres to categorize your music.
|
||||
For example, a release in Discogs might have a genre of "Electronic" and a style of "Techno": enabling this setting would set the genre to be "Electronic, Techno" (assuming default separator of ``", "``) instead of just "Electronic".
|
||||
- **append_style_genre**: Appends the Discogs style (if found) to the genre
|
||||
tag. This can be useful if you want more granular genres to categorize your
|
||||
music. For example, a release in Discogs might have a genre of "Electronic"
|
||||
and a style of "Techno": enabling this setting would set the genre to be
|
||||
"Electronic, Techno" (assuming default separator of ``", "``) instead of just
|
||||
"Electronic".
|
||||
Default: ``False``
|
||||
- **separator**: How to join multiple genre and style values from Discogs into a string.
|
||||
- **separator**: How to join multiple genre and style values from Discogs into
|
||||
a string.
|
||||
Default: ``", "``
|
||||
- **search_limit**: The maximum number of results to return from Discogs. This is
|
||||
useful if you want to limit the number of results returned to speed up
|
||||
searches.
|
||||
Default: ``5``
|
||||
|
||||
|
||||
Troubleshooting
|
||||
|
|
|
|||
Loading…
Reference in a new issue