mirror of
https://github.com/rembo10/headphones.git
synced 2026-05-16 08:35:32 +01:00
cue split config paths for shntool, flac
Allow paths to shntool and flac commands to be specified in config.ini, e.g. cue_split_shntool_path = /usr/local/bin cue_split_flac_path = /opt/local/bin
This commit is contained in:
@@ -42,6 +42,8 @@ _CONFIG_DEFINITIONS = {
|
||||
'CONFIG_VERSION': (str, 'General', '0'),
|
||||
'CORRECT_METADATA': (int, 'General', 0),
|
||||
'CUE_SPLIT': (int, 'General', 1),
|
||||
'CUE_SPLIT_FLAC_PATH': (str, 'General', ''),
|
||||
'CUE_SPLIT_SHNTOOL_PATH': (str, 'General', ''),
|
||||
'CUSTOMHOST': (str, 'General', 'localhost'),
|
||||
'CUSTOMPORT': (int, 'General', 5000),
|
||||
'CUSTOMSLEEP': (int, 'General', 1),
|
||||
|
||||
@@ -72,11 +72,13 @@ CUE_META = None
|
||||
|
||||
|
||||
def check_splitter(command):
|
||||
'''Check xld or shntools installed'''
|
||||
'''Check xld or shntool installed'''
|
||||
try:
|
||||
env = os.environ.copy()
|
||||
if 'xld' in command:
|
||||
env['PATH'] += os.pathsep + '/Applications'
|
||||
elif headphones.CONFIG.CUE_SPLIT_FLAC_PATH:
|
||||
command = os.path.join(headphones.CONFIG.CUE_SPLIT_SHNTOOL_PATH, 'shntool')
|
||||
devnull = open(os.devnull)
|
||||
subprocess.Popen([command], stdout=devnull, stderr=devnull, env=env).communicate()
|
||||
except OSError as e:
|
||||
@@ -103,6 +105,8 @@ def split_baby(split_file, split_cmd):
|
||||
env = os.environ.copy()
|
||||
if 'xld' in split_cmd:
|
||||
env['PATH'] += os.pathsep + '/Applications'
|
||||
elif headphones.CONFIG.CUE_SPLIT_FLAC_PATH:
|
||||
env['PATH'] += os.pathsep + headphones.CONFIG.CUE_SPLIT_FLAC_PATH
|
||||
|
||||
process = subprocess.Popen(split_cmd, startupinfo=startupinfo,
|
||||
|
||||
@@ -588,9 +592,9 @@ def split(albumpath):
|
||||
splitter = 'shntool'
|
||||
|
||||
if splitter == 'shntool' and not check_splitter(splitter):
|
||||
raise ValueError('Command not found, ensure shntools with FLAC or xld (OS X) installed')
|
||||
raise ValueError('Command not found, ensure shntool with FLAC or xld (OS X) installed')
|
||||
|
||||
# Determine if file can be split (only flac allowed for shntools)
|
||||
# Determine if file can be split (only flac allowed for shntool)
|
||||
if 'xld' in splitter and wave.name_ext not in WAVE_FILE_TYPE_BY_EXTENSION.keys() or \
|
||||
wave.type not in SHNTOOL_COMPATIBLE:
|
||||
raise ValueError('Cannot split, audio file has unsupported extension')
|
||||
@@ -627,7 +631,11 @@ def split(albumpath):
|
||||
with open(SPLIT_FILE_NAME, mode='w') as split_file:
|
||||
split_file.write(cue.breakpoints())
|
||||
|
||||
cmd = ['shntool']
|
||||
if headphones.CONFIG.CUE_SPLIT_SHNTOOL_PATH:
|
||||
cmd = [os.path.join(headphones.CONFIG.CUE_SPLIT_SHNTOOL_PATH, 'shntool')]
|
||||
else:
|
||||
cmd = ['shntool']
|
||||
|
||||
cmd.extend(['split'])
|
||||
cmd.extend(['-f'])
|
||||
cmd.extend([SPLIT_FILE_NAME])
|
||||
|
||||
@@ -1033,6 +1033,8 @@ class WebInterface(object):
|
||||
"lossless_bitrate_to": headphones.CONFIG.LOSSLESS_BITRATE_TO,
|
||||
"freeze_db": checked(headphones.CONFIG.FREEZE_DB),
|
||||
"cue_split": checked(headphones.CONFIG.CUE_SPLIT),
|
||||
"cue_split_flac_path": headphones.CONFIG.CUE_SPLIT_FLAC_PATH,
|
||||
"cue_split_shntool_path": headphones.CONFIG.CUE_SPLIT_SHNTOOL_PATH,
|
||||
"move_files": checked(headphones.CONFIG.MOVE_FILES),
|
||||
"rename_files": checked(headphones.CONFIG.RENAME_FILES),
|
||||
"correct_metadata": checked(headphones.CONFIG.CORRECT_METADATA),
|
||||
|
||||
Reference in New Issue
Block a user