mirror of
https://github.com/zarzet/SpotiFLAC-Mobile.git
synced 2026-10-04 15:16:58 +02:00
feat(library): filter tracks missing verified ReplayGain tags
This commit is contained in:
1 parent
fbf479c102
commit
718e13f24e
20 files changed
+568
-20
No files matched your search
@@ -40,6 +40,32 @@ Map<String, dynamic> normalizeScannedAudioMetadata(
|
||||
return normalized;
|
||||
}
|
||||
|
||||
/// Whether scanned or probed tags carry a usable ReplayGain value. Library scans
|
||||
/// and readFileMetadata both use the snake_case `replaygain_*` keys; persisted
|
||||
/// rows round-trip through `hasReplayGain`.
|
||||
bool metadataHasReplayGain(Map<String, dynamic> metadata) {
|
||||
final stored = metadata['hasReplayGain'];
|
||||
if (stored == true || stored == 1) return true;
|
||||
for (final key in const ['replaygain_track_gain', 'replaygain_album_gain']) {
|
||||
final value = metadata[key];
|
||||
final gain = double.tryParse(
|
||||
(value?.toString() ?? '')
|
||||
.replaceFirst(RegExp(r'\s*dB\s*$', caseSensitive: false), '')
|
||||
.trim(),
|
||||
);
|
||||
if (gain != null && gain.isFinite) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool replayGainMetadataWasRead(Map<String, dynamic> metadata) =>
|
||||
metadata['error'] == null &&
|
||||
metadata['metadataFromFilename'] != true &&
|
||||
(metadata['audio_codec'] != null ||
|
||||
metadata['format'] != null ||
|
||||
metadata.containsKey('replaygain_track_gain') ||
|
||||
metadata.containsKey('replaygain_album_gain'));
|
||||
|
||||
int? readPositiveBitrateKbps(dynamic value) {
|
||||
final parsed = readPositiveInt(value);
|
||||
if (parsed == null) return null;
|
||||
|
||||
Reference in new issue
Block a user