Skip to content

Commit

Permalink
Fix #1152: mbcollection: choose release collection
Browse files Browse the repository at this point in the history
  • Loading branch information
sampsyo committed Dec 21, 2014
1 parent 807ff34 commit 02e341c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
14 changes: 11 additions & 3 deletions beetsplug/mbcollection.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -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 = []
Expand Down
2 changes: 2 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand Down

0 comments on commit 02e341c

Please sign in to comment.