[error] clean errors
This commit is contained in:
parent
fdf794e76c
commit
8ec63b7657
|
|
@ -39,6 +39,7 @@ class DLServices {
|
|||
if (Platform.isWindows) {
|
||||
assetName = 'yt-dlp.exe';
|
||||
} else if (Platform.isLinux) {
|
||||
checkFFmpeg();
|
||||
assetName = 'yt-dlp_linux';
|
||||
} else if (Platform.isMacOS) {
|
||||
assetName = 'yt-dlp_macos';
|
||||
|
|
@ -65,6 +66,35 @@ class DLServices {
|
|||
}
|
||||
}
|
||||
|
||||
Future<void> checkFFmpeg() async {
|
||||
try {
|
||||
var result = await Process.run('ffmpeg', ['-version']);
|
||||
if (result.exitCode == 0) {
|
||||
print('FFmpeg is already installed.');
|
||||
return;
|
||||
}
|
||||
|
||||
result = await Process.run('sudo', ['-n', 'true']);
|
||||
bool hasSudo = result.exitCode == 0;
|
||||
|
||||
if (hasSudo) {
|
||||
print('Installing FFmpeg...');
|
||||
result =
|
||||
await Process.run('sudo', ['apt-get', 'install', 'ffmpeg', '-y']);
|
||||
if (result.exitCode == 0) {
|
||||
print('FFmpeg installed successfully.');
|
||||
} else {
|
||||
print('Error installing FFmpeg: ${result.stderr}');
|
||||
}
|
||||
} else {
|
||||
print('Cannot install FFmpeg without sudo privileges.');
|
||||
// Here, you might want to inform the user they need to manually install FFmpeg
|
||||
}
|
||||
} catch (e) {
|
||||
print('An error occurred: $e');
|
||||
}
|
||||
}
|
||||
|
||||
Future<Stream> downloadFile(Video video) async {
|
||||
debugPrint(
|
||||
'Downloading $url in ${video.format.format} format (${video.filename})');
|
||||
|
|
@ -131,23 +161,12 @@ class DLServices {
|
|||
) {
|
||||
if (error is ShellException) {
|
||||
debugPrint('ShellException: ${error.message}');
|
||||
FileLogger().e('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');
|
||||
}
|
||||
if (stackTrace != null) {
|
||||
debugPrint('Stacktrace: $stackTrace');
|
||||
FileLogger().e('Stacktrace: $stackTrace');
|
||||
}
|
||||
if (error.map) {
|
||||
error.map((e) {
|
||||
debugPrint('Analyse result: $e');
|
||||
FileLogger().d('Analyse result: ${e.toString()}');
|
||||
FileLogger().d('stdout: ${e.stdout}');
|
||||
FileLogger().d('stderr: ${e.stderr}');
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
return shellLinesController.stream;
|
||||
|
|
|
|||
Loading…
Reference in New Issue