[macos] install script

This commit is contained in:
macOsScaleway-vscode 2024-09-13 10:52:34 +02:00 committed by jscampucci
parent 80ae1621be
commit f8a8f64a14
5 changed files with 39 additions and 9 deletions

View File

@ -41,14 +41,15 @@ class DLServices {
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 {
@ -79,8 +80,7 @@ class DLServices {
var completer = Completer(); var completer = Completer();
try { try {
shell.run(cmd).then((result) { shell.run(cmd).then((result) {
FileLogger().d('FFmpeg is already installed.'); completer.complete(result);
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,12 +96,13 @@ 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'); var result = await futureShell('ffmpeg -version');
FileLogger().d('$result'); //FileLogger().d('$result');
if (result != null && result.exitCode == 0) { if (result != null) {
FileLogger().d('FFmpeg is already installed.'); FileLogger().d('FFmpeg is already installed.');
return; return;
} }
@ -123,6 +124,14 @@ 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();
@ -195,7 +204,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();
@ -210,6 +219,8 @@ 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) {

View File

@ -120,8 +120,8 @@ class VideosCubit extends Cubit<VideosState> {
await moveVideos(); await moveVideos();
final Directory directory = Directory('temp'); //final Directory directory = Directory('temp');
final List<FileSystemEntity> files = directory.listSync(); final List<FileSystemEntity> files = tempDir.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')) {

View File

@ -3,7 +3,7 @@
archiveVersion = 1; archiveVersion = 1;
classes = { classes = {
}; };
objectVersion = 60; objectVersion = 54;
objects = { objects = {
/* Begin PBXAggregateTarget section */ /* Begin PBXAggregateTarget section */

View File

@ -6,4 +6,18 @@ 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()
}
} }

View File

@ -0,0 +1,5 @@
#!/bin/sh
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
brew install ffmpeg
brew install yt-dlp