From 5bc8ef700910aa84753a0a1fdc87f88bb938a945 Mon Sep 17 00:00:00 2001 From: jean-marie winters Date: Mon, 2 Mar 2015 22:11:33 +0100 Subject: [PATCH] fix some formating --- beetsplug/replaygain.py | 19 ++++++++----------- docs/plugins/replaygain.rst | 8 ++++---- 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/beetsplug/replaygain.py b/beetsplug/replaygain.py index c52cbe053..a13b58985 100644 --- a/beetsplug/replaygain.py +++ b/beetsplug/replaygain.py @@ -88,12 +88,14 @@ class Backend(object): raise NotImplementedError() - # bsg1770gain backend - - class Bs1770gainBackend(Backend): + """bs1770gain is a loudness scanner compliant with ITU-R BS.1770 and its + flavors EBU R128,ATSC A/85 and Replaygain 2.0. It uses a special + designed algorithm to normalize audio to the same level. + """ + def __init__(self, config, log): super(Bs1770gainBackend, self).__init__(config, log) cmd = 'bs1770gain' @@ -107,19 +109,17 @@ class Bs1770gainBackend(Backend): call([cmd, self.method]) self.command = cmd except OSError: - pass + pass if not self.command: raise FatalReplayGainError( 'no replaygain command found: install bs1770gain' ) - def compute_track_gain(self, items): """Computes the track gain of the given tracks, returns a list of TrackGain objects. """ - output = self.compute_gain(items, False) return output @@ -135,8 +135,6 @@ class Bs1770gainBackend(Backend): return AlbumGain(output[-1], output[:-1]) - - def compute_gain(self, items, is_album): """Computes the track or album gain of a list of items, returns a list of TrackGain objects. @@ -147,7 +145,6 @@ class Bs1770gainBackend(Backend): if len(items) == 0: return [] - """Compute ReplayGain values and return a list of results dictionaries as given by `parse_tool_output`. """ @@ -171,7 +168,7 @@ class Bs1770gainBackend(Backend): containing information about each analyzed file. """ out = [] - data = unicode(text, errors='ignore') + data = text.decode('utf8', errors='ignore') regex = ("(\s{2,2}\[\d+\/\d+\].*?|\[ALBUM\].*?)(?=\s{2,2}\[\d+\/\d+\]" "|\s{2,2}\[ALBUM\]:|done\.$)") @@ -179,7 +176,7 @@ class Bs1770gainBackend(Backend): for ll in results[0:num_lines]: parts = ll.split(b'\n') if len(parts) == 0: - self._log.debug(u'bad tool output: {0}', text) + self._log.debug(u'bad tool output: {0!r}', text) raise ReplayGainError('bs1770gain failed') d = { diff --git a/docs/plugins/replaygain.rst b/docs/plugins/replaygain.rst index 8c0bf610d..f08a23953 100644 --- a/docs/plugins/replaygain.rst +++ b/docs/plugins/replaygain.rst @@ -118,11 +118,11 @@ These options only work with the "command" backend: This option only works with the "bs1770gain" backend: -- **method**:either replaygain, ebu or atsc. Default: replaygain +- **method**: The loudness scanning standard: either 'replaygain' for ReplayGain 2.0, + 'ebu' for EBU R128 or 'atsc' for ATSC A/85. + This dictates the reference level: -18, -23, or -24 LUFS respectively. Default: replaygain + - replaygain measures loudness with a reference level of -18 LUFS. - ebu measures loudness with a reference level of -23 LUFS. - atsc measures loudness with a reference level of -24 LUFS. Manual Analysis