[log] clean ffmpeg logging
This commit is contained in:
parent
2b05bc8d93
commit
bc4655090f
|
|
@ -6,6 +6,8 @@ import 'package:notube/constants.dart';
|
||||||
import 'package:notube/models/video.dart';
|
import 'package:notube/models/video.dart';
|
||||||
import 'package:notube/services/download.dart';
|
import 'package:notube/services/download.dart';
|
||||||
|
|
||||||
|
import 'package:notube/services/file_logger.dart';
|
||||||
|
|
||||||
part 'dl_form_state.dart';
|
part 'dl_form_state.dart';
|
||||||
|
|
||||||
class DlFormCubit extends Cubit<DlFormState> {
|
class DlFormCubit extends Cubit<DlFormState> {
|
||||||
|
|
@ -17,7 +19,7 @@ class DlFormCubit extends Cubit<DlFormState> {
|
||||||
emit(state.copyWith(
|
emit(state.copyWith(
|
||||||
format: newFormat,
|
format: newFormat,
|
||||||
));
|
));
|
||||||
print(newFormat);
|
FileLogger().e(newFormat.format);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setUrl(String newUrl) {
|
void setUrl(String newUrl) {
|
||||||
|
|
|
||||||
|
|
@ -38,11 +38,11 @@ class ConverterService {
|
||||||
try {
|
try {
|
||||||
var result = await Process.run(ffmpegPath, ['-version']);
|
var result = await Process.run(ffmpegPath, ['-version']);
|
||||||
if (result.exitCode == 0) {
|
if (result.exitCode == 0) {
|
||||||
print('FFmpeg is installed.');
|
FileLogger().d('FFmpeg is installed.');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
print('FFmpeg is not installed.');
|
FileLogger().d('FFmpeg is not installed.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -79,7 +79,7 @@ class DLServices {
|
||||||
var completer = Completer();
|
var completer = Completer();
|
||||||
try {
|
try {
|
||||||
shell.run(cmd).then((result) {
|
shell.run(cmd).then((result) {
|
||||||
print('FFmpeg is already installed.');
|
FileLogger().d('FFmpeg is already installed.');
|
||||||
completer.complete(true);
|
completer.complete(true);
|
||||||
result.map((e) {
|
result.map((e) {
|
||||||
FileLogger().d('Analyse result: $e');
|
FileLogger().d('Analyse result: $e');
|
||||||
|
|
@ -99,19 +99,17 @@ class DLServices {
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> checkFFmpeg() async {
|
Future<void> checkFFmpeg() async {
|
||||||
var result = await futureShell('ffmpeg -version');
|
|
||||||
FileLogger().d('$result');
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
var result = await Process.run('ffmpeg', ['-version']);
|
var result = await Process.run('ffmpeg', ['-version']);
|
||||||
|
FileLogger().d('$result');
|
||||||
if (result.exitCode == 0) {
|
if (result.exitCode == 0) {
|
||||||
print('FFmpeg is already installed.');
|
FileLogger().d('FFmpeg is already installed.');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
FileLogger().d('RESULTS: $result');
|
FileLogger().d('RESULTS: $result');
|
||||||
|
|
||||||
print('Installing FFmpeg...');
|
FileLogger().d('Installing FFmpeg...');
|
||||||
if (Platform.isLinux) {
|
if (Platform.isLinux) {
|
||||||
result = await Process.run('sudo', ['-n', 'true']);
|
result = await Process.run('sudo', ['-n', 'true']);
|
||||||
bool hasSudo = result.exitCode == 0;
|
bool hasSudo = result.exitCode == 0;
|
||||||
|
|
@ -119,12 +117,12 @@ class DLServices {
|
||||||
result =
|
result =
|
||||||
await Process.run('sudo', ['apt-get', 'install', 'ffmpeg', '-y']);
|
await Process.run('sudo', ['apt-get', 'install', 'ffmpeg', '-y']);
|
||||||
} else {
|
} else {
|
||||||
print('Cannot install FFmpeg without sudo privileges.');
|
FileLogger().d('Cannot install FFmpeg without sudo privileges.');
|
||||||
}
|
}
|
||||||
if (result.exitCode == 0) {
|
if (result.exitCode == 0) {
|
||||||
print('FFmpeg installed successfully.');
|
FileLogger().d('FFmpeg installed successfully.');
|
||||||
} else {
|
} else {
|
||||||
print('Error installing FFmpeg: ${result.stderr}');
|
FileLogger().d('Error installing FFmpeg: ${result.stderr}');
|
||||||
}
|
}
|
||||||
} else if (Platform.isMacOS) {
|
} else if (Platform.isMacOS) {
|
||||||
result = await Process.run('brew', ['install', 'ffmpeg']);
|
result = await Process.run('brew', ['install', 'ffmpeg']);
|
||||||
|
|
@ -137,7 +135,7 @@ class DLServices {
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
print('An error occurred: $e');
|
FileLogger().e('An error occurred: $e');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue