From f1023b7c778d06b958cd3dcc4adcdce4a5c451ee Mon Sep 17 00:00:00 2001 From: zarzet Date: Tue, 14 Apr 2026 20:40:19 +0700 Subject: [PATCH] fix: handle .mp4 as alias for .m4a throughout download pipeline --- lib/providers/download_queue_provider.dart | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/providers/download_queue_provider.dart b/lib/providers/download_queue_provider.dart index 4a571e1..885a98f 100644 --- a/lib/providers/download_queue_provider.dart +++ b/lib/providers/download_queue_provider.dart @@ -574,6 +574,7 @@ class DownloadHistoryNotifier extends Notifier { if (trimmed.startsWith('content://')) return true; return trimmed.endsWith('.flac') || trimmed.endsWith('.m4a') || + trimmed.endsWith('.mp4') || trimmed.endsWith('.aac') || trimmed.endsWith('.mp3') || trimmed.endsWith('.opus') || @@ -595,6 +596,7 @@ class DownloadHistoryNotifier extends Notifier { !hasResolvedSpecs && (trimmedPath.endsWith('.flac') || trimmedPath.endsWith('.m4a') || + trimmedPath.endsWith('.mp4') || trimmedPath.endsWith('.aac') || trimmedPath.startsWith('content://')); @@ -2359,6 +2361,9 @@ class DownloadQueueNotifier extends Notifier { final normalized = preferred.startsWith('.') ? preferred.toLowerCase() : '.${preferred.toLowerCase()}'; + if (normalized == '.mp4') { + return '.m4a'; + } const allowed = {'.flac', '.m4a', '.mp3', '.opus'}; if (allowed.contains(normalized)) { return normalized; @@ -2402,6 +2407,7 @@ class DownloadQueueNotifier extends Notifier { String _mimeTypeForExt(String ext) { switch (ext.toLowerCase()) { case '.m4a': + case '.mp4': return 'audio/mp4'; case '.mp3': return 'audio/mpeg'; @@ -5021,6 +5027,7 @@ class DownloadQueueNotifier extends Notifier { final isM4aFile = filePath != null && (filePath.endsWith('.m4a') || + filePath.endsWith('.mp4') || (mimeType != null && mimeType.contains('mp4'))); final isFlacFile = filePath != null && @@ -5375,7 +5382,8 @@ class DownloadQueueNotifier extends Notifier { if (!await file.exists()) { _log.e('File does not exist at path: $filePath'); } else { - if (!targetPath.toLowerCase().endsWith('.m4a')) { + if (!(targetPath.toLowerCase().endsWith('.m4a') || + targetPath.toLowerCase().endsWith('.mp4'))) { final renamedPath = targetPath.replaceAll( RegExp(r'\.[^.]+$'), '.m4a', @@ -5841,6 +5849,7 @@ class DownloadQueueNotifier extends Notifier { filePath.startsWith('content://') || lowerFilePath.endsWith('.flac') || lowerFilePath.endsWith('.m4a') || + lowerFilePath.endsWith('.mp4') || lowerFilePath.endsWith('.aac') || lowerFilePath.endsWith('.mp3') || lowerFilePath.endsWith('.opus') ||