Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Discogs Memory Error due to large albums #5550

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions beetsplug/discogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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")
Expand Down
3 changes: 3 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions docs/plugins/discogs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
---------------
Expand Down
Loading