diff --git a/beetsplug/mbcollection.py b/beetsplug/mbcollection.py index c1eeb5e4d6..6104082325 100644 --- a/beetsplug/mbcollection.py +++ b/beetsplug/mbcollection.py @@ -36,7 +36,7 @@ def mb_call(func, *args, **kwargs): return func(*args, **kwargs) except musicbrainzngs.AuthenticationError: raise ui.UserError('authentication with MusicBrainz failed') - except musicbrainzngs.ResponseError as exc: + except (musicbrainzngs.ResponseError, musicbrainzngs.NetworkError) as exc: raise ui.UserError('MusicBrainz API error: {0}'.format(exc)) except musicbrainzngs.UsageError: raise ui.UserError('MusicBrainz credentials missing') @@ -57,11 +57,19 @@ def submit_albums(collection_id, release_ids): def update_album_list(album_list): """Update the MusicBrainz colleciton from a list of Beets albums """ - # Get the collection to modify. + # Get the available collections. collections = mb_call(musicbrainzngs.get_collections) if not collections['collection-list']: raise ui.UserError('no collections exist for user') - collection_id = collections['collection-list'][0]['id'] + + # Get the first release collection. MusicBrainz also has event + # collections, so we need to avoid adding to those. + for collection in collections['collection-list']: + if 'release-count' in collection: + collection_id = collection['id'] + break + else: + raise ui.UserError('No collection found.') # Get a list of all the album IDs. album_ids = [] diff --git a/docs/changelog.rst b/docs/changelog.rst index 10ab2bc67f..87487e0588 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -48,6 +48,8 @@ Fixed: * :doc:`/plugins/ftintitle` and :doc:`/plugins/lyrics`: Featuring artists can now be detected when they use the Spanish word *con*. :bug:`1060` :bug:`1143` +* :doc:`/plugins/mbcollection`: Fix an "HTTP 400" error caused by a change in + the MusicBrainz API. :bug:`1152` .. _API changes: http://developer.echonest.com/forums/thread/3650 .. _Plex: https://plex.tv/