[error] clean errors
This commit is contained in:
parent
4ed6c8b94a
commit
96399aa1b4
|
|
@ -39,6 +39,7 @@ class DLServices {
|
||||||
if (Platform.isWindows) {
|
if (Platform.isWindows) {
|
||||||
assetName = 'yt-dlp.exe';
|
assetName = 'yt-dlp.exe';
|
||||||
} else if (Platform.isLinux) {
|
} else if (Platform.isLinux) {
|
||||||
|
checkFFmpeg();
|
||||||
assetName = 'yt-dlp_linux';
|
assetName = 'yt-dlp_linux';
|
||||||
} else if (Platform.isMacOS) {
|
} else if (Platform.isMacOS) {
|
||||||
assetName = 'yt-dlp_macos';
|
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 {
|
Future<Stream> downloadFile(Video video) async {
|
||||||
debugPrint(
|
debugPrint(
|
||||||
'Downloading $url in ${video.format.format} format (${video.filename})');
|
'Downloading $url in ${video.format.format} format (${video.filename})');
|
||||||
|
|
@ -131,23 +161,12 @@ class DLServices {
|
||||||
) {
|
) {
|
||||||
if (error is ShellException) {
|
if (error is ShellException) {
|
||||||
debugPrint('ShellException: ${error.message}');
|
debugPrint('ShellException: ${error.message}');
|
||||||
FileLogger().e('ShellException: ${error.message}');
|
FileLogger().e('ShellException error: ${error.result?.stderr}');
|
||||||
|
FileLogger().e('ShellException out: ${error.result?.stdout}');
|
||||||
} else {
|
} else {
|
||||||
debugPrint('Error: $error');
|
debugPrint('Error: $error');
|
||||||
FileLogger().e('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;
|
return shellLinesController.stream;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue