mirror of
https://github.com/zarzet/SpotiFLAC-Mobile.git
synced 2026-07-02 11:05:38 +02:00
fix(download): detect actual output format from audio codec on fallback
When a fallback provider returns a non-FLAC container (e.g. YouTube Opus) and neither an explicit extension field nor a recognizable path suffix is available (such as SAF content URIs), infer the output extension from the backend-probed audio codec. Prevents Opus/MP3/AAC downloads from being mislabeled and embedded as FLAC, which left metadata empty.
This commit is contained in:
@@ -3331,6 +3331,29 @@ class DownloadQueueNotifier extends Notifier<DownloadQueueState> {
|
||||
if (lower.endsWith(ext)) return ext;
|
||||
}
|
||||
}
|
||||
|
||||
// Generic safety net: when neither an explicit extension field nor a
|
||||
// recognizable path suffix is available (e.g. SAF content URIs that drop
|
||||
// the suffix), fall back to the actual audio codec reported by the backend
|
||||
// probe. This keeps any extension that returns a non-FLAC container (Opus,
|
||||
// MP3, AAC) from being mislabeled as FLAC.
|
||||
final codec = _normalizeAudioFormatValue(
|
||||
result['audio_codec']?.toString() ??
|
||||
result['actual_audio_codec']?.toString() ??
|
||||
result['format']?.toString(),
|
||||
);
|
||||
switch (codec) {
|
||||
case 'opus':
|
||||
return '.opus';
|
||||
case 'mp3':
|
||||
return '.mp3';
|
||||
case 'aac':
|
||||
case 'alac':
|
||||
case 'm4a':
|
||||
return '.m4a';
|
||||
case 'flac':
|
||||
return '.flac';
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user