From 3b757cfce0a83e1fceb687eb04ea3cdfe2489fc2 Mon Sep 17 00:00:00 2001 From: rembo10 Date: Wed, 5 Dec 2012 05:06:49 -0500 Subject: [PATCH] Fixed the encoder adding 'lame', 'ffmpeg', 'xld' to the end of the encoder path which was breaking encoding on windows. Also prevent Headphones from daemonizing under Windows --- Headphones.py | 5 ++++- data/interfaces/default/config.html | 2 +- headphones/__init__.py | 20 +++++++++++++++++--- headphones/music_encoder.py | 23 +++++++++++++++-------- headphones/webserve.py | 4 ++-- 5 files changed, 39 insertions(+), 15 deletions(-) diff --git a/Headphones.py b/Headphones.py index a3896a0f..1982818d 100644 --- a/Headphones.py +++ b/Headphones.py @@ -109,7 +109,10 @@ def main(): headphones.initialize() if headphones.DAEMON: - headphones.daemonize() + if sys.platform == "win32": + print "Daemonize not supported under Windows, starting normally" + else: + headphones.daemonize() #configure the connection to the musicbrainz database headphones.mb.startmb() diff --git a/data/interfaces/default/config.html b/data/interfaces/default/config.html index 58baf946..742ade22 100644 --- a/data/interfaces/default/config.html +++ b/data/interfaces/default/config.html @@ -546,7 +546,7 @@
- +
diff --git a/headphones/__init__.py b/headphones/__init__.py index 2da69469..63373819 100644 --- a/headphones/__init__.py +++ b/headphones/__init__.py @@ -169,6 +169,7 @@ FOLDER_PERMISSIONS = None MUSIC_ENCODER = False ENCODERFOLDER = None +ENCODER_PATH = None ENCODER = None XLDPROFILE = None BITRATE = None @@ -268,7 +269,7 @@ def initialize(): LIBRARYSCAN, LIBRARYSCAN_INTERVAL, DOWNLOAD_SCAN_INTERVAL, SAB_HOST, SAB_USERNAME, SAB_PASSWORD, SAB_APIKEY, SAB_CATEGORY, \ NZBMATRIX, NZBMATRIX_USERNAME, NZBMATRIX_APIKEY, NEWZNAB, NEWZNAB_HOST, NEWZNAB_APIKEY, NEWZNAB_ENABLED, EXTRA_NEWZNABS,\ NZBSORG, NZBSORG_UID, NZBSORG_HASH, NEWZBIN, NEWZBIN_UID, NEWZBIN_PASSWORD, LASTFM_USERNAME, INTERFACE, FOLDER_PERMISSIONS, \ - ENCODERFOLDER, ENCODER, XLDPROFILE, BITRATE, SAMPLINGFREQUENCY, MUSIC_ENCODER, ADVANCEDENCODER, ENCODEROUTPUTFORMAT, ENCODERQUALITY, \ + ENCODERFOLDER, ENCODER_PATH, ENCODER, XLDPROFILE, BITRATE, SAMPLINGFREQUENCY, MUSIC_ENCODER, ADVANCEDENCODER, ENCODEROUTPUTFORMAT, ENCODERQUALITY, \ ENCODERVBRCBR, ENCODERLOSSLESS, DELETE_LOSSLESS_FILES, PROWL_ENABLED, PROWL_PRIORITY, PROWL_KEYS, PROWL_ONSNATCH, \ PUSHOVER_ENABLED, PUSHOVER_PRIORITY, PUSHOVER_KEYS, PUSHOVER_ONSNATCH, MIRRORLIST, \ MIRROR, CUSTOMHOST, CUSTOMPORT, CUSTOMSLEEP, HPUSER, HPPASS, XBMC_ENABLED, XBMC_HOST, XBMC_USERNAME, XBMC_PASSWORD, XBMC_UPDATE, \ @@ -405,7 +406,8 @@ def initialize(): INTERFACE = check_setting_str(CFG, 'General', 'interface', 'default') FOLDER_PERMISSIONS = check_setting_str(CFG, 'General', 'folder_permissions', '0755') - ENCODERFOLDER = check_setting_str(CFG, 'General', 'encoderfolder', '') + ENCODERFOLDER = check_setting_str(CFG, 'General', 'encoderfolder', '') + ENCODER_PATH = check_setting_str(CFG, 'General', 'encoder_path', '') ENCODER = check_setting_str(CFG, 'General', 'encoder', 'ffmpeg') XLDPROFILE = check_setting_str(CFG, 'General', 'xldprofile', '') BITRATE = check_setting_int(CFG, 'General', 'bitrate', 192) @@ -493,6 +495,18 @@ def initialize(): FOLDER_FORMAT = replace_all(FOLDER_FORMAT, folder_values) CONFIG_VERSION = '2' + + if CONFIG_VERSION == '2': + + # Update the config to use direct path to the encoder rather than the encoder folder + if ENCODERFOLDER: + if ENCODER == "xld": + ENCODER_PATH = os.path.join(headphones.ENCODERFOLDER.encode(headphones.SYS_ENCODING), 'xld') + elif ENCODER == "ffmpeg": + ENCODER_PATH = os.path.join(headphones.ENCODERFOLDER.encode(headphones.SYS_ENCODING), 'ffmpeg') + elif ENCODER == "lame": + ENCODER_PATH = os.path.join(headphones.ENCODERFOLDER.encode(headphones.SYS_ENCODING), 'lame') + CONFIG_VERSION = '3' if not LOG_DIR: LOG_DIR = os.path.join(DATA_DIR, 'logs') @@ -749,7 +763,7 @@ def config_write(): new_config['General']['xldprofile'] = XLDPROFILE new_config['General']['bitrate'] = int(BITRATE) new_config['General']['samplingfrequency'] = int(SAMPLINGFREQUENCY) - new_config['General']['encoderfolder'] = ENCODERFOLDER + new_config['General']['encoder_path'] = ENCODER_PATH new_config['General']['advancedencoder'] = ADVANCEDENCODER new_config['General']['encoderoutputformat'] = ENCODEROUTPUTFORMAT new_config['General']['encoderquality'] = ENCODERQUALITY diff --git a/headphones/music_encoder.py b/headphones/music_encoder.py index 4e057e20..f0ede2bd 100644 --- a/headphones/music_encoder.py +++ b/headphones/music_encoder.py @@ -85,15 +85,22 @@ def encode(albumPath): musicTemp = os.path.normpath(os.path.splitext(music)[0] + '.' + encoderFormat) musicTempFiles.append(os.path.join(tempDirEncode, musicTemp)) - if XLD: - if headphones.ENCODERFOLDER: - encoder = os.path.join(headphones.ENCODERFOLDER.encode(headphones.SYS_ENCODING), 'xld') - else: + if headphones.ENCODER_PATH: + encoder = headphones.ENCODER_PATH.encode(headphones.SYS_ENCODING) + else: + if XLD: encoder = os.path.join('/Applications', 'xld') - elif headphones.ENCODER=='lame': - encoder=os.path.join(headphones.ENCODERFOLDER.encode(headphones.SYS_ENCODING),'lame') - elif headphones.ENCODER=='ffmpeg': - encoder=os.path.join(headphones.ENCODERFOLDER.encode(headphones.SYS_ENCODING),'ffmpeg') + elif headphones.ENCODER =='lame': + if headphones.SYS_PLATFORM == "win32": + ## NEED THE DEFAULT LAME INSTALL ON WIN! + encoder = "C:/Program Files/lame/lame.exe" + else: + encoder="lame" + elif headphones.ENCODER =='ffmpeg': + if headphones.SYS_PLATFORM == "win32": + encoder = "C:/Program Files/ffmpeg/ffmpeg.exe" + else: + encoder="ffmpeg" i=0 for music in musicFiles: diff --git a/headphones/webserve.py b/headphones/webserve.py index 4e04246f..813416b6 100644 --- a/headphones/webserve.py +++ b/headphones/webserve.py @@ -626,7 +626,7 @@ class WebInterface(object): "encoder": headphones.ENCODER, "xldprofile": headphones.XLDPROFILE, "bitrate": int(headphones.BITRATE), - "encoderfolder": headphones.ENCODERFOLDER, + "encoderfolder": headphones.ENCODER_PATH, "advancedencoder": headphones.ADVANCEDENCODER, "encoderoutputformat": headphones.ENCODEROUTPUTFORMAT, "samplingfrequency": headphones.SAMPLINGFREQUENCY, @@ -770,7 +770,7 @@ class WebInterface(object): headphones.XLDPROFILE = xldprofile headphones.BITRATE = int(bitrate) headphones.SAMPLINGFREQUENCY = int(samplingfrequency) - headphones.ENCODERFOLDER = encoderfolder + headphones.ENCODER_PATH = encoderfolder headphones.ADVANCEDENCODER = advancedencoder headphones.ENCODEROUTPUTFORMAT = encoderoutputformat headphones.ENCODERVBRCBR = encodervbrcbr