From 5623ef5a948530e25d30f3ab004b635b7d4c72ea Mon Sep 17 00:00:00 2001 From: jscampucci Date: Wed, 10 Jul 2024 11:56:58 +0200 Subject: [PATCH] [error} add downloader error --- lib/services/download.dart | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/lib/services/download.dart b/lib/services/download.dart index 021826d..3ef86df 100644 --- a/lib/services/download.dart +++ b/lib/services/download.dart @@ -120,10 +120,34 @@ class DLServices { '${video.url.trim()} --sub-langs "all,-live_chat" --embed-subs --embed-thumbnail --embed-metadata --progress -o "temp/${video.filename}_$strType.%(ext)s" -f "$formatCmd"'; var shellLinesController = ShellLinesController(); - var shell = Shell(stdout: shellLinesController.sink, verbose: false); + var shellErrorController = ShellLinesController(); + + var shell = Shell( + stdout: shellLinesController.sink, + stderr: shellErrorController.sink, + verbose: false); debugPrint('Running $ytDlpPath $command'); - shell.run('$ytDlpPath $command'); + await shell.run('$ytDlpPath $command').then((result) { + result.map((e) { + debugPrint('Analyse result: $e'); + FileLogger().d('Analyse result: ${e.toString()}'); + FileLogger().d('stdout: ${e.stdout}'); + FileLogger().d('stderr: ${e.stderr}'); + }); + }).catchError(( + error, + stackTrace, + ) { + if (error is ShellException) { + debugPrint('ShellException: ${error.message}'); + FileLogger().e('ShellException error: ${error.result?.stderr}'); + FileLogger().e('ShellException out: ${error.result?.stdout}'); + } else { + debugPrint('Error: $error'); + FileLogger().e('Error: $error'); + } + }); return shellLinesController.stream; }