replaygain: Fix TypeError if command option is not set

This commit is contained in:
Jakob Schnitzer 2012-10-15 16:01:01 +02:00
parent f2ab26d6a4
commit 4ebc5237d0

View file

@ -61,14 +61,16 @@ class ReplayGainPlugin(BeetsPlugin):
'targetlevel', DEFAULT_REFERENCE_LOUDNESS))
self.gain_offset = int(target_level-DEFAULT_REFERENCE_LOUDNESS)
self.command = ui.config_val(config,'replaygain','command', None)
if not os.path.isfile(self.command):
raise ui.UserError('no valid rgain command filepath given')
if not self.command:
if self.command:
if not os.path.isfile(self.command):
raise ui.UserError('no valid rgain command filepath given')
else:
for cmd in ['mp3gain','aacgain']:
proc = subprocess.Popen([cmd,'-v'])
retcode = proc.poll()
if not retcode:
try:
subprocess.call([cmd,'-v'], stderr=subprocess.PIPE)
self.command = cmd
except OSError:
pass
if not self.command:
raise ui.UserError('no valid rgain command found')