diff --git a/beetsplug/discogs.py b/beetsplug/discogs.py index 0dc8e8a175..37d5b9c56e 100644 --- a/beetsplug/discogs.py +++ b/beetsplug/discogs.py @@ -75,6 +75,7 @@ def __init__(self): "separator": ", ", "index_tracks": False, "append_style_genre": False, + "max_track_count": 100, # Add a configuration option } ) self.config["apikey"].redact = True @@ -416,6 +417,16 @@ def get_album_info(self, result): # each make an API call just to get the same data back. tracks = self.get_tracks(result.data["tracklist"]) + # Check if the release has too many tracks + max_track_count = self.config["max_track_count"].get(int) + if len(tracks) > max_track_count: + self._log.warning( + "Skipping release with too many tracks: {0} (track count: {1})", + result.data["title"], + len(tracks), + ) + return None + # Extract information for the optional AlbumInfo fields, if possible. va = result.data["artists"][0].get("name", "").lower() == "various" year = result.data.get("year") diff --git a/docs/changelog.rst b/docs/changelog.rst index 9fb3b9e3ff..40e734ea3b 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -13,6 +13,9 @@ New features: Bug fixes: +* :doc:`plugins/discogs`: Add ``max_track_count`` configuration option to limit + the maximum number of tracks that can be imported in a single album. + :bug:`5207` * :doc:`plugins/lyrics`: LRCLib will fallback to plain lyrics if synced lyrics are not found and `synced` flag is set to `yes`. * Synchronise files included in the source distribution with what we used to diff --git a/docs/plugins/discogs.rst b/docs/plugins/discogs.rst index ac67f2d0ad..bd40b9658e 100644 --- a/docs/plugins/discogs.rst +++ b/docs/plugins/discogs.rst @@ -107,6 +107,9 @@ Other configurations available under ``discogs:`` are: - **separator**: How to join multiple genre and style values from Discogs into a string. Default: ``", "`` +- **max_track_count**: Limits the number of tracks fetched from Discogs. This can be useful if you want to avoid fetching large releases. + Default: ``100`` + Troubleshooting ---------------