Merge branch '2.3.x' into devel
This commit is contained in:
commit
635dfd356d
|
@ -41,7 +41,7 @@ Depends: apache2,
|
||||||
pwgen,
|
pwgen,
|
||||||
python,
|
python,
|
||||||
rabbitmq-server,
|
rabbitmq-server,
|
||||||
silan,
|
silan (>= 0.3.0~),
|
||||||
sudo,
|
sudo,
|
||||||
sysv-rc,
|
sysv-rc,
|
||||||
tar (>= 1.22),
|
tar (>= 1.22),
|
||||||
|
|
|
@ -415,6 +415,7 @@ def file_playable(pathname):
|
||||||
""" Returns True if 'pathname' is playable by liquidsoap. False
|
""" Returns True if 'pathname' is playable by liquidsoap. False
|
||||||
otherwise. """
|
otherwise. """
|
||||||
|
|
||||||
|
#currently disabled because this confuses inotify....
|
||||||
return True
|
return True
|
||||||
#remove all write permissions. This is due to stupid taglib library bug
|
#remove all write permissions. This is due to stupid taglib library bug
|
||||||
#where all files are opened in write mode. The only way around this is to
|
#where all files are opened in write mode. The only way around this is to
|
||||||
|
|
|
@ -14,14 +14,14 @@ def get_process_output(command):
|
||||||
Run subprocess and return stdout
|
Run subprocess and return stdout
|
||||||
"""
|
"""
|
||||||
logger.debug(command)
|
logger.debug(command)
|
||||||
p = Popen(command, shell=True, stdout=PIPE)
|
p = Popen(command, stdout=PIPE, stderr=PIPE)
|
||||||
return p.communicate()[0].strip()
|
return p.communicate()[0].strip()
|
||||||
|
|
||||||
def run_process(command):
|
def run_process(command):
|
||||||
"""
|
"""
|
||||||
Run subprocess and return "return code"
|
Run subprocess and return "return code"
|
||||||
"""
|
"""
|
||||||
p = Popen(command, shell=True)
|
p = Popen(command, stdout=PIPE, stderr=PIPE)
|
||||||
return os.waitpid(p.pid, 0)[1]
|
return os.waitpid(p.pid, 0)[1]
|
||||||
|
|
||||||
def get_mime_type(file_path):
|
def get_mime_type(file_path):
|
||||||
|
@ -31,7 +31,8 @@ def get_mime_type(file_path):
|
||||||
for files which do not have a mp3/ogg/flac extension.
|
for files which do not have a mp3/ogg/flac extension.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
return get_process_output("timeout 5 file -b --mime-type %s" % file_path)
|
command = ['timeout', '5', 'file', '-b', '--mime-type', file_path]
|
||||||
|
return get_process_output(command)
|
||||||
|
|
||||||
def duplicate_file(file_path):
|
def duplicate_file(file_path):
|
||||||
"""
|
"""
|
||||||
|
@ -89,41 +90,37 @@ 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'
|
nice_level = '19'
|
||||||
|
|
||||||
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']) == 0:
|
||||||
command = 'nice -n %s mp3gain -q "%s" 2> /dev/null' \
|
command = ['nice', '-n', nice_level, 'mp3gain', '-q', temp_file_path]
|
||||||
% (nice_level, temp_file_path)
|
|
||||||
out = get_process_output(command)
|
out = get_process_output(command)
|
||||||
search = re.search(r'Recommended "Track" dB change: (.*)', \
|
search = re.search(r'Recommended "Track" dB change: (.*)', \
|
||||||
out)
|
out)
|
||||||
else:
|
else:
|
||||||
logger.warn("mp3gain not found")
|
logger.warn("mp3gain not found")
|
||||||
elif file_type == 'vorbis':
|
elif file_type == 'vorbis':
|
||||||
command = "which vorbisgain > /dev/null && which ogginfo > \
|
if run_process(['which', 'ogginfo']) == 0 and \
|
||||||
/dev/null"
|
run_process(['which', 'vorbisgain']) == 0:
|
||||||
if run_process(command) == 0:
|
command = ['nice', '-n', nice_level, 'vorbisgain', '-q', '-f', temp_file_path]
|
||||||
command = 'nice -n %s vorbisgain -q -f "%s" 2>/dev/null \
|
|
||||||
>/dev/null' % (nice_level,temp_file_path)
|
|
||||||
run_process(command)
|
run_process(command)
|
||||||
|
|
||||||
out = get_process_output('ogginfo "%s"' % temp_file_path)
|
out = get_process_output(['ogginfo', 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']) == 0:
|
||||||
|
|
||||||
command = 'nice -n %s metaflac --add-replay-gain "%s"' \
|
command = ['nice', '-n', nice_level, 'metaflac', \
|
||||||
% (nice_level, temp_file_path)
|
'--add-replay-gain', temp_file_path]
|
||||||
run_process(command)
|
run_process(command)
|
||||||
|
|
||||||
command = 'nice -n %s metaflac \
|
command = ['nice', '-n', nice_level, 'metaflac', \
|
||||||
--show-tag=REPLAYGAIN_TRACK_GAIN "%s"' \
|
'--show-tag=REPLAYGAIN_TRACK_GAIN', \
|
||||||
% (nice_level, temp_file_path)
|
temp_file_path]
|
||||||
|
|
||||||
out = get_process_output(command)
|
out = get_process_output(command)
|
||||||
search = re.search(r'REPLAYGAIN_TRACK_GAIN=(.*) dB', out)
|
search = re.search(r'REPLAYGAIN_TRACK_GAIN=(.*) dB', out)
|
||||||
else: logger.warn("metaflac not found")
|
else: logger.warn("metaflac not found")
|
||||||
|
|
|
@ -18,7 +18,6 @@ class SilanAnalyzer(Thread):
|
||||||
def start_silan(apc, logger):
|
def start_silan(apc, logger):
|
||||||
me = SilanAnalyzer(apc, logger)
|
me = SilanAnalyzer(apc, logger)
|
||||||
me.start()
|
me.start()
|
||||||
me.join()
|
|
||||||
|
|
||||||
def __init__(self, apc, logger):
|
def __init__(self, apc, logger):
|
||||||
Thread.__init__(self)
|
Thread.__init__(self)
|
||||||
|
@ -42,7 +41,7 @@ class SilanAnalyzer(Thread):
|
||||||
full_path = f['fp']
|
full_path = f['fp']
|
||||||
# silence detect(set default queue in and out)
|
# silence detect(set default queue in and out)
|
||||||
try:
|
try:
|
||||||
command = ['silan', '-b', '-f', 'JSON', full_path]
|
command = ['nice', '-n', '19', 'silan', '-b', '-f', 'JSON', full_path]
|
||||||
proc = subprocess.Popen(command, stdout=subprocess.PIPE)
|
proc = subprocess.Popen(command, stdout=subprocess.PIPE)
|
||||||
out = proc.communicate()[0].strip('\r\n')
|
out = proc.communicate()[0].strip('\r\n')
|
||||||
info = json.loads(out)
|
info = json.loads(out)
|
||||||
|
|
Loading…
Reference in New Issue