diff --git a/web_server.py b/web_server.py
index 3f8ecd90..776f26fa 100644
--- a/web_server.py
+++ b/web_server.py
@@ -15062,6 +15062,7 @@ def _check_flac_bit_depth(file_path, context, context_key):
"""
Check if a FLAC file matches the user's preferred bit depth.
Returns True if the file was rejected (caller should return), False if OK.
+ With fallback enabled (default), accepts any FLAC bit depth rather than quarantining.
"""
if not context.get('_audio_quality', '').startswith('FLAC'):
return False
@@ -15069,7 +15070,8 @@ def _check_flac_bit_depth(file_path, context, context_key):
from database.music_database import MusicDatabase
_qp_db = MusicDatabase()
_quality_profile = _qp_db.get_quality_profile()
- _flac_pref = _quality_profile.get('qualities', {}).get('flac', {}).get('bit_depth', 'any')
+ _flac_config = _quality_profile.get('qualities', {}).get('flac', {})
+ _flac_pref = _flac_config.get('bit_depth', 'any')
if _flac_pref == 'any':
return False
@@ -15079,7 +15081,17 @@ def _check_flac_bit_depth(file_path, context, context_key):
if _actual_bits == _flac_pref:
return False
- # Reject — same pattern as AcoustID verification failure
+ # Bit depth doesn't match preference — check if fallback is enabled
+ _flac_fallback = _flac_config.get('bit_depth_fallback', True)
+
+ if _flac_fallback:
+ # Accept the file — a FLAC at any bit depth is better than a failed download
+ track_info = context.get('track_info', {})
+ track_name = track_info.get('name', os.path.basename(file_path))
+ print(f"📀 [FLAC Fallback] Accepted {_actual_bits}-bit FLAC (preferred {_flac_pref}-bit): {track_name}")
+ return False
+
+ # Strict mode — reject and quarantine
rejection_msg = f"FLAC bit depth mismatch: file is {_actual_bits}-bit, preference is {_flac_pref}-bit"
try:
quarantine_path = _move_to_quarantine(file_path, context, rejection_msg)
diff --git a/webui/index.html b/webui/index.html
index 9455ccf1..ced61526 100644
--- a/webui/index.html
+++ b/webui/index.html
@@ -4014,8 +4014,14 @@
-
- Rejects FLAC files that don't match the selected bit depth
+
+
+
+ When enabled, accepts any FLAC rather than rejecting on bit depth mismatch
+
diff --git a/webui/static/script.js b/webui/static/script.js
index 5939dd07..305f8c13 100644
--- a/webui/static/script.js
+++ b/webui/static/script.js
@@ -4943,7 +4943,7 @@ function populateQualityProfileUI(profile) {
}
}
- // FLAC-specific: restore bit depth selector
+ // FLAC-specific: restore bit depth selector and fallback toggle
if (quality === 'flac') {
const bitDepthValue = config.bit_depth || 'any';
document.querySelectorAll('.bit-depth-btn').forEach(btn => {
@@ -4957,6 +4957,15 @@ function populateQualityProfileUI(profile) {
bitDepthSelector.classList.add('disabled');
}
}
+ // Show/hide and restore fallback toggle
+ const fallbackToggle = document.getElementById('flac-fallback-toggle');
+ if (fallbackToggle) {
+ fallbackToggle.style.display = bitDepthValue === 'any' ? 'none' : 'block';
+ }
+ const fallbackCb = document.getElementById('flac-bit-depth-fallback');
+ if (fallbackCb) {
+ fallbackCb.checked = config.bit_depth_fallback !== false;
+ }
}
}
});
@@ -5033,6 +5042,12 @@ function setFlacBitDepth(value) {
btn.classList.toggle('active', btn.getAttribute('data-value') === value);
});
+ // Show/hide fallback toggle — only relevant when a specific bit depth is selected
+ const fallbackToggle = document.getElementById('flac-fallback-toggle');
+ if (fallbackToggle) {
+ fallbackToggle.style.display = value === 'any' ? 'none' : 'block';
+ }
+
// Mark preset as custom when manually changing
if (currentQualityProfile) {
currentQualityProfile.preset = 'custom';
@@ -5044,6 +5059,16 @@ function setFlacBitDepth(value) {
debouncedAutoSaveSettings();
}
+function setFlacBitDepthFallback(enabled) {
+ if (currentQualityProfile) {
+ currentQualityProfile.preset = 'custom';
+ document.querySelectorAll('.preset-button').forEach(btn => {
+ btn.classList.remove('active');
+ });
+ }
+ debouncedAutoSaveSettings();
+}
+
async function applyQualityPreset(presetName) {
try {
showLoadingOverlay(`Applying ${presetName} preset...`);
@@ -5094,10 +5119,12 @@ function collectQualityProfileFromUI() {
priority: existingPriority
};
- // Add FLAC-specific bit_depth setting
+ // Add FLAC-specific bit_depth and fallback settings
if (quality === 'flac') {
const activeBtn = document.querySelector('.bit-depth-btn.active');
profile.qualities[quality].bit_depth = activeBtn ? activeBtn.getAttribute('data-value') : 'any';
+ const fallbackCb = document.getElementById('flac-bit-depth-fallback');
+ profile.qualities[quality].bit_depth_fallback = fallbackCb ? fallbackCb.checked : true;
}
});