def locate_mp3_transcoder():
 transcoders = [u'ffmpeg', u'avconv']
 transcoder_details = {}
 for transcoder in transcoders:
  cmd_path = spawn.find_executable(transcoder)
  if (cmd_path is None):
   transcoder_details[transcoder] = u'not installed'
   continue
  with open(os.devnull, u'w') as null:
   stdout = subprocess.check_output([cmd_path, u'-codecs'], stderr=null).decode(u'ascii')
  mp3_encoding_support = ((u'libmp3lame' in stdout) and (u'disable-libmp3lame' not in stdout))
  if mp3_encoding_support:
   transcoder_details[transcoder] = u'mp3 encoding support'
   break
  else:
   transcoder_details[transcoder] = u'no mp3 encoding support'
 else:
  raise ValueError((u'ffmpeg or avconv must be in the path and support mp3 encoding\ndetails: %r' % transcoder_details))
 return cmd_path

def locate_mp3_transcoder ( ) : transcoders = [ u'ffmpeg' , u'avconv' ] transcoder_details = { } for transcoder in transcoders : cmd_path = spawn . find_executable ( transcoder ) if ( cmd_path is None ) : transcoder_details [ transcoder ] = u'not installed' continue with open ( os . devnull , u'w' ) as null : stdout = subprocess . check_output ( [ cmd_path , u'-codecs' ] , stderr = null ) . decode ( u'ascii' ) mp3_encoding_support = ( ( u'libmp3lame' in stdout ) and ( u'disable-libmp3lame' not in stdout ) ) if mp3_encoding_support : transcoder_details [ transcoder ] = u'mp3 encoding support' break else : transcoder_details [ transcoder ] = u'no mp3 encoding support' else : raise ValueError ( ( u'ffmpeg or avconv must be in the path and support mp3 encoding\ndetails: %r' % transcoder_details ) ) return cmd_path
return the path to a transcoder with mp3 support .