-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
mbsubmit: cleanup and completion #1779
Merged
Merged
Changes from 6 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
8746869
mbsubmit: cleanup, revise logic, config options
diego-plan9 966746f
mbsubmit: add basic tests
diego-plan9 798dd72
mbsubmit: style fixes
diego-plan9 418ad58
Merge remote-tracking branch 'upstream/master' into prompthook
diego-plan9 85ad17d
mbsubmit: add documentation, changelog
diego-plan9 53ecec1
mbsubmit: bump copyright year
diego-plan9 9bba782
mbsubmit: final style fixes (closes #1779)
diego-plan9 75636a2
Merge branch 'master' of github.com:sampsyo/beets into prompthook
diego-plan9 File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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: | ||
|
||
- **mb_format**: The format used for printing the tracks, defined using the | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe just |
||
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 on :ref:`match-config`. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "on" -> "at" or "in" |
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') |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any particular reason for the extra backticks here? It seems like quotes might be enough. (This is officially the tiniest style issue ever!)