Skip to content

Commit 3d364e4

Browse files
authored
Only consider release collections in mbcollection plugin (#5856)
Currently, `mbcollection` takes the first collection it finds (if the user does not explicitely indicates one in the configuration). The problem is that the user may have collections of types that we are not interested in (e.g. recording collections, artist collections, etc.). Since the `get_collections` response returns the collections types, we can only keep the `release` collections.
2 parents f461651 + eb497ee commit 3d364e4

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

beetsplug/mbcollection.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,14 @@ def _get_collection(self):
7070
if not collections["collection-list"]:
7171
raise ui.UserError("no collections exist for user")
7272

73-
# Get all collection IDs, avoiding event collections
74-
collection_ids = [x["id"] for x in collections["collection-list"]]
73+
# Get all release collection IDs, avoiding event collections
74+
collection_ids = [
75+
x["id"]
76+
for x in collections["collection-list"]
77+
if x["entity-type"] == "release"
78+
]
7579
if not collection_ids:
76-
raise ui.UserError("No collection found.")
80+
raise ui.UserError("No release collection found.")
7781

7882
# Check that the collection exists so we can present a nice error
7983
collection = self.config["collection"].as_str()

docs/changelog.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ New features:
2828
:bug:`5832`
2929
* :doc:`plugins/playlist`: Support files with the `.m3u8` extension.
3030
:bug:`5829`
31+
* :doc:`plugins/mbcollection`: When getting the user collections, only consider
32+
collections of releases, and ignore collections of other entity types.
3133

3234
Bug fixes:
3335

0 commit comments

Comments
 (0)