mirror of
https://github.com/beetbox/beets.git
synced 2025-12-24 01:25:47 +01:00
replaygain: Handle missing GStreamer data (#1855)
This commit is contained in:
parent
e3e34b13e4
commit
0aea7e398b
2 changed files with 18 additions and 5 deletions
|
|
@ -501,14 +501,25 @@ class GStreamerBackend(Backend):
|
|||
if len(self._file_tags) != len(items):
|
||||
raise ReplayGainError("Some items in album did not receive tags")
|
||||
|
||||
ret = []
|
||||
# Collect track gains.
|
||||
track_gains = []
|
||||
for item in items:
|
||||
ret.append(Gain(self._file_tags[item]["TRACK_GAIN"],
|
||||
self._file_tags[item]["TRACK_PEAK"]))
|
||||
try:
|
||||
gain = self._file_tags[item]["TRACK_GAIN"]
|
||||
peak = self._file_tags[item]["TRACK_PEAK"]
|
||||
except KeyError:
|
||||
raise ReplayGainError("results missing for track")
|
||||
track_gains.append(Gain(gain, peak))
|
||||
|
||||
# Get album gain information from the last track.
|
||||
last_tags = self._file_tags[items[-1]]
|
||||
return AlbumGain(Gain(last_tags["ALBUM_GAIN"],
|
||||
last_tags["ALBUM_PEAK"]), ret)
|
||||
try:
|
||||
gain = last_tags["ALBUM_GAIN"]
|
||||
peak = last_tags["ALBUM_PEAK"]
|
||||
except KeyError:
|
||||
raise ReplayGainError("results missing for album")
|
||||
|
||||
return AlbumGain(Gain(gain, peak), track_gains)
|
||||
|
||||
def close(self):
|
||||
self._bus.remove_signal_watch()
|
||||
|
|
|
|||
|
|
@ -53,6 +53,8 @@ Fixes:
|
|||
inaccessible. :bug:`1806`
|
||||
* :doc:`/plugins/fetchart`: Possibly fix a Unicode-related crash when using
|
||||
some versions of pyOpenSSL. :bug:`1805`
|
||||
* :doc:`/plugins/replaygain`: Fix an intermittent crash with the GStreamer
|
||||
backend. :bug:`1855`
|
||||
|
||||
.. _beets.io: http://beets.io/
|
||||
.. _Beetbox: https://github.com/beetbox
|
||||
|
|
|
|||
Loading…
Reference in a new issue