mirror of
https://github.com/rembo10/headphones.git
synced 2026-07-22 08:53:59 +01:00
Lossless min/max filter
filter results if calculated target size outside bitrate range
This commit is contained in:
@@ -470,7 +470,14 @@
|
|||||||
<div class="row radio clearfix">
|
<div class="row radio clearfix">
|
||||||
<input type="radio" name="preferred_quality" id="preferred_quality0" value="0" ${config['pref_qual_0']}><label>Highest Quality excluding Lossless</label>
|
<input type="radio" name="preferred_quality" id="preferred_quality0" value="0" ${config['pref_qual_0']}><label>Highest Quality excluding Lossless</label>
|
||||||
<input type="radio" name="preferred_quality" id="preferred_quality1" value="1" ${config['pref_qual_1']}><label>Highest Quality including Lossless</label>
|
<input type="radio" name="preferred_quality" id="preferred_quality1" value="1" ${config['pref_qual_1']}><label>Highest Quality including Lossless</label>
|
||||||
<input type="radio" name="preferred_quality" id="preferred_quality3" value="3" ${config['pref_qual_3']}><label>Lossless Only</label>
|
<input type="radio" name="preferred_quality" id="lossless_only" value="3" ${config['pref_qual_3']}><label>Lossless Only</label>
|
||||||
|
<div id="lossless_only_options">
|
||||||
|
<span style="padding-left: 20px">
|
||||||
|
Reject if target size is not in bitrate range: \
|
||||||
|
<input type="text" class="override-float" name="lossless_bitrate_from" value="${config['lossless_bitrate_from']}" size="4" title="e.g. if album length = 40 mins, from = 350 kbps, then min target size = 102.5 mb, anything less will be rejected">to\
|
||||||
|
<input type="text" class="override-float" name="lossless_bitrate_to" value="${config['lossless_bitrate_to']}" size="5" title="e.g. if album length = 40 mins, to = 2000 kbps, then max target size = 586 mb, anything greater will be rejected">kbps
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
<input type="radio" id="preferred_bitrate" name="preferred_quality" value="2" ${config['pref_qual_2']}>Preferred Bitrate: <input type="text" class="override-float" name="preferred_bitrate" value="${config['pref_bitrate']}" size="3">kbps<br>
|
<input type="radio" id="preferred_bitrate" name="preferred_quality" value="2" ${config['pref_qual_2']}>Preferred Bitrate: <input type="text" class="override-float" name="preferred_bitrate" value="${config['pref_bitrate']}" size="3">kbps<br>
|
||||||
<div id="preferred_bitrate_options">
|
<div id="preferred_bitrate_options">
|
||||||
Reject if <strong>less than</strong> <input type="text" class="override-float" name="preferred_bitrate_low_buffer" value="${config['pref_bitrate_low']}" size="3">% or <strong>more than</strong> <input type="text" class="override-float" name="preferred_bitrate_high_buffer" value="${config['pref_bitrate_high']}" size="3">% of the target size (leave blank for no limit)<br><br>
|
Reject if <strong>less than</strong> <input type="text" class="override-float" name="preferred_bitrate_low_buffer" value="${config['pref_bitrate_low']}" size="3">% or <strong>more than</strong> <input type="text" class="override-float" name="preferred_bitrate_high_buffer" value="${config['pref_bitrate_high']}" size="3">% of the target size (leave blank for no limit)<br><br>
|
||||||
@@ -1587,6 +1594,15 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if ($("#lossless_only").is(":checked"))
|
||||||
|
{
|
||||||
|
$("#lossless_only_options").show();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$("#lossless_only_options").hide();
|
||||||
|
}
|
||||||
|
|
||||||
if ($("#preferred_bitrate").is(":checked"))
|
if ($("#preferred_bitrate").is(":checked"))
|
||||||
{
|
{
|
||||||
$("#preferred_bitrate_options").show();
|
$("#preferred_bitrate_options").show();
|
||||||
@@ -1632,18 +1648,22 @@
|
|||||||
if ($("#preferred_bitrate").is(":checked"))
|
if ($("#preferred_bitrate").is(":checked"))
|
||||||
{
|
{
|
||||||
$("#preferred_bitrate_options").slideDown("fast");
|
$("#preferred_bitrate_options").slideDown("fast");
|
||||||
|
$("#lossless_only_options").slideUp("fast");
|
||||||
}
|
}
|
||||||
if ($("#preferred_quality0").is(":checked"))
|
if ($("#preferred_quality0").is(":checked"))
|
||||||
{
|
{
|
||||||
$("#preferred_bitrate_options").slideUp("fast");
|
$("#preferred_bitrate_options").slideUp("fast");
|
||||||
|
$("#lossless_only_options").slideUp("fast");
|
||||||
}
|
}
|
||||||
if ($("#preferred_quality1").is(":checked"))
|
if ($("#preferred_quality1").is(":checked"))
|
||||||
{
|
{
|
||||||
$("#preferred_bitrate_options").slideUp("fast");
|
$("#preferred_bitrate_options").slideUp("fast");
|
||||||
|
$("#lossless_only_options").slideUp("fast");
|
||||||
}
|
}
|
||||||
if ($("#preferred_quality3").is(":checked"))
|
if ($("#lossless_only").is(":checked"))
|
||||||
{
|
{
|
||||||
$("#preferred_bitrate_options").slideUp("fast");
|
$("#lossless_only_options").slideDown("fast");
|
||||||
|
$("#preferred_bitrate_options").slideUp("fast");
|
||||||
}
|
}
|
||||||
if ($("#nzb_downloader_sabnzbd").is(":checked"))
|
if ($("#nzb_downloader_sabnzbd").is(":checked"))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -103,6 +103,8 @@ PREFERRED_BITRATE_HIGH_BUFFER = None
|
|||||||
PREFERRED_BITRATE_LOW_BUFFER = None
|
PREFERRED_BITRATE_LOW_BUFFER = None
|
||||||
PREFERRED_BITRATE_ALLOW_LOSSLESS = False
|
PREFERRED_BITRATE_ALLOW_LOSSLESS = False
|
||||||
DETECT_BITRATE = False
|
DETECT_BITRATE = False
|
||||||
|
LOSSLESS_BITRATE_FROM = None
|
||||||
|
LOSSLESS_BITRATE_TO = None
|
||||||
ADD_ARTISTS = False
|
ADD_ARTISTS = False
|
||||||
CORRECT_METADATA = False
|
CORRECT_METADATA = False
|
||||||
MOVE_FILES = False
|
MOVE_FILES = False
|
||||||
@@ -358,7 +360,7 @@ def initialize():
|
|||||||
PUSHBULLET_ENABLED, PUSHBULLET_APIKEY, PUSHBULLET_DEVICEID, PUSHBULLET_ONSNATCH, \
|
PUSHBULLET_ENABLED, PUSHBULLET_APIKEY, PUSHBULLET_DEVICEID, PUSHBULLET_ONSNATCH, \
|
||||||
MIRROR, CUSTOMHOST, CUSTOMPORT, CUSTOMSLEEP, HPUSER, HPPASS, XBMC_ENABLED, XBMC_HOST, XBMC_USERNAME, XBMC_PASSWORD, XBMC_UPDATE, \
|
MIRROR, CUSTOMHOST, CUSTOMPORT, CUSTOMSLEEP, HPUSER, HPPASS, XBMC_ENABLED, XBMC_HOST, XBMC_USERNAME, XBMC_PASSWORD, XBMC_UPDATE, \
|
||||||
XBMC_NOTIFY, LMS_ENABLED, LMS_HOST, NMA_ENABLED, NMA_APIKEY, NMA_PRIORITY, NMA_ONSNATCH, SYNOINDEX_ENABLED, ALBUM_COMPLETION_PCT, PREFERRED_BITRATE_HIGH_BUFFER, \
|
XBMC_NOTIFY, LMS_ENABLED, LMS_HOST, NMA_ENABLED, NMA_APIKEY, NMA_PRIORITY, NMA_ONSNATCH, SYNOINDEX_ENABLED, ALBUM_COMPLETION_PCT, PREFERRED_BITRATE_HIGH_BUFFER, \
|
||||||
PREFERRED_BITRATE_LOW_BUFFER, PREFERRED_BITRATE_ALLOW_LOSSLESS, CACHE_SIZEMB, JOURNAL_MODE, UMASK, ENABLE_HTTPS, HTTPS_CERT, HTTPS_KEY, \
|
PREFERRED_BITRATE_LOW_BUFFER, PREFERRED_BITRATE_ALLOW_LOSSLESS, LOSSLESS_BITRATE_FROM, LOSSLESS_BITRATE_TO, CACHE_SIZEMB, JOURNAL_MODE, UMASK, ENABLE_HTTPS, HTTPS_CERT, HTTPS_KEY, \
|
||||||
PLEX_ENABLED, PLEX_SERVER_HOST, PLEX_CLIENT_HOST, PLEX_USERNAME, PLEX_PASSWORD, PLEX_UPDATE, PLEX_NOTIFY, PUSHALOT_ENABLED, PUSHALOT_APIKEY, \
|
PLEX_ENABLED, PLEX_SERVER_HOST, PLEX_CLIENT_HOST, PLEX_USERNAME, PLEX_PASSWORD, PLEX_UPDATE, PLEX_NOTIFY, PUSHALOT_ENABLED, PUSHALOT_APIKEY, \
|
||||||
PUSHALOT_ONSNATCH, SONGKICK_ENABLED, SONGKICK_APIKEY, SONGKICK_LOCATION, SONGKICK_FILTER_ENABLED
|
PUSHALOT_ONSNATCH, SONGKICK_ENABLED, SONGKICK_APIKEY, SONGKICK_LOCATION, SONGKICK_FILTER_ENABLED
|
||||||
|
|
||||||
@@ -438,6 +440,8 @@ def initialize():
|
|||||||
PREFERRED_BITRATE_LOW_BUFFER = check_setting_int(CFG, 'General', 'preferred_bitrate_low_buffer', '')
|
PREFERRED_BITRATE_LOW_BUFFER = check_setting_int(CFG, 'General', 'preferred_bitrate_low_buffer', '')
|
||||||
PREFERRED_BITRATE_ALLOW_LOSSLESS = bool(check_setting_int(CFG, 'General', 'preferred_bitrate_allow_lossless', 0))
|
PREFERRED_BITRATE_ALLOW_LOSSLESS = bool(check_setting_int(CFG, 'General', 'preferred_bitrate_allow_lossless', 0))
|
||||||
DETECT_BITRATE = bool(check_setting_int(CFG, 'General', 'detect_bitrate', 0))
|
DETECT_BITRATE = bool(check_setting_int(CFG, 'General', 'detect_bitrate', 0))
|
||||||
|
LOSSLESS_BITRATE_FROM = check_setting_int(CFG, 'General', 'lossless_bitrate_from', '')
|
||||||
|
LOSSLESS_BITRATE_TO = check_setting_int(CFG, 'General', 'lossless_bitrate_to', '')
|
||||||
ADD_ARTISTS = bool(check_setting_int(CFG, 'General', 'auto_add_artists', 1))
|
ADD_ARTISTS = bool(check_setting_int(CFG, 'General', 'auto_add_artists', 1))
|
||||||
CORRECT_METADATA = bool(check_setting_int(CFG, 'General', 'correct_metadata', 0))
|
CORRECT_METADATA = bool(check_setting_int(CFG, 'General', 'correct_metadata', 0))
|
||||||
MOVE_FILES = bool(check_setting_int(CFG, 'General', 'move_files', 0))
|
MOVE_FILES = bool(check_setting_int(CFG, 'General', 'move_files', 0))
|
||||||
@@ -862,6 +866,8 @@ def config_write():
|
|||||||
new_config['General']['preferred_bitrate_low_buffer'] = PREFERRED_BITRATE_LOW_BUFFER
|
new_config['General']['preferred_bitrate_low_buffer'] = PREFERRED_BITRATE_LOW_BUFFER
|
||||||
new_config['General']['preferred_bitrate_allow_lossless'] = int(PREFERRED_BITRATE_ALLOW_LOSSLESS)
|
new_config['General']['preferred_bitrate_allow_lossless'] = int(PREFERRED_BITRATE_ALLOW_LOSSLESS)
|
||||||
new_config['General']['detect_bitrate'] = int(DETECT_BITRATE)
|
new_config['General']['detect_bitrate'] = int(DETECT_BITRATE)
|
||||||
|
new_config['General']['lossless_bitrate_from'] = LOSSLESS_BITRATE_FROM
|
||||||
|
new_config['General']['lossless_bitrate_to'] = LOSSLESS_BITRATE_TO
|
||||||
new_config['General']['auto_add_artists'] = int(ADD_ARTISTS)
|
new_config['General']['auto_add_artists'] = int(ADD_ARTISTS)
|
||||||
new_config['General']['correct_metadata'] = int(CORRECT_METADATA)
|
new_config['General']['correct_metadata'] = int(CORRECT_METADATA)
|
||||||
new_config['General']['move_files'] = int(MOVE_FILES)
|
new_config['General']['move_files'] = int(MOVE_FILES)
|
||||||
|
|||||||
@@ -218,6 +218,34 @@ def sort_search_results(resultlist, album, new):
|
|||||||
|
|
||||||
finallist = sorted(resultlist, key=lambda title: (title[5], int(title[1])), reverse=True)
|
finallist = sorted(resultlist, key=lambda title: (title[5], int(title[1])), reverse=True)
|
||||||
|
|
||||||
|
# lossless - ignore results if target size outside bitrate range
|
||||||
|
elif headphones.PREFERRED_QUALITY == 3 and (headphones.LOSSLESS_BITRATE_FROM or headphones.LOSSLESS_BITRATE_TO):
|
||||||
|
|
||||||
|
finallist = []
|
||||||
|
tracks = myDB.select('SELECT TrackDuration from tracks WHERE AlbumID=?', [album['AlbumID']])
|
||||||
|
|
||||||
|
if len(tracks):
|
||||||
|
|
||||||
|
albumlength = sum([pair[0] for pair in tracks])
|
||||||
|
mintargetsize = 0
|
||||||
|
maxtargetsize = 0
|
||||||
|
if headphones.LOSSLESS_BITRATE_FROM:
|
||||||
|
mintargetsize = albumlength/1000 * int(headphones.LOSSLESS_BITRATE_FROM) * 128
|
||||||
|
if headphones.LOSSLESS_BITRATE_TO:
|
||||||
|
maxtargetsize = albumlength/1000 * int(headphones.LOSSLESS_BITRATE_TO) * 128
|
||||||
|
|
||||||
|
if mintargetsize > 0 or maxtargetsize > 0:
|
||||||
|
for i, result in reversed(list(enumerate(resultlist))):
|
||||||
|
if int(result[1]) < mintargetsize and mintargetsize > 0 or int(result[1]) > maxtargetsize and maxtargetsize > 0:
|
||||||
|
if int(result[1]) < mintargetsize:
|
||||||
|
logger.info("%s is too small for this album - not considering it. (Size: %s, Minsize: %s)", result[0], helpers.bytes_to_mb(result[1]), helpers.bytes_to_mb(mintargetsize))
|
||||||
|
else:
|
||||||
|
logger.info("%s is too large for this album - not considering it. (Size: %s, Maxsize: %s)", result[0], helpers.bytes_to_mb(result[1]), helpers.bytes_to_mb(maxtargetsize))
|
||||||
|
del resultlist[i]
|
||||||
|
|
||||||
|
if len (resultlist):
|
||||||
|
finallist = sorted(resultlist, key=lambda title: (title[5], int(title[1])), reverse=True)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
|
||||||
finallist = sorted(resultlist, key=lambda title: (title[5], int(title[1])), reverse=True)
|
finallist = sorted(resultlist, key=lambda title: (title[5], int(title[1])), reverse=True)
|
||||||
|
|||||||
@@ -1000,6 +1000,8 @@ class WebInterface(object):
|
|||||||
"pref_bitrate_low" : headphones.PREFERRED_BITRATE_LOW_BUFFER,
|
"pref_bitrate_low" : headphones.PREFERRED_BITRATE_LOW_BUFFER,
|
||||||
"pref_bitrate_allow_lossless" : checked(headphones.PREFERRED_BITRATE_ALLOW_LOSSLESS),
|
"pref_bitrate_allow_lossless" : checked(headphones.PREFERRED_BITRATE_ALLOW_LOSSLESS),
|
||||||
"detect_bitrate" : checked(headphones.DETECT_BITRATE),
|
"detect_bitrate" : checked(headphones.DETECT_BITRATE),
|
||||||
|
"lossless_bitrate_from" : headphones.LOSSLESS_BITRATE_FROM,
|
||||||
|
"lossless_bitrate_to" : headphones.LOSSLESS_BITRATE_TO,
|
||||||
"move_files" : checked(headphones.MOVE_FILES),
|
"move_files" : checked(headphones.MOVE_FILES),
|
||||||
"rename_files" : checked(headphones.RENAME_FILES),
|
"rename_files" : checked(headphones.RENAME_FILES),
|
||||||
"correct_metadata" : checked(headphones.CORRECT_METADATA),
|
"correct_metadata" : checked(headphones.CORRECT_METADATA),
|
||||||
@@ -1136,8 +1138,8 @@ class WebInterface(object):
|
|||||||
xbmc_update=0, xbmc_notify=0, nma_enabled=False, nma_apikey=None, nma_priority=0, nma_onsnatch=0, pushalot_enabled=False, pushalot_apikey=None, pushalot_onsnatch=0, synoindex_enabled=False, lms_enabled=0, lms_host=None,
|
xbmc_update=0, xbmc_notify=0, nma_enabled=False, nma_apikey=None, nma_priority=0, nma_onsnatch=0, pushalot_enabled=False, pushalot_apikey=None, pushalot_onsnatch=0, synoindex_enabled=False, lms_enabled=0, lms_host=None,
|
||||||
pushover_enabled=0, pushover_onsnatch=0, pushover_keys=None, pushover_priority=0, pushover_apitoken=None, pushbullet_enabled=0, pushbullet_onsnatch=0, pushbullet_apikey=None, pushbullet_deviceid=None, twitter_enabled=0, twitter_onsnatch=0,
|
pushover_enabled=0, pushover_onsnatch=0, pushover_keys=None, pushover_priority=0, pushover_apitoken=None, pushbullet_enabled=0, pushbullet_onsnatch=0, pushbullet_apikey=None, pushbullet_deviceid=None, twitter_enabled=0, twitter_onsnatch=0,
|
||||||
osx_notify_enabled=0, osx_notify_onsnatch=0, osx_notify_app=None, boxcar_enabled=0, boxcar_onsnatch=0, boxcar_token=None, mirror=None, customhost=None, customport=None, customsleep=None, hpuser=None, hppass=None,
|
osx_notify_enabled=0, osx_notify_onsnatch=0, osx_notify_app=None, boxcar_enabled=0, boxcar_onsnatch=0, boxcar_token=None, mirror=None, customhost=None, customport=None, customsleep=None, hpuser=None, hppass=None,
|
||||||
preferred_bitrate_high_buffer=None, preferred_bitrate_low_buffer=None, preferred_bitrate_allow_lossless=0, cache_sizemb=None, enable_https=0, https_cert=None, https_key=None, file_permissions=None, folder_permissions=None,
|
preferred_bitrate_high_buffer=None, preferred_bitrate_low_buffer=None, preferred_bitrate_allow_lossless=0, lossless_bitrate_from=None, lossless_bitrate_to=None, cache_sizemb=None, enable_https=0, https_cert=None, https_key=None,
|
||||||
plex_enabled=0, plex_server_host=None, plex_client_host=None, plex_username=None, plex_password=None, plex_update=0, plex_notify=0,
|
file_permissions=None, folder_permissions=None, plex_enabled=0, plex_server_host=None, plex_client_host=None, plex_username=None, plex_password=None, plex_update=0, plex_notify=0,
|
||||||
songkick_enabled=0, songkick_apikey=None, songkick_location=None, songkick_filter_enabled=0, encoder_multicore=False, encoder_multicore_count=0, mpc_enabled=False, **kwargs ):
|
songkick_enabled=0, songkick_apikey=None, songkick_location=None, songkick_filter_enabled=0, encoder_multicore=False, encoder_multicore_count=0, mpc_enabled=False, **kwargs ):
|
||||||
|
|
||||||
headphones.HTTP_HOST = http_host
|
headphones.HTTP_HOST = http_host
|
||||||
@@ -1216,6 +1218,8 @@ class WebInterface(object):
|
|||||||
headphones.PREFERRED_BITRATE_LOW_BUFFER = preferred_bitrate_low_buffer
|
headphones.PREFERRED_BITRATE_LOW_BUFFER = preferred_bitrate_low_buffer
|
||||||
headphones.PREFERRED_BITRATE_ALLOW_LOSSLESS = preferred_bitrate_allow_lossless
|
headphones.PREFERRED_BITRATE_ALLOW_LOSSLESS = preferred_bitrate_allow_lossless
|
||||||
headphones.DETECT_BITRATE = detect_bitrate
|
headphones.DETECT_BITRATE = detect_bitrate
|
||||||
|
headphones.LOSSLESS_BITRATE_FROM = lossless_bitrate_from
|
||||||
|
headphones.LOSSLESS_BITRATE_TO = lossless_bitrate_to
|
||||||
headphones.MOVE_FILES = move_files
|
headphones.MOVE_FILES = move_files
|
||||||
headphones.CORRECT_METADATA = correct_metadata
|
headphones.CORRECT_METADATA = correct_metadata
|
||||||
headphones.RENAME_FILES = rename_files
|
headphones.RENAME_FILES = rename_files
|
||||||
|
|||||||
Reference in New Issue
Block a user