summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJ0J0 Todos <2733783+JOJ0@users.noreply.github.com>2023-12-06 13:08:20 +0100
committerGitHub <noreply@github.com>2023-12-06 13:08:20 +0100
commite5d10004ae08bcbbaa4ee1397a4d889e8b3b52de (patch)
treeee25c83661bc28ef5863755e1e601544527d6286
parenta384bee6bfb97c8b07fd9435a00a3641cbb21e49 (diff)
parent9357448bdeadb5f8a8a2b7a8fc55e432dd4aa906 (diff)
Merge pull request #4807 from doronbehar/mbsubmit-improvements
mbsubmit: Add picard `PromptChoice`
-rw-r--r--beetsplug/mbsubmit.py19
-rw-r--r--docs/changelog.rst1
-rw-r--r--docs/plugins/mbsubmit.rst34
-rw-r--r--test/plugins/test_mbsubmit.py6
4 files changed, 51 insertions, 9 deletions
diff --git a/beetsplug/mbsubmit.py b/beetsplug/mbsubmit.py
index e4c0f372e..d215e616c 100644
--- a/beetsplug/mbsubmit.py
+++ b/beetsplug/mbsubmit.py
@@ -21,11 +21,13 @@ implemented by MusicBrainz yet.
[1] https://wiki.musicbrainz.org/History:How_To_Parse_Track_Listings
"""
+import subprocess
from beets import ui
from beets.autotag import Recommendation
from beets.plugins import BeetsPlugin
from beets.ui.commands import PromptChoice
+from beets.util import displayable_path
from beetsplug.info import print_data
@@ -37,6 +39,7 @@ class MBSubmitPlugin(BeetsPlugin):
{
"format": "$track. $title - $artist ($length)",
"threshold": "medium",
+ "picard_path": "picard",
}
)
@@ -56,7 +59,21 @@ class MBSubmitPlugin(BeetsPlugin):
def before_choose_candidate_event(self, session, task):
if task.rec <= self.threshold:
- return [PromptChoice("p", "Print tracks", self.print_tracks)]
+ return [
+ PromptChoice("p", "Print tracks", self.print_tracks),
+ PromptChoice("o", "Open files with Picard", self.picard),
+ ]
+
+ def picard(self, session, task):
+ paths = []
+ for p in task.paths:
+ paths.append(displayable_path(p))
+ try:
+ picard_path = self.config["picard_path"].as_str()
+ subprocess.Popen([picard_path] + paths)
+ self._log.info("launched picard from\n{}", picard_path)
+ except OSError as exc:
+ self._log.error(f"Could not open picard, got error:\n{exc}")
def print_tracks(self, session, task):
for i in sorted(task.items, key=lambda i: i.track):
diff --git a/docs/changelog.rst b/docs/changelog.rst
index c69ec82f8..233423299 100644
--- a/docs/changelog.rst
+++ b/docs/changelog.rst
@@ -17,6 +17,7 @@ Major new features:
New features:
+* :doc:`plugins/mbsubmit`: add new prompt choices helping further to submit unmatched tracks to MusicBrainz faster.
* :doc:`plugins/spotify`: We now fetch track's ISRC, EAN, and UPC identifiers from Spotify when using the ``spotifysync`` command.
:bug:`4992`
* :doc:`plugins/discogs`: supply a value for the `cover_art_url` attribute, for use by `fetchart`.
diff --git a/docs/plugins/mbsubmit.rst b/docs/plugins/mbsubmit.rst
index 5cb9be8f1..0e86ddc69 100644
--- a/docs/plugins/mbsubmit.rst
+++ b/docs/plugins/mbsubmit.rst
@@ -1,23 +1,40 @@
MusicBrainz Submit Plugin
=========================
-The ``mbsubmit`` plugin provides an extra prompt choice during an import
-session and a ``mbsubmit`` command that prints the tracks of the current
-album in a format that is parseable by MusicBrainz's `track parser`_.
+The ``mbsubmit`` plugin provides extra prompt choices when an import session
+fails to find a good enough match for a release. Additionally, it provides an
+``mbsubmit`` command that prints the tracks of the current album in a format
+that is parseable by MusicBrainz's `track parser`_. The prompt choices are:
+
+- Print the tracks to stdout in a format suitable for MusicBrainz's `track
+ parser`_.
+
+- Open the program `Picard`_ with the unmatched folder as an input, allowing
+ you to start submitting the unmatched release to MusicBrainz with many input
+ fields already filled in, thanks to Picard reading the preexisting tags of
+ the files.
+
+For the last option, `Picard`_ is assumed to be installed and available on the
+machine including a ``picard`` executable. Picard developers list `download
+options`_. `other GNU/Linux distributions`_ may distribute Picard via their
+package manager as well.
.. _track parser: https://wiki.musicbrainz.org/History:How_To_Parse_Track_Listings
+.. _Picard: https://picard.musicbrainz.org/
+.. _download options: https://picard.musicbrainz.org/downloads/
+.. _other GNU/Linux distributions: https://repology.org/project/picard-tagger/versions
Usage
-----
Enable the ``mbsubmit`` plugin in your configuration (see :ref:`using-plugins`)
-and select the ``Print tracks`` choice which is by default displayed when no
-strong recommendations are found for the album::
+and select one of the options mentioned above. Here the option ``Print tracks``
+choice is demonstrated::
No matching release found for 3 tracks.
For help, see: https://beets.readthedocs.org/en/latest/faq.html#nomatch
[U]se as-is, as Tracks, Group albums, Skip, Enter search, enter Id, aBort,
- Print tracks? p
+ Print tracks, Open files with Picard? p
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)
@@ -53,6 +70,11 @@ file. The following options are available:
Default: ``medium`` (causing the choice to be displayed for all albums that
have a recommendation of medium strength or lower). Valid values: ``none``,
``low``, ``medium``, ``strong``.
+- **picard_path**: The path to the ``picard`` executable. Could be an absolute
+ path, and if not, ``$PATH`` is consulted. The default value is simply
+ ``picard``. Windows users will have to find and specify the absolute path to
+ their ``picard.exe``. That would probably be:
+ ``C:\Program Files\MusicBrainz Picard\picard.exe``.
Please note that some values of the ``threshold`` configuration option might
require other ``beets`` command line switches to be enabled in order to work as
diff --git a/test/plugins/test_mbsubmit.py b/test/plugins/test_mbsubmit.py
index 6f9c81c04..e495a73a9 100644
--- a/test/plugins/test_mbsubmit.py
+++ b/test/plugins/test_mbsubmit.py
@@ -45,7 +45,7 @@ class MBSubmitPluginTest(
# Manually build the string for comparing the output.
tracklist = (
- "Print tracks? "
+ "Open files with Picard? "
"01. Tag Title 1 - Tag Artist (0:01)\n"
"02. Tag Title 2 - Tag Artist (0:01)"
)
@@ -61,7 +61,9 @@ class MBSubmitPluginTest(
self.importer.run()
# Manually build the string for comparing the output.
- tracklist = "Print tracks? " "02. Tag Title 2 - Tag Artist (0:01)"
+ tracklist = (
+ "Open files with Picard? " "02. Tag Title 2 - Tag Artist (0:01)"
+ )
self.assertIn(tracklist, output.getvalue())