mirror of
https://github.com/rembo10/headphones.git
synced 2026-07-21 00:14:02 +01:00
Add option to encode only lossless files
This commit is contained in:
@@ -263,6 +263,8 @@
|
|||||||
<br>
|
<br>
|
||||||
<h3><input type="checkbox" name="encode" value="1" ${config['encode']}/> Re-encode downloads during postprocessing</h3>
|
<h3><input type="checkbox" name="encode" value="1" ${config['encode']}/> Re-encode downloads during postprocessing</h3>
|
||||||
<i class="smalltext">Note: this option requires the lame or ffmpeg encoder</i>
|
<i class="smalltext">Note: this option requires the lame or ffmpeg encoder</i>
|
||||||
|
<br>
|
||||||
|
<h3><input type="checkbox" name="encoderlossless" value="1" ${config['encoderlossless']}/> Re-encode only LossLess format (.flac)</h3>
|
||||||
<br><br>
|
<br><br>
|
||||||
<%
|
<%
|
||||||
if config['encoder'] == 'lame':
|
if config['encoder'] == 'lame':
|
||||||
|
|||||||
@@ -263,6 +263,8 @@
|
|||||||
<br>
|
<br>
|
||||||
<h3><input type="checkbox" name="encode" value="1" ${config['encode']}/> Re-encode downloads during postprocessing</h3>
|
<h3><input type="checkbox" name="encode" value="1" ${config['encode']}/> Re-encode downloads during postprocessing</h3>
|
||||||
<i class="smalltext">Note: this option requires the lame or ffmpeg encoder</i>
|
<i class="smalltext">Note: this option requires the lame or ffmpeg encoder</i>
|
||||||
|
<br>
|
||||||
|
<h3><input type="checkbox" name="encoderlossless" value="1" ${config['encoderlossless']}/> Re-encode only LossLess format (.flac)</h3>
|
||||||
<br><br>
|
<br><br>
|
||||||
<%
|
<%
|
||||||
if config['encoder'] == 'lame':
|
if config['encoder'] == 'lame':
|
||||||
|
|||||||
@@ -122,6 +122,7 @@ ADVANCEDENCODER = None
|
|||||||
ENCODEROUTPUTFORMAT = None
|
ENCODEROUTPUTFORMAT = None
|
||||||
ENCODERQUALITY = None
|
ENCODERQUALITY = None
|
||||||
ENCODERVBRCBR = None
|
ENCODERVBRCBR = None
|
||||||
|
ENCODERLOSSLESS = True
|
||||||
|
|
||||||
def CheckSection(sec):
|
def CheckSection(sec):
|
||||||
""" Check if INI section exists, if not create it """
|
""" Check if INI section exists, if not create it """
|
||||||
@@ -181,7 +182,8 @@ def initialize():
|
|||||||
LIBRARYSCAN_INTERVAL, DOWNLOAD_SCAN_INTERVAL, SAB_HOST, SAB_USERNAME, SAB_PASSWORD, SAB_APIKEY, SAB_CATEGORY, \
|
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, \
|
NZBMATRIX, NZBMATRIX_USERNAME, NZBMATRIX_APIKEY, NEWZNAB, NEWZNAB_HOST, NEWZNAB_APIKEY, \
|
||||||
NZBSORG, NZBSORG_UID, NZBSORG_HASH, NEWZBIN, NEWZBIN_UID, NEWZBIN_PASSWORD, LASTFM_USERNAME, INTERFACE, FOLDER_PERMISSIONS, \
|
NZBSORG, NZBSORG_UID, NZBSORG_HASH, NEWZBIN, NEWZBIN_UID, NEWZBIN_PASSWORD, LASTFM_USERNAME, INTERFACE, FOLDER_PERMISSIONS, \
|
||||||
ENCODERFOLDER, ENCODER, BITRATE, SAMPLINGFREQUENCY, ENCODE, ADVANCEDENCODER, ENCODEROUTPUTFORMAT, ENCODERQUALITY, ENCODERVBRVBR
|
ENCODERFOLDER, ENCODER, BITRATE, SAMPLINGFREQUENCY, ENCODE, ADVANCEDENCODER, ENCODEROUTPUTFORMAT, ENCODERQUALITY, ENCODERVBRVBR, \
|
||||||
|
ENCODERLOSSLESS
|
||||||
|
|
||||||
if __INITIALIZED__:
|
if __INITIALIZED__:
|
||||||
return False
|
return False
|
||||||
@@ -272,6 +274,7 @@ def initialize():
|
|||||||
ENCODEROUTPUTFORMAT = check_setting_str(CFG, 'General', 'encoderoutputformat', 'mp3')
|
ENCODEROUTPUTFORMAT = check_setting_str(CFG, 'General', 'encoderoutputformat', 'mp3')
|
||||||
ENCODERQUALITY = check_setting_int(CFG, 'General', 'vorbisquality', 5)
|
ENCODERQUALITY = check_setting_int(CFG, 'General', 'vorbisquality', 5)
|
||||||
ENCODERVBRCBR = check_setting_str(CFG, 'General', 'encodervbrcbr', 'cbr')
|
ENCODERVBRCBR = check_setting_str(CFG, 'General', 'encodervbrcbr', 'cbr')
|
||||||
|
ENCODERLOSSLESS = bool(check_setting_int(CFG, 'General', 'encoderlossless', 1))
|
||||||
|
|
||||||
if not LOG_DIR:
|
if not LOG_DIR:
|
||||||
LOG_DIR = os.path.join(DATA_DIR, 'logs')
|
LOG_DIR = os.path.join(DATA_DIR, 'logs')
|
||||||
@@ -459,6 +462,7 @@ def config_write():
|
|||||||
new_config['General']['encoderoutputformat'] = ENCODEROUTPUTFORMAT
|
new_config['General']['encoderoutputformat'] = ENCODEROUTPUTFORMAT
|
||||||
new_config['General']['encoderquality'] = ENCODERQUALITY
|
new_config['General']['encoderquality'] = ENCODERQUALITY
|
||||||
new_config['General']['encodervbrcbr'] = ENCODERVBRCBR
|
new_config['General']['encodervbrcbr'] = ENCODERVBRCBR
|
||||||
|
new_config['General']['encoderlossless'] = ENCODERLOSSLESS
|
||||||
|
|
||||||
new_config.write()
|
new_config.write()
|
||||||
|
|
||||||
|
|||||||
+14
-9
@@ -31,10 +31,18 @@ def encode(albumPath):
|
|||||||
for r,d,f in os.walk(albumPath):
|
for r,d,f in os.walk(albumPath):
|
||||||
for music in f:
|
for music in f:
|
||||||
if any(music.endswith('.' + x) for x in headphones.MEDIA_FORMATS):
|
if any(music.endswith('.' + x) for x in headphones.MEDIA_FORMATS):
|
||||||
musicFiles.append(os.path.join(r, music))
|
if (headphones.ENCODERLOSSLESS):
|
||||||
musicTemp = os.path.normpath(os.path.splitext(music)[0]+'.'+headphones.ENCODEROUTPUTFORMAT).encode(headphones.SYS_ENCODING)
|
if (music.endswith('.flac')):
|
||||||
musicTempFiles.append(os.path.join(tempDirEncode, musicTemp))
|
musicFiles.append(os.path.join(r, music))
|
||||||
|
musicTemp = os.path.normpath(os.path.splitext(music)[0]+'.'+headphones.ENCODEROUTPUTFORMAT).encode(headphones.SYS_ENCODING)
|
||||||
|
musicTempFiles.append(os.path.join(tempDirEncode, musicTemp))
|
||||||
|
else:
|
||||||
|
logger.warn('Music "%s" is already encoded' % (music))
|
||||||
|
else:
|
||||||
|
musicFiles.append(os.path.join(r, music))
|
||||||
|
musicTemp = os.path.normpath(os.path.splitext(music)[0]+'.'+headphones.ENCODEROUTPUTFORMAT).encode(headphones.SYS_ENCODING)
|
||||||
|
musicTempFiles.append(os.path.join(tempDirEncode, musicTemp))
|
||||||
|
|
||||||
if headphones.ENCODER=='lame':
|
if headphones.ENCODER=='lame':
|
||||||
encoder=os.path.join(headphones.ENCODERFOLDER,'lame')
|
encoder=os.path.join(headphones.ENCODERFOLDER,'lame')
|
||||||
elif headphones.ENCODER=='ffmpeg':
|
elif headphones.ENCODER=='ffmpeg':
|
||||||
@@ -42,7 +50,6 @@ def encode(albumPath):
|
|||||||
i=0
|
i=0
|
||||||
for music in musicFiles:
|
for music in musicFiles:
|
||||||
infoMusic=MediaFile(music)
|
infoMusic=MediaFile(music)
|
||||||
|
|
||||||
if headphones.ENCODER == 'lame':
|
if headphones.ENCODER == 'lame':
|
||||||
if not any(music.endswith('.' +headphones.ENCODEROUTPUTFORMAT) for x in ["mp3", "wav"]):
|
if not any(music.endswith('.' +headphones.ENCODEROUTPUTFORMAT) for x in ["mp3", "wav"]):
|
||||||
logger.warn('Lame cant encode "%s" format for "%s", use ffmpeg' % (os.path.splitext(music)[1],music))
|
logger.warn('Lame cant encode "%s" format for "%s", use ffmpeg' % (os.path.splitext(music)[1],music))
|
||||||
@@ -65,8 +72,8 @@ def encode(albumPath):
|
|||||||
else:
|
else:
|
||||||
command(encoder,music,musicTempFiles[i],albumPath)
|
command(encoder,music,musicTempFiles[i],albumPath)
|
||||||
ifencoded=1
|
ifencoded=1
|
||||||
i=i+1
|
i=i+1
|
||||||
|
|
||||||
shutil.rmtree(tempDirEncode)
|
shutil.rmtree(tempDirEncode)
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
for r,d,f in os.walk(albumPath):
|
for r,d,f in os.walk(albumPath):
|
||||||
@@ -76,8 +83,6 @@ def encode(albumPath):
|
|||||||
|
|
||||||
if ifencoded==0:
|
if ifencoded==0:
|
||||||
logger.info('Encoding for folder "%s" is not needed' % (albumPath))
|
logger.info('Encoding for folder "%s" is not needed' % (albumPath))
|
||||||
else:
|
|
||||||
logger.info('Encoding for folder "%s" is completed in %s' % (albumPath,getTimeEncode(startAlbumTime)))
|
|
||||||
|
|
||||||
return musicFinalFiles
|
return musicFinalFiles
|
||||||
|
|
||||||
|
|||||||
@@ -359,7 +359,8 @@ class WebInterface(object):
|
|||||||
"encoderoutputformat": headphones.ENCODEROUTPUTFORMAT,
|
"encoderoutputformat": headphones.ENCODEROUTPUTFORMAT,
|
||||||
"samplingfrequency": int(headphones.SAMPLINGFREQUENCY),
|
"samplingfrequency": int(headphones.SAMPLINGFREQUENCY),
|
||||||
"encodervbrcbr": (headphones.ENCODERVBRCBR),
|
"encodervbrcbr": (headphones.ENCODERVBRCBR),
|
||||||
"encoderquality": int(headphones.ENCODERQUALITY)
|
"encoderquality": int(headphones.ENCODERQUALITY),
|
||||||
|
"encoderlossless": checked(headphones.ENCODERLOSSLESS)
|
||||||
}
|
}
|
||||||
return serve_template(templatename="config.html", title="Settings", config=config)
|
return serve_template(templatename="config.html", title="Settings", config=config)
|
||||||
config.exposed = True
|
config.exposed = True
|
||||||
@@ -370,7 +371,7 @@ class WebInterface(object):
|
|||||||
usenet_retention=None, nzbmatrix=0, nzbmatrix_username=None, nzbmatrix_apikey=None, newznab=0, newznab_host=None, newznab_apikey=None,
|
usenet_retention=None, nzbmatrix=0, nzbmatrix_username=None, nzbmatrix_apikey=None, newznab=0, newznab_host=None, newznab_apikey=None,
|
||||||
nzbsorg=0, nzbsorg_uid=None, nzbsorg_hash=None, newzbin=0, newzbin_uid=None, newzbin_password=None, preferred_quality=0, preferred_bitrate=None, detect_bitrate=0, move_files=0,
|
nzbsorg=0, nzbsorg_uid=None, nzbsorg_hash=None, newzbin=0, newzbin_uid=None, newzbin_password=None, preferred_quality=0, preferred_bitrate=None, detect_bitrate=0, move_files=0,
|
||||||
rename_files=0, correct_metadata=0, cleanup_files=0, add_album_art=0, embed_album_art=0, embed_lyrics=0, destination_dir=None, folder_format=None, file_format=None, include_extras=0, interface=None, log_dir=None,
|
rename_files=0, correct_metadata=0, cleanup_files=0, add_album_art=0, embed_album_art=0, embed_lyrics=0, destination_dir=None, folder_format=None, file_format=None, include_extras=0, interface=None, log_dir=None,
|
||||||
encode=0, encoder=None, bitrate=None, samplingfrequency=None, encoderfolder=None, advancedencoder=None, encoderoutputformat=None, encodervbrcbr=None, encoderquality=None):
|
encode=0, encoder=None, bitrate=None, samplingfrequency=None, encoderfolder=None, advancedencoder=None, encoderoutputformat=None, encodervbrcbr=None, encoderquality=None, encoderlossless=0):
|
||||||
|
|
||||||
headphones.HTTP_HOST = http_host
|
headphones.HTTP_HOST = http_host
|
||||||
headphones.HTTP_PORT = http_port
|
headphones.HTTP_PORT = http_port
|
||||||
@@ -423,6 +424,7 @@ class WebInterface(object):
|
|||||||
headphones.ENCODEROUTPUTFORMAT = encoderoutputformat
|
headphones.ENCODEROUTPUTFORMAT = encoderoutputformat
|
||||||
headphones.ENCODERVBRCBR = encodervbrcbr
|
headphones.ENCODERVBRCBR = encodervbrcbr
|
||||||
headphones.ENCODERQUALITY = int(encoderquality)
|
headphones.ENCODERQUALITY = int(encoderquality)
|
||||||
|
headphones.ENCODERLOSSLESS = encoderlossless
|
||||||
|
|
||||||
headphones.config_write()
|
headphones.config_write()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user