From c4e2255eaff15130310b173fb9d473807c413f77 Mon Sep 17 00:00:00 2001 From: jscampucci Date: Tue, 27 Aug 2024 16:40:51 +0200 Subject: [PATCH] [audio] manage audio download --- lib/constants.dart | 6 ++++++ lib/services/download.dart | 6 +++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/constants.dart b/lib/constants.dart index 053ca64..dfbec50 100644 --- a/lib/constants.dart +++ b/lib/constants.dart @@ -64,3 +64,9 @@ const convertedFormats = [ Format.tGP, Format.flv, ]; + +const audioFormats = [ + Format.m4a, + Format.mp3, + Format.mp3HD, +]; diff --git a/lib/services/download.dart b/lib/services/download.dart index 2595ceb..d6604f8 100644 --- a/lib/services/download.dart +++ b/lib/services/download.dart @@ -151,15 +151,16 @@ class DLServices { Format.values.firstWhere((e) => e.format == video.format.format).ytCmd; FileLogger().d('Format code: $formatCmd'); - File doneFile = File('temp/${video.filename}_tmp.mp4'); + File doneFile = File('${tempDir.path}/${video.filename}_tmp.mp4'); if (doneFile.existsSync()) { FileLogger().d('File already downloaded'); return Stream.fromIterable(['[EmbedThumbnail]']); } var strType = convertedFormats.contains(video.format) ? 'tmp' : 'done'; + var isAudio = audioFormats.contains(video.format); var command = - '${video.url.trim()} --sub-langs "all,-live_chat" --embed-subs --embed-thumbnail --embed-metadata --progress -o "${tempDir.path}/${video.filename}_$strType.%(ext)s" -f "$formatCmd"'; + '${video.url.trim()}${isAudio ? '' : '--sub-langs "all,-live_chat" --embed-subs --embed-thumbnail --embed-metadata'} --progress -o "${tempDir.path}/${video.filename}_$strType.%(ext)s" -f "$formatCmd"'; var shellLinesController = ShellLinesController(); var shellErrorController = ShellLinesController(); @@ -184,7 +185,6 @@ class DLServices { FileLogger().e('ShellException error: ${error.result?.stderr}'); FileLogger().e('ShellException out: ${error.result?.stdout}'); } else { - FileLogger().d('Error: $error'); FileLogger().e('Error: $error'); } });