Skip to content

Commit

Permalink
Merge pull request #4456 from arsaboo/mbsubmit
Browse files Browse the repository at this point in the history
Extend mbsubmit plugin to run after initial import
  • Loading branch information
sampsyo authored Aug 27, 2022
2 parents 010bacd + b65bdd7 commit 50bd693
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 2 deletions.
20 changes: 20 additions & 0 deletions beetsplug/mbsubmit.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,11 @@
"""


from beets import ui
from beets.autotag import Recommendation
from beets.plugins import BeetsPlugin
from beets.ui.commands import PromptChoice

from beetsplug.info import print_data


Expand Down Expand Up @@ -55,3 +57,21 @@ def before_choose_candidate_event(self, session, task):
def print_tracks(self, session, task):
for i in sorted(task.items, key=lambda i: i.track):
print_data(None, i, self.config['format'].as_str())

def commands(self):
"""Add beet UI commands for mbsubmit."""
mbsubmit_cmd = ui.Subcommand(
'mbsubmit', help='Submit Tracks to MusicBrainz')

def func(lib, opts, args):
items = lib.items(ui.decargs(args))
self._mbsubmit(items)

mbsubmit_cmd.func = func

return [mbsubmit_cmd]

def _mbsubmit(self, items):
"""Print track information to be submitted to MusicBrainz."""
for i in sorted(items, key=lambda i: i.track):
print_data(None, i, self.config['format'].as_str())
2 changes: 2 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ Changelog goes here!

New features:

* :doc:`/plugins/mbsubmit`: Added a new `mbsubmit` command to print track information to be submitted to MusicBrainz after initial import.
:bug:`4455`
* Added `spotify_updated` field to track when the information was last updated.
* We now import and tag the `album` information when importing singletons using Spotify source.
:bug:`4398`
Expand Down
11 changes: 9 additions & 2 deletions docs/plugins/mbsubmit.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ MusicBrainz Submit Plugin
=========================

The ``mbsubmit`` plugin provides an extra prompt choice during an import
session that prints the tracks of the current album in a format that is
parseable by MusicBrainz's `track parser`_.
session and a ``mbsubmit`` command that prints the tracks of the current
album in a format that is parseable by MusicBrainz's `track parser`_.

.. _track parser: https://wiki.musicbrainz.org/History:How_To_Parse_Track_Listings

Expand All @@ -27,6 +27,13 @@ strong recommendations are found for the album::
[U]se as-is, as Tracks, Group albums, Skip, Enter search, enter Id, aBort,
Print tracks?

You can also run ``beet mbsubmit QUERY`` to print the track information for any album::

$ beet mbsubmit album:"An Obscure Album"
01. An Obscure Track - An Obscure Artist (3:37)
02. Another Obscure Track - An Obscure Artist (2:05)
03. The Third Track - Another Obscure Artist (3:02)

As MusicBrainz currently does not support submitting albums programmatically,
the recommended workflow is to copy the output of the ``Print tracks`` choice
and paste it into the parser that can be found by clicking on the
Expand Down

0 comments on commit 50bd693

Please sign in to comment.