cc-4332: Added nicu before command invocation
This commit is contained in:
parent
434bcf15ab
commit
4de8d32fad
2 changed files with 10 additions and 11 deletions
|
@ -161,8 +161,7 @@ class Metadata(Loggable):
|
||||||
# Forcing the unicode through
|
# Forcing the unicode through
|
||||||
try : fpath = fpath.decode("utf-8")
|
try : fpath = fpath.decode("utf-8")
|
||||||
except : pass
|
except : pass
|
||||||
if not mmp.file_playable(fpath):
|
if not mmp.file_playable(fpath): raise BadSongFile(fpath)
|
||||||
raise BadSongFile(fpath)
|
|
||||||
try : full_mutagen = mutagen.File(fpath, easy=True)
|
try : full_mutagen = mutagen.File(fpath, easy=True)
|
||||||
except Exception : raise BadSongFile(fpath)
|
except Exception : raise BadSongFile(fpath)
|
||||||
self.path = fpath
|
self.path = fpath
|
||||||
|
|
|
@ -87,34 +87,34 @@ def calculate_replay_gain(file_path):
|
||||||
temp_file_path = duplicate_file(file_path)
|
temp_file_path = duplicate_file(file_path)
|
||||||
|
|
||||||
file_type = get_file_type(file_path)
|
file_type = get_file_type(file_path)
|
||||||
|
nice_level = '15'
|
||||||
|
|
||||||
if file_type:
|
if file_type:
|
||||||
if file_type == 'mp3':
|
if file_type == 'mp3':
|
||||||
if run_process("which mp3gain > /dev/null") == 0:
|
if run_process("which mp3gain > /dev/null") == 0:
|
||||||
out = get_process_output('mp3gain -q "%s" 2> /dev/null' % temp_file_path)
|
out = get_process_output('nice -n %s mp3gain -q "%s" 2> /dev/null' % (nice_level, temp_file_path))
|
||||||
search = re.search(r'Recommended "Track" dB change: (.*)', out)
|
search = re.search(r'Recommended "Track" dB change: (.*)', out)
|
||||||
else:
|
else:
|
||||||
logger.warn("mp3gain not found")
|
logger.warn("mp3gain not found")
|
||||||
elif file_type == 'vorbis':
|
elif file_type == 'vorbis':
|
||||||
if run_process("which vorbisgain > /dev/null && which ogginfo > /dev/null") == 0:
|
if run_process("which vorbisgain > /dev/null && which ogginfo > /dev/null") == 0:
|
||||||
run_process('vorbisgain -q -f "%s" 2>/dev/null >/dev/null' % temp_file_path)
|
run_process('nice -n %s vorbisgain -q -f "%s" 2>/dev/null >/dev/null' % (nice_level,temp_file_path))
|
||||||
out = get_process_output('ogginfo "%s"' % temp_file_path)
|
out = get_process_output('ogginfo "%s"' % temp_file_path)
|
||||||
search = re.search(r'REPLAYGAIN_TRACK_GAIN=(.*) dB', out)
|
search = re.search(r'REPLAYGAIN_TRACK_GAIN=(.*) dB', out)
|
||||||
else:
|
else:
|
||||||
logger.warn("vorbisgain/ogginfo not found")
|
logger.warn("vorbisgain/ogginfo not found")
|
||||||
elif file_type == 'flac':
|
elif file_type == 'flac':
|
||||||
if run_process("which metaflac > /dev/null") == 0:
|
if run_process("which metaflac > /dev/null") == 0:
|
||||||
out = get_process_output('metaflac --show-tag=REPLAYGAIN_TRACK_GAIN "%s"' % temp_file_path)
|
out = get_process_output('nice -n %s metaflac --show-tag=REPLAYGAIN_TRACK_GAIN "%s"' % (nice_level, temp_file_path))
|
||||||
search = re.search(r'REPLAYGAIN_TRACK_GAIN=(.*) dB', out)
|
search = re.search(r'REPLAYGAIN_TRACK_GAIN=(.*) dB', out)
|
||||||
else:
|
else: logger.warn("metaflac not found")
|
||||||
logger.warn("metaflac not found")
|
|
||||||
else:
|
|
||||||
pass
|
|
||||||
|
|
||||||
#no longer need the temp, file simply remove it.
|
|
||||||
os.remove(temp_file_path)
|
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
logger.error(str(e))
|
logger.error(str(e))
|
||||||
|
finally:
|
||||||
|
#no longer need the temp, file simply remove it.
|
||||||
|
try: os.remove(temp_file_path)
|
||||||
|
except: pass
|
||||||
|
|
||||||
replay_gain = 0
|
replay_gain = 0
|
||||||
if search:
|
if search:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue