[log] clean ffmpeg logging

This commit is contained in:
jscampucci 2024-08-15 15:35:55 +02:00
parent 8fe8f4568e
commit 583949b686
3 changed files with 13 additions and 13 deletions

View File

@ -6,6 +6,8 @@ import 'package:notube/constants.dart';
import 'package:notube/models/video.dart';
import 'package:notube/services/download.dart';
import 'package:notube/services/file_logger.dart';
part 'dl_form_state.dart';
class DlFormCubit extends Cubit<DlFormState> {
@ -17,7 +19,7 @@ class DlFormCubit extends Cubit<DlFormState> {
emit(state.copyWith(
format: newFormat,
));
print(newFormat);
FileLogger().e(newFormat.format);
}
void setUrl(String newUrl) {

View File

@ -38,11 +38,11 @@ class ConverterService {
try {
var result = await Process.run(ffmpegPath, ['-version']);
if (result.exitCode == 0) {
print('FFmpeg is installed.');
FileLogger().d('FFmpeg is installed.');
return;
}
} catch (e) {
print('FFmpeg is not installed.');
FileLogger().d('FFmpeg is not installed.');
}
}

View File

@ -79,7 +79,7 @@ class DLServices {
var completer = Completer();
try {
shell.run(cmd).then((result) {
print('FFmpeg is already installed.');
FileLogger().d('FFmpeg is already installed.');
completer.complete(true);
result.map((e) {
FileLogger().d('Analyse result: $e');
@ -99,19 +99,17 @@ class DLServices {
}
Future<void> checkFFmpeg() async {
var result = await futureShell('ffmpeg -version');
FileLogger().d('$result');
try {
var result = await Process.run('ffmpeg', ['-version']);
FileLogger().d('$result');
if (result.exitCode == 0) {
print('FFmpeg is already installed.');
FileLogger().d('FFmpeg is already installed.');
return;
}
FileLogger().d('RESULTS: $result');
print('Installing FFmpeg...');
FileLogger().d('Installing FFmpeg...');
if (Platform.isLinux) {
result = await Process.run('sudo', ['-n', 'true']);
bool hasSudo = result.exitCode == 0;
@ -119,12 +117,12 @@ class DLServices {
result =
await Process.run('sudo', ['apt-get', 'install', 'ffmpeg', '-y']);
} else {
print('Cannot install FFmpeg without sudo privileges.');
FileLogger().d('Cannot install FFmpeg without sudo privileges.');
}
if (result.exitCode == 0) {
print('FFmpeg installed successfully.');
FileLogger().d('FFmpeg installed successfully.');
} else {
print('Error installing FFmpeg: ${result.stderr}');
FileLogger().d('Error installing FFmpeg: ${result.stderr}');
}
} else if (Platform.isMacOS) {
result = await Process.run('brew', ['install', 'ffmpeg']);
@ -137,7 +135,7 @@ class DLServices {
]);
}
} catch (e) {
print('An error occurred: $e');
FileLogger().e('An error occurred: $e');
}
}