-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1779 from diego-plan9/prompthook
mbsubmit: cleanup and completion
- Loading branch information
Showing
5 changed files
with
150 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
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`_. | ||
|
||
.. _track parser: http://wiki.musicbrainz.org/History:How_To_Parse_Track_Listings | ||
|
||
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:: | ||
|
||
No matching release found for 3 tracks. | ||
For help, see: http://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 | ||
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) | ||
|
||
No matching release found for 3 tracks. | ||
For help, see: http://beets.readthedocs.org/en/latest/faq.html#nomatch | ||
[U]se as-is, as Tracks, Group albums, Skip, Enter search, enter Id, aBort, | ||
Print tracks? | ||
|
||
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 | ||
"Track Parser" button on MusicBrainz "Tracklist" tab. | ||
|
||
Configuration | ||
------------- | ||
|
||
To configure the plugin, make a ``mbsubmit:`` section in your configuration | ||
file. The following options are available: | ||
|
||
- **format**: The format used for printing the tracks, defined using the | ||
same template syntax as beets’ :doc:`path formats </reference/pathformat>`. | ||
Default: ``$track. $title - $artist ($length)``. | ||
- **threshold**: The minimum strength of the autotagger recommendation that | ||
will cause the ``Print tracks`` choice to be displayed on the prompt. | ||
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``. | ||
|
||
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 | ||
intended. In particular, setting a threshold of ``strong`` will only display | ||
the prompt if ``timid`` mode is enabled. You can find more information about | ||
how the recommendation system works at :ref:`match-config`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
# -*- coding: utf-8 -*- | ||
# This file is part of beets. | ||
# Copyright 2016, Adrian Sampson and Diego Moreda. | ||
# | ||
# Permission is hereby granted, free of charge, to any person obtaining | ||
# a copy of this software and associated documentation files (the | ||
# "Software"), to deal in the Software without restriction, including | ||
# without limitation the rights to use, copy, modify, merge, publish, | ||
# distribute, sublicense, and/or sell copies of the Software, and to | ||
# permit persons to whom the Software is furnished to do so, subject to | ||
# the following conditions: | ||
# | ||
# The above copyright notice and this permission notice shall be | ||
# included in all copies or substantial portions of the Software. | ||
|
||
from __future__ import (division, absolute_import, print_function, | ||
unicode_literals) | ||
|
||
from test._common import unittest | ||
from test.helper import capture_stdout, control_stdin, TestHelper | ||
from test.test_importer import ImportHelper, AutotagStub | ||
from test.test_ui_importer import TerminalImportSessionSetup | ||
|
||
|
||
class MBSubmitPluginTest(TerminalImportSessionSetup, unittest.TestCase, | ||
ImportHelper, TestHelper): | ||
def setUp(self): | ||
self.setup_beets() | ||
self.load_plugins('mbsubmit') | ||
self._create_import_dir(2) | ||
self._setup_import_session() | ||
self.matcher = AutotagStub().install() | ||
|
||
def tearDown(self): | ||
self.unload_plugins() | ||
self.teardown_beets() | ||
|
||
def test_print_tracks_output(self): | ||
"""Test the output of the "print tracks" choice.""" | ||
self.matcher.matching = AutotagStub.BAD | ||
|
||
with capture_stdout() as output: | ||
with control_stdin('\n'.join(['p', 's'])): | ||
# Print tracks; Skip | ||
self.importer.run() | ||
|
||
# Manually build the string for comparing the output. | ||
tracklist = ('Print tracks? ' | ||
'01. Tag Title 1 - Tag Artist (0:01)\n' | ||
'02. Tag Title 2 - Tag Artist (0:01)') | ||
self.assertIn(tracklist, output.getvalue()) | ||
|
||
def test_print_tracks_output_as_tracks(self): | ||
"""Test the output of the "print tracks" choice, as singletons.""" | ||
self.matcher.matching = AutotagStub.BAD | ||
|
||
with capture_stdout() as output: | ||
with control_stdin('\n'.join(['t', 's', 'p', 's'])): | ||
# as Tracks; Skip; Print tracks; Skip | ||
self.importer.run() | ||
|
||
# Manually build the string for comparing the output. | ||
tracklist = ('Print tracks? ' | ||
'02. Tag Title 2 - Tag Artist (0:01)') | ||
self.assertIn(tracklist, output.getvalue()) | ||
|
||
|
||
def suite(): | ||
return unittest.TestLoader().loadTestsFromName(__name__) | ||
|
||
if __name__ == b'__main__': | ||
unittest.main(defaultTest='suite') |