From 2038a40fa2a8013d34166f3670ccc0b57732990a Mon Sep 17 00:00:00 2001 From: Jack Wilsdon Date: Thu, 5 May 2016 11:27:28 +0100 Subject: [PATCH 1/6] Add write option to bpm plugin Add write option to bpm plugin and tidy up command function. --- beetsplug/bpm.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/beetsplug/bpm.py b/beetsplug/bpm.py index ba284c042..4e7b202ac 100644 --- a/beetsplug/bpm.py +++ b/beetsplug/bpm.py @@ -54,6 +54,7 @@ class BPMPlugin(BeetsPlugin): self.config.add({ u'max_strokes': 3, u'overwrite': True, + u'write': False }) def commands(self): @@ -64,7 +65,9 @@ class BPMPlugin(BeetsPlugin): return [cmd] def command(self, lib, opts, args): - self.get_bpm(lib.items(ui.decargs(args))) + items = lib.items(ui.decargs(args)) + write = self.config['write'].get(bool) + self.get_bpm(items, write) def get_bpm(self, items, write=False): overwrite = self.config['overwrite'].get(bool) From df7b1b95519f2388966dc7c52e79743a963b4a64 Mon Sep 17 00:00:00 2001 From: Jack Wilsdon Date: Thu, 5 May 2016 11:40:42 +0100 Subject: [PATCH 2/6] Add changelog entry --- docs/changelog.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/changelog.rst b/docs/changelog.rst index 99ebc39f5..08d586263 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -22,6 +22,8 @@ New features: source in a flexible field; for a usecase see the documentation. * :doc:`/plugins/export`: A new plugin to export the data from queries to a json format. Thanks to :user:`GuilhermeHideki`. +* :doc:`/plugins/bpm`: Add ``write`` option to write tracks after updating + their BPM. * :doc:`/reference/pathformat`: new functions: %first{} and %ifdef{} * :doc:`/reference/config`: option ``terminal_encoding`` now works for some inputs From 6935b6deff1a1f141f9767d62daa765c8d6e7fb5 Mon Sep 17 00:00:00 2001 From: Jack Wilsdon Date: Thu, 5 May 2016 11:41:18 +0100 Subject: [PATCH 3/6] Add configuration documentation for bpm plugin --- docs/plugins/bpm.rst | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/docs/plugins/bpm.rst b/docs/plugins/bpm.rst index ce1f62298..f622ebc8d 100644 --- a/docs/plugins/bpm.rst +++ b/docs/plugins/bpm.rst @@ -22,6 +22,20 @@ for instance, with ``mpc`` you can do something like:: beet bpm $(mpc |head -1|tr -d "-") +Configuration +------------- + +To configure the plugin, make a ``bpm:`` section in your configuration file. +The available options are: + +- **max_strokes**: The maximum number of strokes to accept when tapping out the + BPM. + Default: 3. +- **overwrite**: Overwrite the track's existing BPM. + Default: ``yes``. +- **write**: Write the song's tags to file when the BPM is updated. + Default: ``no``. + Credit ------ From 2d5c68cec90a751f3c252380f2597731b63fd80f Mon Sep 17 00:00:00 2001 From: Jack Wilsdon Date: Fri, 6 May 2016 17:50:27 +0100 Subject: [PATCH 4/6] Remove write option from bpm and use import.write --- beetsplug/bpm.py | 5 ++--- docs/plugins/bpm.rst | 5 +++-- docs/reference/config.rst | 2 ++ 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/beetsplug/bpm.py b/beetsplug/bpm.py index 4e7b202ac..9166082e3 100644 --- a/beetsplug/bpm.py +++ b/beetsplug/bpm.py @@ -53,8 +53,7 @@ class BPMPlugin(BeetsPlugin): super(BPMPlugin, self).__init__() self.config.add({ u'max_strokes': 3, - u'overwrite': True, - u'write': False + u'overwrite': True }) def commands(self): @@ -66,7 +65,7 @@ class BPMPlugin(BeetsPlugin): def command(self, lib, opts, args): items = lib.items(ui.decargs(args)) - write = self.config['write'].get(bool) + write = ui.should_write() self.get_bpm(items, write) def get_bpm(self, items, write=False): diff --git a/docs/plugins/bpm.rst b/docs/plugins/bpm.rst index f622ebc8d..012c3903c 100644 --- a/docs/plugins/bpm.rst +++ b/docs/plugins/bpm.rst @@ -22,6 +22,9 @@ for instance, with ``mpc`` you can do something like:: beet bpm $(mpc |head -1|tr -d "-") +If :ref:`import.write ` is ``yes``, the song's tags are +written to disk. + Configuration ------------- @@ -33,8 +36,6 @@ The available options are: Default: 3. - **overwrite**: Overwrite the track's existing BPM. Default: ``yes``. -- **write**: Write the song's tags to file when the BPM is updated. - Default: ``no``. Credit ------ diff --git a/docs/reference/config.rst b/docs/reference/config.rst index b074edf5c..827b6855a 100644 --- a/docs/reference/config.rst +++ b/docs/reference/config.rst @@ -373,6 +373,8 @@ file that looks like this:: These options are available in this section: +.. _config-import-write: + write ~~~~~ From fcce9c02ac6f3ada1fa6e8579884a64b95dba039 Mon Sep 17 00:00:00 2001 From: Jack Wilsdon Date: Fri, 6 May 2016 17:51:21 +0100 Subject: [PATCH 5/6] Revert removal of trailing comma --- beetsplug/bpm.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/beetsplug/bpm.py b/beetsplug/bpm.py index 9166082e3..542a2b616 100644 --- a/beetsplug/bpm.py +++ b/beetsplug/bpm.py @@ -53,7 +53,7 @@ class BPMPlugin(BeetsPlugin): super(BPMPlugin, self).__init__() self.config.add({ u'max_strokes': 3, - u'overwrite': True + u'overwrite': True, }) def commands(self): From 9c2c331cfd630e610723f3f201c7dd0c3586b8a0 Mon Sep 17 00:00:00 2001 From: Jack Wilsdon Date: Fri, 6 May 2016 17:54:12 +0100 Subject: [PATCH 6/6] Update changelog to reflect removal of write option --- docs/changelog.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index 08d586263..6a779382a 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -22,8 +22,8 @@ New features: source in a flexible field; for a usecase see the documentation. * :doc:`/plugins/export`: A new plugin to export the data from queries to a json format. Thanks to :user:`GuilhermeHideki`. -* :doc:`/plugins/bpm`: Add ``write`` option to write tracks after updating - their BPM. +* :doc:`/plugins/bpm`: Now uses ``import.write`` option to write tracks after + updating their BPM. * :doc:`/reference/pathformat`: new functions: %first{} and %ifdef{} * :doc:`/reference/config`: option ``terminal_encoding`` now works for some inputs