diff --git a/beetsplug/replaygain.py b/beetsplug/replaygain.py index 3c9c0042a..e621e9b21 100644 --- a/beetsplug/replaygain.py +++ b/beetsplug/replaygain.py @@ -711,7 +711,13 @@ class AudioToolsBackend(Backend): # of the track. # Note that the method needs an audiotools.PCMReader instance that can # be obtained from an audiofile instance. - rg_track_gain, rg_track_peak = rg.title_gain(audiofile.to_pcm()) + try: + rg_track_gain, rg_track_peak = rg.title_gain(audiofile.to_pcm()) + except ValueError as exc: + # `audiotools.replaygain` can raise a `ValueError` if the sample + # rate is incorrect. + self._log.debug('error in rg.title_gain() call: {}', exc) + raise ReplayGainError('audiotools audio data error') self._log.debug(u'ReplayGain for track {0} - {1}: {2:.2f}, {3:.2f}', item.artist, item.title, rg_track_gain, rg_track_peak) diff --git a/docs/changelog.rst b/docs/changelog.rst index 5fb335a34..24b96fb56 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -39,6 +39,8 @@ Fixes: * Date fields are now written in the correct order (year-month-day), which eliminates an intermittent bug where the latter two fields would not get written to files. Thanks to :user:`jdetrey`. :bug:`1303` :bug:`1589` +* :doc:`/plugins/replaygain`: Avoid a crash when the PyAudioTools backend + encounters an error. :bug:`1592` 1.3.14 (August 2, 2015)