Compare commits
No commits in common. "f4940b189d39081b3eac4c1ccd72c4808c1a2b4e" and "bc4655090f48061fe8d6e2a12114e549aad96403" have entirely different histories.
f4940b189d
...
bc4655090f
Binary file not shown.
|
|
@ -11,12 +11,12 @@ enum Format {
|
||||||
mp3(
|
mp3(
|
||||||
format: 'MP3',
|
format: 'MP3',
|
||||||
ytCmd: 'bestaudio[ext=m4a]/bestaudio[ext=webm]',
|
ytCmd: 'bestaudio[ext=m4a]/bestaudio[ext=webm]',
|
||||||
ffmpegCmd: '-f mp3 -ab 192k -vn',
|
ffmpegCmd: '-f mp3 -loglevel quiet -ab 192k -vn',
|
||||||
extension: 'mp3'),
|
extension: 'mp3'),
|
||||||
mp3HD(
|
mp3HD(
|
||||||
format: 'MP3 HD',
|
format: 'MP3 HD',
|
||||||
ytCmd: 'bestaudio[ext=m4a]/bestaudio[ext=webm]',
|
ytCmd: 'bestaudio[ext=m4a]/bestaudio[ext=webm]',
|
||||||
ffmpegCmd: '-f mp3 -ab 320k -vn',
|
ffmpegCmd: '-f mp3 -loglevel quiet -ab 320k -vn',
|
||||||
extension: 'mp3'),
|
extension: 'mp3'),
|
||||||
mp4(format: 'MP4'),
|
mp4(format: 'MP4'),
|
||||||
mp4HD(
|
mp4HD(
|
||||||
|
|
@ -64,9 +64,3 @@ const convertedFormats = [
|
||||||
Format.tGP,
|
Format.tGP,
|
||||||
Format.flv,
|
Format.flv,
|
||||||
];
|
];
|
||||||
|
|
||||||
const audioFormats = [
|
|
||||||
Format.m4a,
|
|
||||||
Format.mp3,
|
|
||||||
Format.mp3HD,
|
|
||||||
];
|
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,6 @@ class Video extends Equatable {
|
||||||
this.uploadDate = '',
|
this.uploadDate = '',
|
||||||
this.filename = '',
|
this.filename = '',
|
||||||
this.playlistTitle = '',
|
this.playlistTitle = '',
|
||||||
this.destination = '',
|
|
||||||
});
|
});
|
||||||
|
|
||||||
final String id;
|
final String id;
|
||||||
|
|
@ -36,7 +35,6 @@ class Video extends Equatable {
|
||||||
final String uploadDate;
|
final String uploadDate;
|
||||||
final String filename;
|
final String filename;
|
||||||
final String playlistTitle;
|
final String playlistTitle;
|
||||||
final String destination;
|
|
||||||
|
|
||||||
factory Video.fromJson(Map<String, dynamic> json) {
|
factory Video.fromJson(Map<String, dynamic> json) {
|
||||||
return Video(
|
return Video(
|
||||||
|
|
@ -68,7 +66,6 @@ class Video extends Equatable {
|
||||||
String? uploadDate,
|
String? uploadDate,
|
||||||
String? filename,
|
String? filename,
|
||||||
String? playlistTitle,
|
String? playlistTitle,
|
||||||
String? destination,
|
|
||||||
}) {
|
}) {
|
||||||
return Video(
|
return Video(
|
||||||
id: id ?? this.id,
|
id: id ?? this.id,
|
||||||
|
|
@ -85,7 +82,6 @@ class Video extends Equatable {
|
||||||
uploadDate: uploadDate ?? this.uploadDate,
|
uploadDate: uploadDate ?? this.uploadDate,
|
||||||
filename: filename ?? this.filename,
|
filename: filename ?? this.filename,
|
||||||
playlistTitle: playlistTitle ?? this.playlistTitle,
|
playlistTitle: playlistTitle ?? this.playlistTitle,
|
||||||
destination: destination ?? this.destination,
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -104,6 +100,5 @@ class Video extends Equatable {
|
||||||
isParsed,
|
isParsed,
|
||||||
filename,
|
filename,
|
||||||
playlistTitle,
|
playlistTitle,
|
||||||
destination
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,19 @@ class ConverterService {
|
||||||
} else if (Platform.isMacOS) {
|
} else if (Platform.isMacOS) {
|
||||||
ffmpegPath = 'ffmpeg';
|
ffmpegPath = 'ffmpeg';
|
||||||
}
|
}
|
||||||
|
await checkFFmpeg();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> checkFFmpeg() async {
|
||||||
|
try {
|
||||||
|
var result = await Process.run(ffmpegPath, ['-version']);
|
||||||
|
if (result.exitCode == 0) {
|
||||||
|
FileLogger().d('FFmpeg is installed.');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
FileLogger().d('FFmpeg is not installed.');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<File?> getTmpFile(String filename) async {
|
Future<File?> getTmpFile(String filename) async {
|
||||||
|
|
@ -41,7 +54,6 @@ class ConverterService {
|
||||||
FileLogger().d('dirFilename $dirFilename');
|
FileLogger().d('dirFilename $dirFilename');
|
||||||
FileLogger().d('filename $filename');
|
FileLogger().d('filename $filename');
|
||||||
if (dirFilename == '${filename}_tmp') {
|
if (dirFilename == '${filename}_tmp') {
|
||||||
FileLogger().d('Found tmp file ${file.path}');
|
|
||||||
return File(file.path);
|
return File(file.path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -52,39 +64,29 @@ class ConverterService {
|
||||||
FileLogger().d(
|
FileLogger().d(
|
||||||
'____Converting ${video.title} to ${video.format.format} format_____');
|
'____Converting ${video.title} to ${video.format.format} format_____');
|
||||||
|
|
||||||
File tmpFile = File('${tempDir.path}/${video.filename}_tmp.mp4');
|
File tmpFile = File('temp/${video.filename}_tmp.mp4');
|
||||||
var dlFileExist = await tmpFile.exists();
|
|
||||||
FileLogger().d('dlFileExist: $dlFileExist');
|
|
||||||
if (!dlFileExist) {
|
|
||||||
FileLogger()
|
|
||||||
.d('File not found, testing destination ${video.destination}');
|
|
||||||
if (video.destination != '') {
|
|
||||||
tmpFile = File('${tempDir.path}/${video.destination}');
|
|
||||||
}
|
|
||||||
if (!tmpFile.existsSync()) {
|
if (!tmpFile.existsSync()) {
|
||||||
FileLogger().d('File not found, testing temp directory');
|
|
||||||
tmpFile = await getTmpFile(video.filename) ??
|
tmpFile = await getTmpFile(video.filename) ??
|
||||||
File('${tempDir.path}/${video.filename}_tmp.mp4');
|
File('temp/${video.filename}_tmp.mp4');
|
||||||
}
|
}
|
||||||
}
|
|
||||||
FileLogger().d('tmpFile: ${tmpFile.path}');
|
|
||||||
|
|
||||||
File doneFile = File(
|
File doneFile =
|
||||||
'${tempDir.path}/${video.filename}_done.${video.format.extension}');
|
File('temp/${video.filename}_done.${video.format.extension}');
|
||||||
if (doneFile.existsSync()) {
|
if (doneFile.existsSync()) {
|
||||||
FileLogger().d('File already converted');
|
FileLogger().d('File already converted');
|
||||||
return Stream.fromIterable(['progress=end']);
|
return Stream.fromIterable(['progress=end']);
|
||||||
}
|
}
|
||||||
|
|
||||||
var command =
|
var command =
|
||||||
"-i '${tmpFile.path}' ${video.format.ffmpegCmd} '${tempDir.path}/${video.filename}_done.${video.format.extension}'";
|
'-i "${tmpFile.path}" ${video.format.ffmpegCmd} "temp/${video.filename}_done.${video.format.extension}"';
|
||||||
|
|
||||||
var shellLinesController = ShellLinesController();
|
var shellLinesController = ShellLinesController();
|
||||||
var shell = Shell(
|
var shell = Shell(
|
||||||
stdout: shellLinesController.sink, stderr: shellLinesController.sink);
|
stdout: shellLinesController.sink, stderr: shellLinesController.sink);
|
||||||
|
|
||||||
FileLogger().d('Running $ffmpegPath $command');
|
await shell.run('''
|
||||||
await shell.run("$ffmpegPath $command");
|
$ffmpegPath $command
|
||||||
|
''');
|
||||||
|
|
||||||
return shellLinesController.stream;
|
return shellLinesController.stream;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -39,17 +39,16 @@ class DLServices {
|
||||||
Future<void> _init() async {
|
Future<void> _init() async {
|
||||||
tempDir = await getTemporaryDirectory();
|
tempDir = await getTemporaryDirectory();
|
||||||
if (Platform.isWindows) {
|
if (Platform.isWindows) {
|
||||||
//checkFFmpeg();
|
checkFFmpeg();
|
||||||
assetName = 'yt-dlp.exe';
|
assetName = 'yt-dlp.exe';
|
||||||
await copyExecutable();
|
|
||||||
} else if (Platform.isLinux) {
|
} else if (Platform.isLinux) {
|
||||||
checkFFmpeg();
|
checkFFmpeg();
|
||||||
assetName = 'yt-dlp_linux';
|
assetName = 'yt-dlp_linux';
|
||||||
} else if (Platform.isMacOS) {
|
} else if (Platform.isMacOS) {
|
||||||
checkFFmpeg();
|
checkFFmpeg();
|
||||||
assetName = 'yt-dlp_macos';
|
assetName = 'yt-dlp_macos';
|
||||||
ytDlpPath = "yt-dlp";
|
|
||||||
}
|
}
|
||||||
|
await copyExecutable();
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> copyExecutable() async {
|
Future<void> copyExecutable() async {
|
||||||
|
|
@ -80,7 +79,8 @@ class DLServices {
|
||||||
var completer = Completer();
|
var completer = Completer();
|
||||||
try {
|
try {
|
||||||
shell.run(cmd).then((result) {
|
shell.run(cmd).then((result) {
|
||||||
completer.complete(result);
|
FileLogger().d('FFmpeg is already installed.');
|
||||||
|
completer.complete(true);
|
||||||
result.map((e) {
|
result.map((e) {
|
||||||
FileLogger().d('Analyse result: $e');
|
FileLogger().d('Analyse result: $e');
|
||||||
FileLogger().d('Analyse result: ${e.toString()}');
|
FileLogger().d('Analyse result: ${e.toString()}');
|
||||||
|
|
@ -96,18 +96,19 @@ class DLServices {
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
completer.completeError(error);
|
completer.completeError(error);
|
||||||
}
|
}
|
||||||
return completer.future;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> checkFFmpeg() async {
|
Future<void> checkFFmpeg() async {
|
||||||
var result = await futureShell('ffmpeg -version');
|
try {
|
||||||
//FileLogger().d('$result');
|
var result = await Process.run('ffmpeg', ['-version']);
|
||||||
if (result != null) {
|
FileLogger().d('$result');
|
||||||
|
if (result.exitCode == 0) {
|
||||||
FileLogger().d('FFmpeg is already installed.');
|
FileLogger().d('FFmpeg is already installed.');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
FileLogger().d('RESULTS: $result');
|
||||||
|
|
||||||
FileLogger().d('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']);
|
||||||
|
|
@ -124,14 +125,6 @@ class DLServices {
|
||||||
FileLogger().d('Error installing FFmpeg: ${result.stderr}');
|
FileLogger().d('Error installing FFmpeg: ${result.stderr}');
|
||||||
}
|
}
|
||||||
} else if (Platform.isMacOS) {
|
} else if (Platform.isMacOS) {
|
||||||
var homebrewTest = await futureShell("brew --version");
|
|
||||||
FileLogger().d('$homebrewTest');
|
|
||||||
if (result == null) {
|
|
||||||
FileLogger().d('Install homebrew');
|
|
||||||
var installHomebrew = await futureShell('/bin/bash -c "\$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"');
|
|
||||||
FileLogger().d('$installHomebrew');
|
|
||||||
}
|
|
||||||
|
|
||||||
result = await Process.run('brew', ['install', 'ffmpeg']);
|
result = await Process.run('brew', ['install', 'ffmpeg']);
|
||||||
} else if (Platform.isWindows) {
|
} else if (Platform.isWindows) {
|
||||||
Directory directory = await getApplicationDocumentsDirectory();
|
Directory directory = await getApplicationDocumentsDirectory();
|
||||||
|
|
@ -160,17 +153,16 @@ class DLServices {
|
||||||
Format.values.firstWhere((e) => e.format == video.format.format).ytCmd;
|
Format.values.firstWhere((e) => e.format == video.format.format).ytCmd;
|
||||||
FileLogger().d('Format code: $formatCmd');
|
FileLogger().d('Format code: $formatCmd');
|
||||||
|
|
||||||
File doneFile = File('${tempDir.path}/${video.filename}_tmp.mp4');
|
File doneFile = File('temp/${video.filename}_tmp.mp4');
|
||||||
if (doneFile.existsSync()) {
|
if (doneFile.existsSync()) {
|
||||||
FileLogger().d('File already downloaded');
|
FileLogger().d('File already downloaded');
|
||||||
return Stream.fromIterable(['[EmbedThumbnail]']);
|
return Stream.fromIterable(['[EmbedThumbnail]']);
|
||||||
}
|
}
|
||||||
|
|
||||||
var strType = convertedFormats.contains(video.format) ? 'tmp' : 'done';
|
var strType = convertedFormats.contains(video.format) ? 'tmp' : 'done';
|
||||||
var isAudio = audioFormats.contains(video.format);
|
|
||||||
var command =
|
var command =
|
||||||
'${video.url.trim()}${isAudio ? '' : '--embed-subs --embed-thumbnail --embed-metadata'} --progress -o "${tempDir.path}/${video.filename}_$strType.%(ext)s" -f "$formatCmd"';
|
'${video.url.trim()} --sub-langs "all,-live_chat" --embed-subs --embed-thumbnail --embed-metadata --progress -o "temp/${video.filename}_$strType.%(ext)s" -f "$formatCmd"';
|
||||||
//--sub-langs "all,-live_chat"
|
|
||||||
var shellLinesController = ShellLinesController();
|
var shellLinesController = ShellLinesController();
|
||||||
var shellErrorController = ShellLinesController();
|
var shellErrorController = ShellLinesController();
|
||||||
|
|
||||||
|
|
@ -194,6 +186,7 @@ class DLServices {
|
||||||
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 {
|
||||||
|
FileLogger().d('Error: $error');
|
||||||
FileLogger().e('Error: $error');
|
FileLogger().e('Error: $error');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -204,7 +197,7 @@ class DLServices {
|
||||||
Future analyseUrl(String url) async {
|
Future analyseUrl(String url) async {
|
||||||
FileLogger().d('Analyse $url');
|
FileLogger().d('Analyse $url');
|
||||||
|
|
||||||
var command = '${'"'}${url.trim()}${'"'} -q --flat-playlist -J';
|
var command = '${url.trim()} -q --flat-playlist -J';
|
||||||
|
|
||||||
var shellLinesController = ShellLinesController();
|
var shellLinesController = ShellLinesController();
|
||||||
var shellErrorController = ShellLinesController();
|
var shellErrorController = ShellLinesController();
|
||||||
|
|
@ -219,8 +212,6 @@ class DLServices {
|
||||||
stderr: shellErrorController.sink,
|
stderr: shellErrorController.sink,
|
||||||
verbose: false);
|
verbose: false);
|
||||||
|
|
||||||
FileLogger().d('''$ytDlpPath $command''');
|
|
||||||
|
|
||||||
await shell.run('''
|
await shell.run('''
|
||||||
$ytDlpPath $command
|
$ytDlpPath $command
|
||||||
''').then((result) {
|
''').then((result) {
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,6 @@ class FileLogger {
|
||||||
static final FileLogger _instance = FileLogger._internal();
|
static final FileLogger _instance = FileLogger._internal();
|
||||||
late Logger _logger;
|
late Logger _logger;
|
||||||
late File _logFile;
|
late File _logFile;
|
||||||
late Directory tempDir;
|
|
||||||
|
|
||||||
factory FileLogger() {
|
factory FileLogger() {
|
||||||
return _instance;
|
return _instance;
|
||||||
|
|
@ -16,8 +15,7 @@ class FileLogger {
|
||||||
FileLogger._internal();
|
FileLogger._internal();
|
||||||
|
|
||||||
Future<void> init() async {
|
Future<void> init() async {
|
||||||
tempDir = await getTemporaryDirectory();
|
_logFile = File('apps_logs.txt');
|
||||||
_logFile = File('${tempDir.path}/apps_logs.txt');
|
|
||||||
|
|
||||||
_logger = Logger(
|
_logger = Logger(
|
||||||
filter: ProductionFilter(),
|
filter: ProductionFilter(),
|
||||||
|
|
@ -32,7 +30,6 @@ class FileLogger {
|
||||||
}
|
}
|
||||||
|
|
||||||
void i(String message) {
|
void i(String message) {
|
||||||
debugPrint(message);
|
|
||||||
_logger.i(message);
|
_logger.i(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -42,7 +39,6 @@ class FileLogger {
|
||||||
}
|
}
|
||||||
|
|
||||||
void e(String message, [dynamic error, StackTrace? stackTrace]) {
|
void e(String message, [dynamic error, StackTrace? stackTrace]) {
|
||||||
debugPrint(message);
|
|
||||||
_logger.e(message, error: error, stackTrace: stackTrace);
|
_logger.e(message, error: error, stackTrace: stackTrace);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,6 @@ import 'package:notube/models/video.dart';
|
||||||
import 'package:notube/services/converter.dart';
|
import 'package:notube/services/converter.dart';
|
||||||
import 'package:notube/services/download.dart';
|
import 'package:notube/services/download.dart';
|
||||||
import 'package:notube/constants.dart';
|
import 'package:notube/constants.dart';
|
||||||
import 'package:path_provider/path_provider.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;
|
||||||
|
|
@ -20,7 +19,6 @@ class VideosCubit extends Cubit<VideosState> {
|
||||||
|
|
||||||
late DLServices dlService;
|
late DLServices dlService;
|
||||||
late ConverterService converterService;
|
late ConverterService converterService;
|
||||||
late Directory tempDir;
|
|
||||||
|
|
||||||
Iterable<Video> downloadingVid = [];
|
Iterable<Video> downloadingVid = [];
|
||||||
|
|
||||||
|
|
@ -49,22 +47,6 @@ class VideosCubit extends Cubit<VideosState> {
|
||||||
return completer.future;
|
return completer.future;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future changeDestination(Video video, String destination) async {
|
|
||||||
var completer = Completer<void>();
|
|
||||||
var tmpVideoList = state.videoList.toList();
|
|
||||||
int index = tmpVideoList.indexWhere((v) => v.id == video.id);
|
|
||||||
|
|
||||||
if (index != -1) {
|
|
||||||
tmpVideoList[index] = video.copyWith(destination: destination);
|
|
||||||
emit(VideosState(videoList: tmpVideoList));
|
|
||||||
completer.complete(tmpVideoList[index]);
|
|
||||||
} else {
|
|
||||||
FileLogger().d('Video not found in the list');
|
|
||||||
completer.completeError('Video not found in the list');
|
|
||||||
}
|
|
||||||
return completer.future;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setGlobalStatus(String status) {
|
void setGlobalStatus(String status) {
|
||||||
emit(VideosState(status: status));
|
emit(VideosState(status: status));
|
||||||
}
|
}
|
||||||
|
|
@ -89,7 +71,6 @@ class VideosCubit extends Cubit<VideosState> {
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> startConverter() async {
|
Future<void> startConverter() async {
|
||||||
tempDir = await getTemporaryDirectory();
|
|
||||||
var videosToConvert = state.videoList.where((video) =>
|
var videosToConvert = state.videoList.where((video) =>
|
||||||
video.status == 'downloaded' &&
|
video.status == 'downloaded' &&
|
||||||
convertedFormats.contains(video.format));
|
convertedFormats.contains(video.format));
|
||||||
|
|
@ -120,8 +101,8 @@ class VideosCubit extends Cubit<VideosState> {
|
||||||
|
|
||||||
await moveVideos();
|
await moveVideos();
|
||||||
|
|
||||||
//final Directory directory = Directory('temp');
|
final Directory directory = Directory('temp');
|
||||||
final List<FileSystemEntity> files = tempDir.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);
|
||||||
if (dirFilename.contains('_tmp')) {
|
if (dirFilename.contains('_tmp')) {
|
||||||
|
|
@ -146,15 +127,15 @@ class VideosCubit extends Cubit<VideosState> {
|
||||||
for (Video video in state.videoList.where((video) =>
|
for (Video video in state.videoList.where((video) =>
|
||||||
video.status == 'downloaded' || video.status == 'converted')) {
|
video.status == 'downloaded' || video.status == 'converted')) {
|
||||||
var cleanTitle = video.title.replaceAll(RegExp(r'[^\w\s]+'), '');
|
var cleanTitle = video.title.replaceAll(RegExp(r'[^\w\s]+'), '');
|
||||||
final tmpFile = File(
|
final tmpFile =
|
||||||
'${tempDir.path}/${video.filename}_done.${video.format.extension}');
|
File('temp/${video.filename}_done.${video.format.extension}');
|
||||||
|
|
||||||
var playlistTitle = video.playlistTitle;
|
var playlistTitle = video.playlistTitle;
|
||||||
if (playlistTitle.isNotEmpty && playlistTitle != '') {
|
|
||||||
await Directory('${downloadDirectory.path}/$playlistTitle')
|
await Directory('${downloadDirectory.path}/$playlistTitle')
|
||||||
.create(recursive: true)
|
.create(recursive: true)
|
||||||
.catchError((e) => FileLogger().e('Error creating directory: $e'));
|
.catchError((e) => FileLogger().e('Error creating directory: $e'));
|
||||||
FileLogger().d('Playlist title: $playlistTitle');
|
FileLogger().d('Playlist title: $playlistTitle');
|
||||||
|
if (playlistTitle.isNotEmpty && playlistTitle != '') {
|
||||||
cleanTitle = '$playlistTitle/$cleanTitle';
|
cleanTitle = '$playlistTitle/$cleanTitle';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -164,7 +145,6 @@ class VideosCubit extends Cubit<VideosState> {
|
||||||
var isMoved = false;
|
var isMoved = false;
|
||||||
while (!isMoved) {
|
while (!isMoved) {
|
||||||
try {
|
try {
|
||||||
FileLogger().d('Moving ${tmpFile.path} to ${newFile.path}');
|
|
||||||
await tmpFile.rename(newFile.path);
|
await tmpFile.rename(newFile.path);
|
||||||
isMoved = true;
|
isMoved = true;
|
||||||
} on FileSystemException catch (e) {
|
} on FileSystemException catch (e) {
|
||||||
|
|
@ -172,10 +152,9 @@ class VideosCubit extends Cubit<VideosState> {
|
||||||
await Future.delayed(Duration(seconds: 1));
|
await Future.delayed(Duration(seconds: 1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FileLogger().d('File moved to ${newFile.path}');
|
|
||||||
await changeStatus(video, 'done');
|
await changeStatus(video, 'done');
|
||||||
await archiveVideo(video.copyWith(status: 'done'));
|
await archiveVideo(video.copyWith(status: 'done'));
|
||||||
|
FileLogger().d('File moved to ${newFile.path}');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -237,50 +216,21 @@ class VideosCubit extends Cubit<VideosState> {
|
||||||
FileLogger().d(
|
FileLogger().d(
|
||||||
'___Downloading ${video.title} in ${video.format} format ${video.filename}____');
|
'___Downloading ${video.title} in ${video.format} format ${video.filename}____');
|
||||||
|
|
||||||
|
FileLogger().d(
|
||||||
|
'___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>();
|
||||||
|
|
||||||
shellStream.listen(
|
shellStream.listen(
|
||||||
(line) async {
|
(line) {
|
||||||
if (line.contains('[download]') &&
|
if (line.contains('[download]') &&
|
||||||
line.contains('of') &&
|
line.contains('of') &&
|
||||||
line.contains('%')) {
|
line.contains('%')) {
|
||||||
var percentString =
|
var percentString =
|
||||||
line.split('[download]')[1].split(' of')[0].split('%')[0].trim();
|
line.split('[download]')[1].split(' of')[0].split('%')[0].trim();
|
||||||
var percent = percentString == null ? 0 : double.parse(percentString);
|
var percent = percentString == null ? 0 : double.parse(percentString);
|
||||||
|
|
||||||
if (audioFormats.contains(video.format) && percent == 100) {
|
|
||||||
changeStatus(video, 'downloaded');
|
|
||||||
if (!completer.isCompleted) {
|
|
||||||
FileLogger().d('____Download completed___');
|
|
||||||
FileLogger().d('Download completed');
|
|
||||||
runningTasks--;
|
|
||||||
completer.complete();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
changeStatus(video, 'downloading $percent%');
|
changeStatus(video, 'downloading $percent%');
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (line.contains('Destination:')) {
|
|
||||||
FileLogger().w('Destination: $line');
|
|
||||||
var destination =
|
|
||||||
line.split('Destination:')[1].trim().split(RegExp(r'[\\/]')).last;
|
|
||||||
video = await changeDestination(video, destination);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (line.contains('has already been downloaded')) {
|
|
||||||
FileLogger().w('Destination: $line');
|
|
||||||
RegExp regExp = RegExp(r'\\([^\\]+?\.[^\\]+?)\s');
|
|
||||||
Match? match = regExp.firstMatch(line);
|
|
||||||
if (match != null) {
|
|
||||||
String destination = match.group(1)!;
|
|
||||||
FileLogger().w('Destination: $destination');
|
|
||||||
video = await changeDestination(video, destination);
|
|
||||||
} else {
|
|
||||||
FileLogger().w('Destination: $line');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (line.contains('[EmbedThumbnail]')) {
|
if (line.contains('[EmbedThumbnail]')) {
|
||||||
changeStatus(video, 'downloaded');
|
changeStatus(video, 'downloaded');
|
||||||
|
|
@ -292,7 +242,7 @@ class VideosCubit extends Cubit<VideosState> {
|
||||||
completer.complete();
|
completer.complete();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
FileLogger().d(line);
|
//FileLogger().d(line);
|
||||||
},
|
},
|
||||||
onError: (error) {
|
onError: (error) {
|
||||||
if (!completer.isCompleted) {
|
if (!completer.isCompleted) {
|
||||||
|
|
|
||||||
|
|
@ -283,7 +283,7 @@
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
buildConfigurationList = 33CC10E82044A3C60003C045 /* Build configuration list for PBXProject "Runner" */;
|
buildConfigurationList = 33CC10E82044A3C60003C045 /* Build configuration list for PBXProject "Runner" */;
|
||||||
compatibilityVersion = "Xcode 15.0";
|
compatibilityVersion = "Xcode 9.3";
|
||||||
developmentRegion = en;
|
developmentRegion = en;
|
||||||
hasScannedForEncodings = 0;
|
hasScannedForEncodings = 0;
|
||||||
knownRegions = (
|
knownRegions = (
|
||||||
|
|
|
||||||
|
|
@ -1,23 +1,9 @@
|
||||||
import Cocoa
|
import Cocoa
|
||||||
import FlutterMacOS
|
import FlutterMacOS
|
||||||
|
|
||||||
@main
|
@NSApplicationMain
|
||||||
class AppDelegate: FlutterAppDelegate {
|
class AppDelegate: FlutterAppDelegate {
|
||||||
override func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool {
|
override func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
override func applicationDidFinishLaunching(_ notification: Notification) {
|
|
||||||
super.applicationDidFinishLaunching(notification)
|
|
||||||
runInstallScript()
|
|
||||||
}
|
|
||||||
|
|
||||||
func runInstallScript() {
|
|
||||||
let scriptPath = Bundle.main.path(forResource: "notube-macos-install", ofType: "sh")
|
|
||||||
let task = Process()
|
|
||||||
task.launchPath = "/bin/bash"
|
|
||||||
task.arguments = [scriptPath!]
|
|
||||||
task.launch()
|
|
||||||
task.waitUntilExit()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,31 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
# Check if Homebrew is installed
|
|
||||||
if ! command -v brew &> /dev/null
|
|
||||||
then
|
|
||||||
echo "Homebrew not found. Installing Homebrew..."
|
|
||||||
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
|
|
||||||
else
|
|
||||||
echo "Homebrew is already installed."
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "export PATH=/opt/homebrew/bin:$PATH" >> ~/.bash_profile && source ~/.bash_profile
|
|
||||||
|
|
||||||
|
|
||||||
# Install FFmpeg
|
|
||||||
if ! command -v ffmpeg &> /dev/null
|
|
||||||
then
|
|
||||||
echo "FFmpeg not found. Installing FFmpeg..."
|
|
||||||
brew install ffmpeg
|
|
||||||
else
|
|
||||||
echo "FFmpeg is already installed."
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Install yt-dlp
|
|
||||||
if ! command -v yt-dlp &> /dev/null
|
|
||||||
then
|
|
||||||
echo "yt-dlp not found. Installing yt-dlp..."
|
|
||||||
brew install yt-dlp
|
|
||||||
else
|
|
||||||
echo "yt-dlp is already installed."
|
|
||||||
fi
|
|
||||||
|
|
@ -854,10 +854,10 @@ packages:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: vm_service
|
name: vm_service
|
||||||
sha256: "5c5f338a667b4c644744b661f309fb8080bb94b18a7e91ef1dbd343bed00ed6d"
|
sha256: f652077d0bdf60abe4c1f6377448e8655008eef28f128bc023f7b5e8dfeb48fc
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "14.2.5"
|
version: "14.2.4"
|
||||||
web:
|
web:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ description: noTube
|
||||||
|
|
||||||
publish_to: "none" # Remove this line if you wish to publish to pub.dev
|
publish_to: "none" # Remove this line if you wish to publish to pub.dev
|
||||||
|
|
||||||
version: 0.0.50
|
version: 0.0.23
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: ">=3.0.0 <4.0.0"
|
sdk: ">=3.0.0 <4.0.0"
|
||||||
|
|
|
||||||
|
|
@ -1,84 +0,0 @@
|
||||||
; Script generated by the Inno Setup Script Wizard.
|
|
||||||
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
|
|
||||||
|
|
||||||
#define MyAppName "noTube"
|
|
||||||
#define MyAppVersion "0.50"
|
|
||||||
#define MyAppPublisher "noTube"
|
|
||||||
#define MyAppURL "https://notube.lol/"
|
|
||||||
#define MyAppExeName "notube.exe"
|
|
||||||
|
|
||||||
[Setup]
|
|
||||||
; NOTE: The value of AppId uniquely identifies this application. Do not use the same AppId value in installers for other applications.
|
|
||||||
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
|
|
||||||
AppId={{C715B92D-00E4-48BD-954F-202DB362ED4C}
|
|
||||||
AppName={#MyAppName}
|
|
||||||
AppVersion={#MyAppVersion}
|
|
||||||
;AppVerName={#MyAppName} {#MyAppVersion}
|
|
||||||
AppPublisher={#MyAppPublisher}
|
|
||||||
AppPublisherURL={#MyAppURL}
|
|
||||||
AppSupportURL={#MyAppURL}
|
|
||||||
AppUpdatesURL={#MyAppURL}
|
|
||||||
DefaultDirName={autopf}\{#MyAppName}
|
|
||||||
; "ArchitecturesAllowed=x64compatible" specifies that Setup cannot run
|
|
||||||
; on anything but x64 and Windows 11 on Arm.
|
|
||||||
ArchitecturesAllowed=x64compatible
|
|
||||||
; "ArchitecturesInstallIn64BitMode=x64compatible" requests that the
|
|
||||||
; install be done in "64-bit mode" on x64 or Windows 11 on Arm,
|
|
||||||
; meaning it should use the native 64-bit Program Files directory and
|
|
||||||
; the 64-bit view of the registry.
|
|
||||||
ArchitecturesInstallIn64BitMode=x64compatible
|
|
||||||
DisableProgramGroupPage=yes
|
|
||||||
; Uncomment the following line to run in non administrative install mode (install for current user only.)
|
|
||||||
;PrivilegesRequired=lowest
|
|
||||||
OutputDir=C:\Users\Skapdat\Oth\buildNoTube
|
|
||||||
OutputBaseFilename=notube-windows
|
|
||||||
SetupIconFile=C:\Users\Skapdat\Projets\Dev\NoTube-Flutter\notube\build\windows\x64\runner\Release\data\flutter_assets\assets\images\favicon.ico
|
|
||||||
Compression=lzma
|
|
||||||
SolidCompression=yes
|
|
||||||
WizardStyle=modern
|
|
||||||
ChangesEnvironment=yes
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
[Languages]
|
|
||||||
Name: "english"; MessagesFile: "compiler:Default.isl"
|
|
||||||
Name: "french"; MessagesFile: "compiler:Languages\French.isl"
|
|
||||||
|
|
||||||
[Tasks]
|
|
||||||
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked
|
|
||||||
|
|
||||||
[Files]
|
|
||||||
Source: "C:\Users\Skapdat\Projets\Dev\NoTube-Flutter\notube\build\windows\x64\runner\Release\{#MyAppExeName}"; DestDir: "{app}"; Flags: ignoreversion
|
|
||||||
Source: "C:\Users\Skapdat\Projets\Dev\NoTube-Flutter\notube\build\windows\x64\runner\Release\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
|
|
||||||
; NOTE: Don't use "Flags: ignoreversion" on any shared system files
|
|
||||||
|
|
||||||
[Icons]
|
|
||||||
Name: "{autoprograms}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
|
|
||||||
Name: "{autodesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon
|
|
||||||
|
|
||||||
[Registry]
|
|
||||||
Root: HKLM; Subkey: "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"; \
|
|
||||||
ValueType: expandsz; ValueName: "Path"; ValueData: "{olddata};{app}\data\flutter_assets\assets\executable"; \
|
|
||||||
Check: NeedsAddPath('{app}\data\flutter_assets\assets\executable')
|
|
||||||
|
|
||||||
[Run]
|
|
||||||
Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent
|
|
||||||
|
|
||||||
|
|
||||||
[Code]
|
|
||||||
|
|
||||||
function NeedsAddPath(Param: string): boolean;
|
|
||||||
var
|
|
||||||
OrigPath: string;
|
|
||||||
begin
|
|
||||||
if not RegQueryStringValue(HKEY_LOCAL_MACHINE,
|
|
||||||
'SYSTEM\CurrentControlSet\Control\Session Manager\Environment',
|
|
||||||
'Path', OrigPath)
|
|
||||||
then begin
|
|
||||||
Result := True;
|
|
||||||
exit;
|
|
||||||
end;
|
|
||||||
{ look for the path with leading and trailing semicolon }
|
|
||||||
{ Pos() returns 0 if not found }
|
|
||||||
Result := Pos(';' + Param + ';', ';' + OrigPath + ';') = 0;
|
|
||||||
end;
|
|
||||||
Loading…
Reference in New Issue