[log] clean file logger
This commit is contained in:
parent
01db0170fd
commit
fd60d2c137
|
|
@ -7,6 +7,7 @@ import 'package:notube/constants.dart';
|
||||||
import 'package:notube/models/video.dart';
|
import 'package:notube/models/video.dart';
|
||||||
import 'package:notube/videoList/cubit/videos_cubit.dart';
|
import 'package:notube/videoList/cubit/videos_cubit.dart';
|
||||||
import 'package:notube/dlForm/cubit/dl_form_cubit.dart';
|
import 'package:notube/dlForm/cubit/dl_form_cubit.dart';
|
||||||
|
import 'package:notube/services/file_logger.dart';
|
||||||
|
|
||||||
class SubmitButton extends StatefulWidget {
|
class SubmitButton extends StatefulWidget {
|
||||||
const SubmitButton({super.key});
|
const SubmitButton({super.key});
|
||||||
|
|
@ -22,7 +23,7 @@ class _SubmitButtonState extends State<SubmitButton> {
|
||||||
if (state.isParsed) {
|
if (state.isParsed) {
|
||||||
context.read<VideosCubit>().setGlobalStatus('loaded');
|
context.read<VideosCubit>().setGlobalStatus('loaded');
|
||||||
for (Video video in state.videos) {
|
for (Video video in state.videos) {
|
||||||
debugPrint('Adding video: $video');
|
FileLogger().d('Adding video: $video');
|
||||||
context.read<VideosCubit>().addVideo(video);
|
context.read<VideosCubit>().addVideo(video);
|
||||||
}
|
}
|
||||||
context.read<DlFormCubit>().clearForm();
|
context.read<DlFormCubit>().clearForm();
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ import 'package:flutter/foundation.dart';
|
||||||
import 'package:process_run/process_run.dart';
|
import 'package:process_run/process_run.dart';
|
||||||
import 'package:notube/models/video.dart';
|
import 'package:notube/models/video.dart';
|
||||||
import 'package:path/path.dart' as p;
|
import 'package:path/path.dart' as p;
|
||||||
|
import 'package:notube/services/file_logger.dart';
|
||||||
|
|
||||||
class ConverterService {
|
class ConverterService {
|
||||||
late Directory tempDir;
|
late Directory tempDir;
|
||||||
|
|
@ -15,7 +16,7 @@ class ConverterService {
|
||||||
ConverterService._();
|
ConverterService._();
|
||||||
|
|
||||||
static Future<ConverterService> init() async {
|
static Future<ConverterService> init() async {
|
||||||
debugPrint('Initializing DLServices');
|
FileLogger().d('Initializing DLServices');
|
||||||
var dlService = ConverterService._();
|
var dlService = ConverterService._();
|
||||||
await dlService._init();
|
await dlService._init();
|
||||||
return dlService;
|
return dlService;
|
||||||
|
|
@ -50,8 +51,8 @@ class ConverterService {
|
||||||
final List<FileSystemEntity> files = directory.listSync();
|
final List<FileSystemEntity> files = directory.listSync();
|
||||||
for (FileSystemEntity file in files) {
|
for (FileSystemEntity file in files) {
|
||||||
final String dirFilename = p.basenameWithoutExtension(file.path);
|
final String dirFilename = p.basenameWithoutExtension(file.path);
|
||||||
debugPrint('dirFilename $dirFilename');
|
FileLogger().d('dirFilename $dirFilename');
|
||||||
debugPrint('filename $filename');
|
FileLogger().d('filename $filename');
|
||||||
if (dirFilename == '${filename}_tmp') {
|
if (dirFilename == '${filename}_tmp') {
|
||||||
return File(file.path);
|
return File(file.path);
|
||||||
}
|
}
|
||||||
|
|
@ -60,7 +61,7 @@ class ConverterService {
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<Stream> convertFile(Video video) async {
|
Future<Stream> convertFile(Video video) async {
|
||||||
debugPrint(
|
FileLogger().d(
|
||||||
'____Converting ${video.title} to ${video.format.format} format_____');
|
'____Converting ${video.title} to ${video.format.format} format_____');
|
||||||
|
|
||||||
File tmpFile = File('temp/${video.filename}_tmp.mp4');
|
File tmpFile = File('temp/${video.filename}_tmp.mp4');
|
||||||
|
|
@ -72,7 +73,7 @@ class ConverterService {
|
||||||
File doneFile =
|
File doneFile =
|
||||||
File('temp/${video.filename}_done.${video.format.extension}');
|
File('temp/${video.filename}_done.${video.format.extension}');
|
||||||
if (doneFile.existsSync()) {
|
if (doneFile.existsSync()) {
|
||||||
debugPrint('File already converted');
|
FileLogger().d('File already converted');
|
||||||
return Stream.fromIterable(['progress=end']);
|
return Stream.fromIterable(['progress=end']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ class DLServices {
|
||||||
DLServices._();
|
DLServices._();
|
||||||
|
|
||||||
static Future<DLServices> init() async {
|
static Future<DLServices> init() async {
|
||||||
debugPrint('Initializing DLServices');
|
FileLogger().d('Initializing DLServices');
|
||||||
var dlService = DLServices._();
|
var dlService = DLServices._();
|
||||||
await dlService._init();
|
await dlService._init();
|
||||||
return dlService;
|
return dlService;
|
||||||
|
|
@ -57,7 +57,7 @@ class DLServices {
|
||||||
ByteData data = await rootBundle.load('assets/executable/$assetName');
|
ByteData data = await rootBundle.load('assets/executable/$assetName');
|
||||||
await tempFile.exists().then((value) {
|
await tempFile.exists().then((value) {
|
||||||
if (!value) {
|
if (!value) {
|
||||||
debugPrint('Copying $assetName to ${tempFile.path}');
|
FileLogger().d('Copying $assetName to ${tempFile.path}');
|
||||||
tempFile.writeAsBytes(
|
tempFile.writeAsBytes(
|
||||||
data.buffer.asUint8List(data.offsetInBytes, data.lengthInBytes));
|
data.buffer.asUint8List(data.offsetInBytes, data.lengthInBytes));
|
||||||
}
|
}
|
||||||
|
|
@ -82,10 +82,10 @@ class DLServices {
|
||||||
print('FFmpeg is already installed.');
|
print('FFmpeg is already installed.');
|
||||||
completer.complete(true);
|
completer.complete(true);
|
||||||
result.map((e) {
|
result.map((e) {
|
||||||
debugPrint('Analyse result: $e');
|
FileLogger().d('Analyse result: $e');
|
||||||
FileLogger().d('Analyse result: ${e.toString()}');
|
FileLogger().d('Analyse result: ${e.toString()}');
|
||||||
FileLogger().d('stdout: ${e.stdout}');
|
FileLogger().w('stdout: ${e.stdout}');
|
||||||
FileLogger().d('stderr: ${e.stderr}');
|
FileLogger().e('stderr: ${e.stderr}');
|
||||||
});
|
});
|
||||||
}).catchError((
|
}).catchError((
|
||||||
error,
|
error,
|
||||||
|
|
@ -100,7 +100,7 @@ class DLServices {
|
||||||
|
|
||||||
Future<void> checkFFmpeg() async {
|
Future<void> checkFFmpeg() async {
|
||||||
var result = await futureShell('ffmpeg -version');
|
var result = await futureShell('ffmpeg -version');
|
||||||
debugPrint('$result');
|
FileLogger().d('$result');
|
||||||
|
|
||||||
try {
|
try {
|
||||||
var result = await Process.run('ffmpeg', ['-version']);
|
var result = await Process.run('ffmpeg', ['-version']);
|
||||||
|
|
@ -109,7 +109,7 @@ class DLServices {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
debugPrint('RESULTS: $result');
|
FileLogger().d('RESULTS: $result');
|
||||||
|
|
||||||
print('Installing FFmpeg...');
|
print('Installing FFmpeg...');
|
||||||
if (Platform.isLinux) {
|
if (Platform.isLinux) {
|
||||||
|
|
@ -142,7 +142,7 @@ class DLServices {
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<Stream> downloadFile(Video video) async {
|
Future<Stream> downloadFile(Video video) async {
|
||||||
debugPrint(
|
FileLogger().d(
|
||||||
'Downloading $url in ${video.format.format} format (${video.filename})');
|
'Downloading $url in ${video.format.format} format (${video.filename})');
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -153,11 +153,11 @@ class DLServices {
|
||||||
// get the format code from the Format enum
|
// get the format code from the Format enum
|
||||||
var formatCmd =
|
var formatCmd =
|
||||||
Format.values.firstWhere((e) => e.format == video.format.format).ytCmd;
|
Format.values.firstWhere((e) => e.format == video.format.format).ytCmd;
|
||||||
debugPrint('Format code: $formatCmd');
|
FileLogger().d('Format code: $formatCmd');
|
||||||
|
|
||||||
File doneFile = File('temp/${video.filename}_tmp.mp4');
|
File doneFile = File('temp/${video.filename}_tmp.mp4');
|
||||||
if (doneFile.existsSync()) {
|
if (doneFile.existsSync()) {
|
||||||
debugPrint('File already downloaded');
|
FileLogger().d('File already downloaded');
|
||||||
return Stream.fromIterable(['[EmbedThumbnail]']);
|
return Stream.fromIterable(['[EmbedThumbnail]']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -171,24 +171,24 @@ class DLServices {
|
||||||
var shell = Shell(
|
var shell = Shell(
|
||||||
stdout: shellLinesController.sink, stderr: shellErrorController.sink);
|
stdout: shellLinesController.sink, stderr: shellErrorController.sink);
|
||||||
|
|
||||||
debugPrint('Running $ytDlpPath $command');
|
FileLogger().d('Running $ytDlpPath $command');
|
||||||
shell.run('$ytDlpPath $command').then((result) {
|
shell.run('$ytDlpPath $command').then((result) {
|
||||||
result.map((e) {
|
result.map((e) {
|
||||||
debugPrint('Analyse result: $e');
|
FileLogger().d('Analyse result: $e');
|
||||||
FileLogger().d('Analyse result: ${e.toString()}');
|
FileLogger().d('Analyse result: ${e.toString()}');
|
||||||
FileLogger().d('stdout: ${e.stdout}');
|
FileLogger().w('stdout: ${e.stdout}');
|
||||||
FileLogger().d('stderr: ${e.stderr}');
|
FileLogger().e('stderr: ${e.stderr}');
|
||||||
});
|
});
|
||||||
}).catchError((
|
}).catchError((
|
||||||
error,
|
error,
|
||||||
stackTrace,
|
stackTrace,
|
||||||
) {
|
) {
|
||||||
if (error is ShellException) {
|
if (error is ShellException) {
|
||||||
debugPrint('ShellException: ${error.message}');
|
FileLogger().d('ShellException: ${error.message}');
|
||||||
FileLogger().e('ShellException error: ${error.result?.stderr}');
|
FileLogger().e('ShellException error: ${error.result?.stderr}');
|
||||||
FileLogger().e('ShellException out: ${error.result?.stdout}');
|
FileLogger().e('ShellException out: ${error.result?.stdout}');
|
||||||
} else {
|
} else {
|
||||||
debugPrint('Error: $error');
|
FileLogger().d('Error: $error');
|
||||||
FileLogger().e('Error: $error');
|
FileLogger().e('Error: $error');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -197,7 +197,7 @@ class DLServices {
|
||||||
}
|
}
|
||||||
|
|
||||||
Future analyseUrl(String url) async {
|
Future analyseUrl(String url) async {
|
||||||
debugPrint('Analyse $url');
|
FileLogger().d('Analyse $url');
|
||||||
|
|
||||||
var command = '${url.trim()} -q --flat-playlist -J';
|
var command = '${url.trim()} -q --flat-playlist -J';
|
||||||
|
|
||||||
|
|
@ -205,7 +205,7 @@ class DLServices {
|
||||||
var shellErrorController = ShellLinesController();
|
var shellErrorController = ShellLinesController();
|
||||||
|
|
||||||
shellErrorController.stream.listen((event) {
|
shellErrorController.stream.listen((event) {
|
||||||
debugPrint('Analyse error: $event');
|
FileLogger().d('Analyse error: $event');
|
||||||
FileLogger().e('Analyse error: $event');
|
FileLogger().e('Analyse error: $event');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -218,21 +218,21 @@ class DLServices {
|
||||||
$ytDlpPath $command
|
$ytDlpPath $command
|
||||||
''').then((result) {
|
''').then((result) {
|
||||||
result.map((e) {
|
result.map((e) {
|
||||||
debugPrint('Analyse result: $e');
|
FileLogger().d('Analyse result: $e');
|
||||||
FileLogger().d('Analyse result: ${e.toString()}');
|
FileLogger().d('Analyse result: ${e.toString()}');
|
||||||
FileLogger().d('stdout: ${e.stdout}');
|
FileLogger().w('stdout: ${e.stdout}');
|
||||||
FileLogger().d('stderr: ${e.stderr}');
|
FileLogger().e('stderr: ${e.stderr}');
|
||||||
});
|
});
|
||||||
}).catchError((
|
}).catchError((
|
||||||
error,
|
error,
|
||||||
stackTrace,
|
stackTrace,
|
||||||
) {
|
) {
|
||||||
if (error is ShellException) {
|
if (error is ShellException) {
|
||||||
debugPrint('ShellException: ${error.message}');
|
FileLogger().d('ShellException: ${error.message}');
|
||||||
FileLogger().e('ShellException error: ${error.result?.stderr}');
|
FileLogger().e('ShellException error: ${error.result?.stderr}');
|
||||||
FileLogger().e('ShellException out: ${error.result?.stdout}');
|
FileLogger().e('ShellException out: ${error.result?.stdout}');
|
||||||
} else {
|
} else {
|
||||||
debugPrint('Error: $error');
|
FileLogger().d('Error: $error');
|
||||||
FileLogger().e('Error: $error');
|
FileLogger().e('Error: $error');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -18,12 +18,14 @@ class FileLogger {
|
||||||
_logFile = File('apps_logs.txt');
|
_logFile = File('apps_logs.txt');
|
||||||
|
|
||||||
_logger = Logger(
|
_logger = Logger(
|
||||||
|
filter: ProductionFilter(),
|
||||||
printer: PrettyPrinter(),
|
printer: PrettyPrinter(),
|
||||||
output: FileOutput(file: _logFile),
|
output: FileOutput(file: _logFile),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void d(String message) {
|
void d(String message) {
|
||||||
|
FileLogger().d(message);
|
||||||
_logger.d(message);
|
_logger.d(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -32,6 +34,7 @@ class FileLogger {
|
||||||
}
|
}
|
||||||
|
|
||||||
void w(String message) {
|
void w(String message) {
|
||||||
|
FileLogger().d(message);
|
||||||
_logger.w(message);
|
_logger.w(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@ import 'package:notube/constants.dart';
|
||||||
import 'package:shared_preferences/shared_preferences.dart';
|
import 'package:shared_preferences/shared_preferences.dart';
|
||||||
import 'package:downloadsfolder/downloadsfolder.dart';
|
import 'package:downloadsfolder/downloadsfolder.dart';
|
||||||
import 'package:path/path.dart' as p;
|
import 'package:path/path.dart' as p;
|
||||||
|
import 'package:notube/services/file_logger.dart';
|
||||||
|
|
||||||
part 'videos_state.dart';
|
part 'videos_state.dart';
|
||||||
|
|
||||||
|
|
@ -40,7 +41,7 @@ class VideosCubit extends Cubit<VideosState> {
|
||||||
emit(VideosState(videoList: tmpVideoList));
|
emit(VideosState(videoList: tmpVideoList));
|
||||||
completer.complete();
|
completer.complete();
|
||||||
} else {
|
} else {
|
||||||
debugPrint('Video not found in the list');
|
FileLogger().d('Video not found in the list');
|
||||||
completer.completeError('Video not found in the list');
|
completer.completeError('Video not found in the list');
|
||||||
}
|
}
|
||||||
return completer.future;
|
return completer.future;
|
||||||
|
|
@ -60,12 +61,12 @@ class VideosCubit extends Cubit<VideosState> {
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> archiveVideo(Video video) async {
|
Future<void> archiveVideo(Video video) async {
|
||||||
debugPrint('Archiving video: ${video.title} ${video.format.format}');
|
FileLogger().d('Archiving video: ${video.title} ${video.format.format}');
|
||||||
var nVideoList = state.videoList.where((v) => v.id != video.id).toList();
|
var nVideoList = state.videoList.where((v) => v.id != video.id).toList();
|
||||||
var archivedVideos = state.archiveList.toList();
|
var archivedVideos = state.archiveList.toList();
|
||||||
debugPrint('Archived videos before: ${archivedVideos.length}');
|
FileLogger().d('Archived videos before: ${archivedVideos.length}');
|
||||||
archivedVideos.add(video);
|
archivedVideos.add(video);
|
||||||
debugPrint('Archived videos after: $archivedVideos');
|
FileLogger().d('Archived videos after: $archivedVideos');
|
||||||
emit(state.copyWith(videoList: nVideoList, archiveList: archivedVideos));
|
emit(state.copyWith(videoList: nVideoList, archiveList: archivedVideos));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -76,7 +77,8 @@ class VideosCubit extends Cubit<VideosState> {
|
||||||
for (Video video in videosToConvert) {
|
for (Video video in videosToConvert) {
|
||||||
await convertVideo(video);
|
await convertVideo(video);
|
||||||
}
|
}
|
||||||
debugPrint('All videos converted');
|
FileLogger().d('All videos converted');
|
||||||
|
FileLogger().d('All videos converted');
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> startDownloader() async {
|
Future<void> startDownloader() async {
|
||||||
|
|
@ -86,9 +88,9 @@ class VideosCubit extends Cubit<VideosState> {
|
||||||
state.videoList.where((video) => video.status == 'pending').take(3);
|
state.videoList.where((video) => video.status == 'pending').take(3);
|
||||||
|
|
||||||
while (downloadingVid.isNotEmpty && runningTasks < maxConcurrentTasks) {
|
while (downloadingVid.isNotEmpty && runningTasks < maxConcurrentTasks) {
|
||||||
debugPrint('Videos to download: ${downloadingVid.length}');
|
FileLogger().d('Videos to download: ${downloadingVid.length}');
|
||||||
runningTasks++;
|
runningTasks++;
|
||||||
debugPrint('Concurrent workers: $runningTasks');
|
FileLogger().d('Concurrent workers: $runningTasks');
|
||||||
|
|
||||||
await downloadVideo(downloadingVid.first);
|
await downloadVideo(downloadingVid.first);
|
||||||
downloadingVid =
|
downloadingVid =
|
||||||
|
|
@ -108,11 +110,12 @@ class VideosCubit extends Cubit<VideosState> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
debugPrint('All videos downloaded');
|
FileLogger().d('All videos downloaded');
|
||||||
|
FileLogger().d('All videos downloaded');
|
||||||
}
|
}
|
||||||
|
|
||||||
Future moveVideos() async {
|
Future moveVideos() async {
|
||||||
debugPrint('Moving videos to download folder');
|
FileLogger().d('Moving videos to download folder');
|
||||||
final prefs = await SharedPreferences.getInstance();
|
final prefs = await SharedPreferences.getInstance();
|
||||||
Directory defaultDownloadDirectory = await getDownloadDirectory();
|
Directory defaultDownloadDirectory = await getDownloadDirectory();
|
||||||
prefs.get('downloadFolder') ??
|
prefs.get('downloadFolder') ??
|
||||||
|
|
@ -130,8 +133,8 @@ class VideosCubit extends Cubit<VideosState> {
|
||||||
var playlistTitle = video.playlistTitle;
|
var playlistTitle = video.playlistTitle;
|
||||||
await Directory('${downloadDirectory.path}/$playlistTitle')
|
await Directory('${downloadDirectory.path}/$playlistTitle')
|
||||||
.create(recursive: true)
|
.create(recursive: true)
|
||||||
.catchError((e) => debugPrint('Error creating directory: $e'));
|
.catchError((e) => FileLogger().e('Error creating directory: $e'));
|
||||||
debugPrint('Playlist title: $playlistTitle');
|
FileLogger().d('Playlist title: $playlistTitle');
|
||||||
if (playlistTitle.isNotEmpty && playlistTitle != '') {
|
if (playlistTitle.isNotEmpty && playlistTitle != '') {
|
||||||
cleanTitle = '$playlistTitle/$cleanTitle';
|
cleanTitle = '$playlistTitle/$cleanTitle';
|
||||||
}
|
}
|
||||||
|
|
@ -145,19 +148,20 @@ class VideosCubit extends Cubit<VideosState> {
|
||||||
await tmpFile.rename(newFile.path);
|
await tmpFile.rename(newFile.path);
|
||||||
isMoved = true;
|
isMoved = true;
|
||||||
} on FileSystemException catch (e) {
|
} on FileSystemException catch (e) {
|
||||||
debugPrint('Error moving file: $e');
|
FileLogger().e('Error moving file: $e');
|
||||||
await Future.delayed(Duration(seconds: 1));
|
await Future.delayed(Duration(seconds: 1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
await changeStatus(video, 'done');
|
await changeStatus(video, 'done');
|
||||||
await archiveVideo(video.copyWith(status: 'done'));
|
await archiveVideo(video.copyWith(status: 'done'));
|
||||||
debugPrint('File moved to ${newFile.path}');
|
FileLogger().d('File moved to ${newFile.path}');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future convertVideo(Video video) async {
|
Future convertVideo(Video video) async {
|
||||||
converterService = await ConverterService.init();
|
converterService = await ConverterService.init();
|
||||||
debugPrint('Converting ${video.title} to ${video.format.format}');
|
FileLogger().d('Converting ${video.title} to ${video.format.format}');
|
||||||
|
FileLogger().d('Converting ${video.title} to ${video.format.format}');
|
||||||
changeStatus(video, 'converting');
|
changeStatus(video, 'converting');
|
||||||
final shellStream = await converterService.convertFile(video);
|
final shellStream = await converterService.convertFile(video);
|
||||||
var duration = '0.0';
|
var duration = '0.0';
|
||||||
|
|
@ -165,12 +169,13 @@ class VideosCubit extends Cubit<VideosState> {
|
||||||
|
|
||||||
shellStream.listen(
|
shellStream.listen(
|
||||||
(line) {
|
(line) {
|
||||||
debugPrint(line);
|
FileLogger().d(line);
|
||||||
//FFmpeg doesn't return any output for audio conversion
|
//FFmpeg doesn't return any output for audio conversion
|
||||||
if (video.format.extension == "mp3") {
|
if (video.format.extension == "mp3") {
|
||||||
changeStatus(video, 'converted');
|
changeStatus(video, 'converted');
|
||||||
if (!completer.isCompleted) {
|
if (!completer.isCompleted) {
|
||||||
debugPrint('____Conversion audio completed___');
|
FileLogger().d('____Conversion audio completed___');
|
||||||
|
FileLogger().d('Conversion audio completed');
|
||||||
runningTasks--;
|
runningTasks--;
|
||||||
completer.complete();
|
completer.complete();
|
||||||
}
|
}
|
||||||
|
|
@ -179,18 +184,18 @@ class VideosCubit extends Cubit<VideosState> {
|
||||||
var durationString =
|
var durationString =
|
||||||
line.split('Duration: ')[1].split(',')[0].trim();
|
line.split('Duration: ')[1].split(',')[0].trim();
|
||||||
duration = durationString;
|
duration = durationString;
|
||||||
debugPrint('Duration: $duration');
|
FileLogger().d('Duration: $duration');
|
||||||
}
|
}
|
||||||
if (line.contains('out_time_ms=')) {
|
if (line.contains('out_time_ms=')) {
|
||||||
var timeString = line.split('out_time_ms=')[1];
|
var timeString = line.split('out_time_ms=')[1];
|
||||||
var time = timeString;
|
var time = timeString;
|
||||||
debugPrint('Time: $time');
|
FileLogger().d('Time: $time');
|
||||||
changeStatus(video, 'converting $time on $duration');
|
changeStatus(video, 'converting $time on $duration');
|
||||||
}
|
}
|
||||||
if (line.contains('progress=end')) {
|
if (line.contains('progress=end')) {
|
||||||
changeStatus(video, 'converted');
|
changeStatus(video, 'converted');
|
||||||
if (!completer.isCompleted) {
|
if (!completer.isCompleted) {
|
||||||
debugPrint('____Conversion completed___');
|
FileLogger().d('____Conversion completed___');
|
||||||
runningTasks--;
|
runningTasks--;
|
||||||
completer.complete();
|
completer.complete();
|
||||||
}
|
}
|
||||||
|
|
@ -208,7 +213,10 @@ class VideosCubit extends Cubit<VideosState> {
|
||||||
}
|
}
|
||||||
|
|
||||||
Future downloadVideo(Video video) async {
|
Future downloadVideo(Video video) async {
|
||||||
debugPrint(
|
FileLogger().d(
|
||||||
|
'___Downloading ${video.title} in ${video.format} format ${video.filename}____');
|
||||||
|
|
||||||
|
FileLogger().d(
|
||||||
'___Downloading ${video.title} in ${video.format} format ${video.filename}____');
|
'___Downloading ${video.title} in ${video.format} format ${video.filename}____');
|
||||||
final shellStream = await dlService.downloadFile(video);
|
final shellStream = await dlService.downloadFile(video);
|
||||||
var completer = Completer<void>();
|
var completer = Completer<void>();
|
||||||
|
|
@ -228,12 +236,13 @@ class VideosCubit extends Cubit<VideosState> {
|
||||||
changeStatus(video, 'downloaded');
|
changeStatus(video, 'downloaded');
|
||||||
|
|
||||||
if (!completer.isCompleted) {
|
if (!completer.isCompleted) {
|
||||||
debugPrint('____Download completed___');
|
FileLogger().d('____Download completed___');
|
||||||
|
FileLogger().d('Download completed');
|
||||||
runningTasks--;
|
runningTasks--;
|
||||||
completer.complete();
|
completer.complete();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//debugPrint(line);
|
//FileLogger().d(line);
|
||||||
},
|
},
|
||||||
onError: (error) {
|
onError: (error) {
|
||||||
if (!completer.isCompleted) {
|
if (!completer.isCompleted) {
|
||||||
|
|
|
||||||
Binary file not shown.
Loading…
Reference in New Issue