From 2118a414354aef54a24f4607744dea1c7ae76d1f Mon Sep 17 00:00:00 2001 From: Olin Gay Date: Tue, 19 Aug 2014 21:01:18 -0400 Subject: [PATCH 1/2] Adding album artist fix --- beets/ui/commands.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/beets/ui/commands.py b/beets/ui/commands.py index a7720464e..4794ee999 100644 --- a/beets/ui/commands.py +++ b/beets/ui/commands.py @@ -1178,6 +1178,7 @@ def show_stats(lib, query, exact): total_items = 0 artists = set() albums = set() + albumartists = set() for item in items: if exact: @@ -1188,6 +1189,7 @@ def show_stats(lib, query, exact): total_items += 1 artists.add(item.artist) albums.add(item.album) + albumartists.add(item.albumartist) size_str = '' + ui.human_bytes(total_size) if exact: @@ -1197,8 +1199,9 @@ def show_stats(lib, query, exact): Total time: {1} ({2:.2f} seconds) Total size: {3} Artists: {4} -Albums: {5}""".format(total_items, ui.human_seconds(total_time), total_time, - size_str, len(artists), len(albums))) +Album Artists: {5} +Albums: {6}""".format(total_items, ui.human_seconds(total_time), total_time, + size_str, len(artists), len(albumartists), len(albums))) def stats_func(lib, opts, args): From 3b82be1a2375e3112a0ca84951f7d2517373f0ca Mon Sep 17 00:00:00 2001 From: Olin Gay Date: Wed, 27 Aug 2014 10:26:31 +0530 Subject: [PATCH 2/2] Changes for issue -- mbcollection: Automatically update collection on import #793 --- beetsplug/mbcollection.py | 23 +++++++++++++++++++++-- docs/plugins/mbcollection.rst | 14 ++++++++++++++ 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/beetsplug/mbcollection.py b/beetsplug/mbcollection.py index 1abdfec51..95c3beef3 100644 --- a/beetsplug/mbcollection.py +++ b/beetsplug/mbcollection.py @@ -54,7 +54,9 @@ def submit_albums(collection_id, release_ids): ) -def update_collection(lib, opts, args): +def update_album_list(album_list): + """Update the MusicBrainz colleciton from a list of Beets albums + """ # Get the collection to modify. collections = mb_call(musicbrainzngs.get_collections) if not collections['collection-list']: @@ -63,7 +65,7 @@ def update_collection(lib, opts, args): # Get a list of all the album IDs. album_ids = [] - for album in lib.albums(): + for album in album_list: aid = album.mb_albumid if aid: if re.match(UUID_REGEX, aid): @@ -76,6 +78,11 @@ def update_collection(lib, opts, args): submit_albums(collection_id, album_ids) print('...MusicBrainz collection updated.') + +def update_collection(lib, opts, args): + update_album_list(lib.albums()) + + update_mb_collection_cmd = Subcommand('mbupdate', help='Update MusicBrainz collection') update_mb_collection_cmd.func = update_collection @@ -88,6 +95,18 @@ class MusicBrainzCollectionPlugin(BeetsPlugin): config['musicbrainz']['user'].get(unicode), config['musicbrainz']['pass'].get(unicode), ) + self.config.add({'auto': False}) + self.automatic = self.config['auto'].get(bool) + self.import_stages = [self.imported] def commands(self): return [update_mb_collection_cmd] + + def imported(self, session, task): + """Add each added album to the musicbrainz collection + """ + if not self.automatic: + return + + if task.is_album: + update_album_list([task.album]) diff --git a/docs/plugins/mbcollection.rst b/docs/plugins/mbcollection.rst index dc59ad88c..bab73e2e8 100644 --- a/docs/plugins/mbcollection.rst +++ b/docs/plugins/mbcollection.rst @@ -18,3 +18,17 @@ Then, use the ``beet mbupdate`` command to send your albums to MusicBrainz. The command automatically adds all of your albums to the first collection it finds. If you don't have a MusicBrainz collection yet, you may need to add one to your profile first. + +Auto Update Mode +---------------- + +You can now add each imported album to your MusicBrainz collection, without +needing a separate ``beet mbupdate`` command. To do this, first enable the +plugin and add your MusicBrainz account using the instructions above. Then, +add a block for the ``mbcollection`` plugin to enable ``auto`` configuration:: + + mbcollection: + auto: yes + +During future imports, your default collection will be updated with the +imported album. \ No newline at end of file