Merge branch '2.3.x' into devel

This commit is contained in:
Martin Konecny 2013-03-08 12:39:47 -05:00
commit 635dfd356d
4 changed files with 20 additions and 23 deletions

2
debian/control vendored
View File

@ -41,7 +41,7 @@ Depends: apache2,
pwgen,
python,
rabbitmq-server,
silan,
silan (>= 0.3.0~),
sudo,
sysv-rc,
tar (>= 1.22),

View File

@ -415,6 +415,7 @@ def file_playable(pathname):
""" Returns True if 'pathname' is playable by liquidsoap. False
otherwise. """
#currently disabled because this confuses inotify....
return True
#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

View File

@ -14,14 +14,14 @@ def get_process_output(command):
Run subprocess and return stdout
"""
logger.debug(command)
p = Popen(command, shell=True, stdout=PIPE)
p = Popen(command, stdout=PIPE, stderr=PIPE)
return p.communicate()[0].strip()
def run_process(command):
"""
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]
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.
"""
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):
"""
@ -89,41 +90,37 @@ def calculate_replay_gain(file_path):
temp_file_path = duplicate_file(file_path)
file_type = get_file_type(file_path)
nice_level = '15'
nice_level = '19'
if file_type:
if file_type == 'mp3':
if run_process("which mp3gain > /dev/null") == 0:
command = 'nice -n %s mp3gain -q "%s" 2> /dev/null' \
% (nice_level, temp_file_path)
if run_process(['which', 'mp3gain']) == 0:
command = ['nice', '-n', nice_level, 'mp3gain', '-q', temp_file_path]
out = get_process_output(command)
search = re.search(r'Recommended "Track" dB change: (.*)', \
out)
else:
logger.warn("mp3gain not found")
elif file_type == 'vorbis':
command = "which vorbisgain > /dev/null && which ogginfo > \
/dev/null"
if run_process(command) == 0:
command = 'nice -n %s vorbisgain -q -f "%s" 2>/dev/null \
>/dev/null' % (nice_level,temp_file_path)
if run_process(['which', 'ogginfo']) == 0 and \
run_process(['which', 'vorbisgain']) == 0:
command = ['nice', '-n', nice_level, 'vorbisgain', '-q', '-f', temp_file_path]
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)
else:
logger.warn("vorbisgain/ogginfo not found")
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"' \
% (nice_level, temp_file_path)
command = ['nice', '-n', nice_level, 'metaflac', \
'--add-replay-gain', temp_file_path]
run_process(command)
command = 'nice -n %s metaflac \
--show-tag=REPLAYGAIN_TRACK_GAIN "%s"' \
% (nice_level, temp_file_path)
command = ['nice', '-n', nice_level, 'metaflac', \
'--show-tag=REPLAYGAIN_TRACK_GAIN', \
temp_file_path]
out = get_process_output(command)
search = re.search(r'REPLAYGAIN_TRACK_GAIN=(.*) dB', out)
else: logger.warn("metaflac not found")

View File

@ -18,7 +18,6 @@ class SilanAnalyzer(Thread):
def start_silan(apc, logger):
me = SilanAnalyzer(apc, logger)
me.start()
me.join()
def __init__(self, apc, logger):
Thread.__init__(self)
@ -42,7 +41,7 @@ class SilanAnalyzer(Thread):
full_path = f['fp']
# silence detect(set default queue in and out)
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)
out = proc.communicate()[0].strip('\r\n')
info = json.loads(out)