Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add BPSyncPlugin #3389

Merged
merged 18 commits into from
Oct 6, 2019
Merged

Add BPSyncPlugin #3389

merged 18 commits into from
Oct 6, 2019

Conversation

rhlahuja
Copy link
Contributor

@rhlahuja rhlahuja commented Oct 4, 2019

This is a proof-of-concept for a bpsync plugin, Beatport's equivalent of mbsync. It allows users to sync changes to Beatport metadata and "backfill" new fields recently added in #3372.

I'm considering abstracting this functionality into a SyncMetadataSourcePlugin base class (similar to MetadataSourcePlugin introduced in #3355) which can also be leveraged for Spotify/Deezer/MusicBrainz, although that requires some larger refactors of BeatportPlugin and MBSyncPlugin, perhaps better suited for a separate PR?

@sampsyo, what do you think? Is it worth putting the finishing touches on this Beatport-specific plugin, or investing time in a SyncMetadataSourcePlugin to future-proof?

This PR also closes #3387 by properly assigning genre and renaming musical_key to initial_key.

Note: I had to run

UPDATE item_attributes SET key='initial_key' WHERE key='musical_key'

on my database to avoid raising AttributeError: 'TrackInfo' object has no attribute 'musical_key' when autotag.apply_metadata(album_info, mapping) is called.

@sampsyo
Copy link
Member

sampsyo commented Oct 4, 2019

Nice!! This looks great. I do think it would be a good idea to land this self-contained version—and then consider factoring out another base class, if that makes sense, in a second pass.

@rhlahuja rhlahuja changed the title [WIP] Add BPSyncPlugin Add BPSyncPlugin Oct 4, 2019
@rhlahuja
Copy link
Contributor Author

rhlahuja commented Oct 5, 2019

@sampsyo, this is ready for a review whenever you're free!

Copy link
Member

@sampsyo sampsyo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great so far! Here are a few suggestions.

beets/library.py Outdated Show resolved Hide resolved
beets/plugins.py Show resolved Hide resolved
beets/plugins.py Outdated Show resolved Hide resolved
docs/plugins/bpsync.rst Outdated Show resolved Hide resolved
docs/plugins/bpsync.rst Show resolved Hide resolved
docs/plugins/bpsync.rst Outdated Show resolved Hide resolved
return [self.album_for_id(album_id=a['id']) for a in albums]
results = self._search_api(query_type='album', filters=query_filters)
albums = [self.album_for_id(album_id=r['id']) for r in results]
return [a for a in albums if a is not None]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This bit logic along with this early return were added to exclude "empty" (0-track) albums I encountered such as https://www.deezer.com/us/album/6979394.

Copy link
Member

@sampsyo sampsyo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome; this looks great! Thanks for all your work on both the new plugin and some refactoring.

@sampsyo sampsyo merged commit 61a56f1 into beetbox:master Oct 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Beatport plugin does not apply tags to file
2 participants