mirror of
https://github.com/zarzet/SpotiFLAC-Mobile.git
synced 2026-07-11 06:53:46 +02:00
feat: resolve audio metadata from file, backfill placeholder quality labels with actual bit depth and sample rate
This commit is contained in:
@@ -5,3 +5,47 @@ String? normalizeOptionalString(String? value) {
|
||||
if (trimmed.toLowerCase() == 'null') return null;
|
||||
return trimmed;
|
||||
}
|
||||
|
||||
String formatSampleRateKHz(int sampleRate) {
|
||||
final khz = sampleRate / 1000;
|
||||
final precision = sampleRate % 1000 == 0 ? 0 : 1;
|
||||
return '${khz.toStringAsFixed(precision)}kHz';
|
||||
}
|
||||
|
||||
String? buildDisplayAudioQuality({
|
||||
int? bitDepth,
|
||||
int? sampleRate,
|
||||
int? bitrateKbps,
|
||||
String? format,
|
||||
String? storedQuality,
|
||||
}) {
|
||||
if (bitrateKbps != null && bitrateKbps > 0) {
|
||||
final normalizedFormat = normalizeOptionalString(format)?.toUpperCase();
|
||||
return normalizedFormat != null
|
||||
? '$normalizedFormat ${bitrateKbps}kbps'
|
||||
: '${bitrateKbps}kbps';
|
||||
}
|
||||
|
||||
if (bitDepth != null &&
|
||||
bitDepth > 0 &&
|
||||
sampleRate != null &&
|
||||
sampleRate > 0) {
|
||||
return '$bitDepth-bit/${formatSampleRateKHz(sampleRate)}';
|
||||
}
|
||||
|
||||
return normalizeOptionalString(storedQuality);
|
||||
}
|
||||
|
||||
bool isPlaceholderQualityLabel(String? quality) {
|
||||
final normalized = normalizeOptionalString(quality)?.toLowerCase();
|
||||
if (normalized == null) return false;
|
||||
|
||||
return const {
|
||||
'best',
|
||||
'lossless',
|
||||
'hi-res',
|
||||
'hi-res-max',
|
||||
'high',
|
||||
'cd',
|
||||
}.contains(normalized);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user