diff --git a/beetsplug/play.py b/beetsplug/play.py index 9e912dbce..8477acbfc 100644 --- a/beetsplug/play.py +++ b/beetsplug/play.py @@ -81,6 +81,11 @@ class PlayPlugin(BeetsPlugin): action='store', help=u'add additional arguments to the command', ) + play_command.parser.add_option( + u'-y', u'--yes', + action="store_true", + help=u'skip the warning threshold', + ) play_command.func = self._play_command return [play_command] @@ -125,8 +130,8 @@ class PlayPlugin(BeetsPlugin): # Check if the selection exceeds configured threshold. If True, # cancel, otherwise proceed with play command. - if not self._exceeds_threshold(selection, command_str, open_args, - item_type): + if opts.yes or not self._exceeds_threshold( + selection, command_str, open_args, item_type): play(command_str, selection, paths, open_args, self._log, item_type) diff --git a/docs/changelog.rst b/docs/changelog.rst index 18b742e98..bae5c1e49 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -49,6 +49,9 @@ New features: :bug:`2366` :bug:`2495` * Importing a release with multiple release events now selects the event based on your :ref:`preferred` countries. :bug:`2501` +* :doc:`/plugins/play`: A new ``-y`` or ``--yes`` parameter lets you skip + the warning message if you enqueue more items than the warning threshold + usually allows. Fixes: diff --git a/docs/plugins/play.rst b/docs/plugins/play.rst index 9b9110bde..3a08a4239 100644 --- a/docs/plugins/play.rst +++ b/docs/plugins/play.rst @@ -95,6 +95,10 @@ example:: indicates that you need to insert extra arguments before specifying the playlist. +The ``--yes`` (or ``-y``) flag to the ``play`` command will skip the warning +message if you choose to play more items than the **warning_threshold** +value usually allows. + Note on the Leakage of the Generated Playlists ---------------------------------------------- diff --git a/test/test_play.py b/test/test_play.py index 86fef99a9..9721143cc 100644 --- a/test/test_play.py +++ b/test/test_play.py @@ -115,6 +115,20 @@ class PlayPluginTest(unittest.TestCase, TestHelper): open_mock.assert_not_called() + def test_skip_warning_threshold_bypass(self, open_mock): + self.config['play']['warning_threshold'] = 1 + self.other_item = self.add_item(title='another NiceTitle') + + expected_playlist = u'{0}\n{1}'.format( + self.item.path.decode('utf-8'), + self.other_item.path.decode('utf-8')) + + with control_stdin("a"): + self.run_and_assert( + open_mock, + [u'-y', u'NiceTitle'], + expected_playlist=expected_playlist) + def test_command_failed(self, open_mock): open_mock.side_effect = OSError(u"some reason")