From 430369062bf899b8a650e0f8eace011c53c86e4a Mon Sep 17 00:00:00 2001 From: anshuman73 Date: Tue, 29 Nov 2016 00:28:38 +0530 Subject: [PATCH 1/6] Fixed a small typo --- beetsplug/mbcollection.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/beetsplug/mbcollection.py b/beetsplug/mbcollection.py index a590a7605..992c51fe3 100644 --- a/beetsplug/mbcollection.py +++ b/beetsplug/mbcollection.py @@ -80,7 +80,7 @@ class MusicBrainzCollectionPlugin(BeetsPlugin): self.update_album_list([task.album]) def update_album_list(self, album_list): - """Update the MusicBrainz colleciton from a list of Beets albums + """Update the MusicBrainz collection from a list of Beets albums """ # Get the available collections. collections = mb_call(musicbrainzngs.get_collections) From 318661b4a90ef61c328587eb8dc74f607daf5d98 Mon Sep 17 00:00:00 2001 From: anshuman73 Date: Tue, 29 Nov 2016 01:53:59 +0530 Subject: [PATCH 2/6] Added parsing of secondary album types. Fixes #2200 --- beets/autotag/mb.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/beets/autotag/mb.py b/beets/autotag/mb.py index 78d382d87..6ce75772c 100644 --- a/beets/autotag/mb.py +++ b/beets/autotag/mb.py @@ -276,11 +276,18 @@ def album_info(release): disambig.append(release.get('disambiguation')) info.albumdisambig = u', '.join(disambig) - # Release type not always populated. - if 'type' in release['release-group']: - reltype = release['release-group']['type'] - if reltype: - info.albumtype = reltype.lower() + # Considers all release types (both primary and secondary) and stores as a comma-separated string + all_types = [] + if 'primary-type' in release['release-group']: + rel_primarytype = release['release-group']['primary-type'] + if rel_primarytype: + all_types.append(rel_primarytype.lower()) + if 'secondary-type-list' in release['release-group']: + for secondarytype in release['release-group']['secondary-type-list']: + all_types.append(secondarytype.lower()) + if len(all_types) != 0: + all_types = ','.join(all_types) + info.albumtype = all_types.lower() # Release dates. release_date = release.get('date') From a9d9d83660fccce266dd439567ccce62f803104d Mon Sep 17 00:00:00 2001 From: anshuman73 Date: Tue, 29 Nov 2016 10:05:17 +0530 Subject: [PATCH 3/6] Added support for type field and made code more elegant --- beets/autotag/mb.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/beets/autotag/mb.py b/beets/autotag/mb.py index 6ce75772c..452aa7d50 100644 --- a/beets/autotag/mb.py +++ b/beets/autotag/mb.py @@ -276,18 +276,22 @@ def album_info(release): disambig.append(release.get('disambiguation')) info.albumdisambig = u', '.join(disambig) - # Considers all release types (both primary and secondary) and stores as a comma-separated string + # Considers all release types (both primary and secondary) and + # stores them as a comma-separated string all_types = [] if 'primary-type' in release['release-group']: rel_primarytype = release['release-group']['primary-type'] if rel_primarytype: all_types.append(rel_primarytype.lower()) if 'secondary-type-list' in release['release-group']: - for secondarytype in release['release-group']['secondary-type-list']: - all_types.append(secondarytype.lower()) - if len(all_types) != 0: - all_types = ','.join(all_types) - info.albumtype = all_types.lower() + all_types.extend([secondarytype.lower() for secondarytype in\ + release['release-group']['secondary-type-list']]) + if 'type' in release['release-group']: + rel_type = release['release-group']['type'] + if rel_type and rel_type.lower() not in all_types: + all_types.append(rel_type) + if len(all_types): + info.albumtype = ', '.join(all_types).lower() # Release dates. release_date = release.get('date') From 0c61e08d7fa2e98cf03bacd631fc57bd1460f0be Mon Sep 17 00:00:00 2001 From: anshuman73 Date: Wed, 30 Nov 2016 20:34:40 +0530 Subject: [PATCH 4/6] Added new Album types as logs --- beets/autotag/mb.py | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/beets/autotag/mb.py b/beets/autotag/mb.py index 452aa7d50..17cb62776 100644 --- a/beets/autotag/mb.py +++ b/beets/autotag/mb.py @@ -278,20 +278,19 @@ def album_info(release): # Considers all release types (both primary and secondary) and # stores them as a comma-separated string - all_types = [] + if 'type' in release['release-group']: + reltype = release['release-group']['type'] + if reltype: + info.albumtype = reltype.lower() if 'primary-type' in release['release-group']: rel_primarytype = release['release-group']['primary-type'] if rel_primarytype: - all_types.append(rel_primarytype.lower()) + log.debug('Primary Type (new data): ' + rel_primarytype.lower()) if 'secondary-type-list' in release['release-group']: - all_types.extend([secondarytype.lower() for secondarytype in\ - release['release-group']['secondary-type-list']]) - if 'type' in release['release-group']: - rel_type = release['release-group']['type'] - if rel_type and rel_type.lower() not in all_types: - all_types.append(rel_type) - if len(all_types): - info.albumtype = ', '.join(all_types).lower() + if release['release-group']['secondary-type-list']: + log.debug('Secondary Type(s) (new data): ' + ', '.join( + [secondarytype.lower() for secondarytype in \ + release['release-group']['secondary-type-list']])) # Release dates. release_date = release.get('date') From 1217efd2bd4a63645a605136856cee30de25bec9 Mon Sep 17 00:00:00 2001 From: anshuman73 Date: Wed, 30 Nov 2016 20:44:12 +0530 Subject: [PATCH 5/6] Changed comment to reflect current status --- beets/autotag/mb.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/beets/autotag/mb.py b/beets/autotag/mb.py index 17cb62776..0d689917e 100644 --- a/beets/autotag/mb.py +++ b/beets/autotag/mb.py @@ -276,8 +276,9 @@ def album_info(release): disambig.append(release.get('disambiguation')) info.albumdisambig = u', '.join(disambig) - # Considers all release types (both primary and secondary) and - # stores them as a comma-separated string + # Retrieves the Release type. + # Considers all other release types(including primary and secondary) (new) + # and logs them. if 'type' in release['release-group']: reltype = release['release-group']['type'] if reltype: From 082f944ac68d7b34f8ea3bcefb3a9cf5bacc15de Mon Sep 17 00:00:00 2001 From: anshuman73 Date: Thu, 1 Dec 2016 02:07:00 +0530 Subject: [PATCH 6/6] Removed redundant backslash --- beets/autotag/mb.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/beets/autotag/mb.py b/beets/autotag/mb.py index 0d689917e..ed7287860 100644 --- a/beets/autotag/mb.py +++ b/beets/autotag/mb.py @@ -290,7 +290,7 @@ def album_info(release): if 'secondary-type-list' in release['release-group']: if release['release-group']['secondary-type-list']: log.debug('Secondary Type(s) (new data): ' + ', '.join( - [secondarytype.lower() for secondarytype in \ + [secondarytype.lower() for secondarytype in release['release-group']['secondary-type-list']])) # Release dates.