[macos] install script
This commit is contained in:
parent
80ae1621be
commit
f8a8f64a14
|
|
@ -41,14 +41,15 @@ class DLServices {
|
|||
if (Platform.isWindows) {
|
||||
//checkFFmpeg();
|
||||
assetName = 'yt-dlp.exe';
|
||||
await copyExecutable();
|
||||
} else if (Platform.isLinux) {
|
||||
checkFFmpeg();
|
||||
assetName = 'yt-dlp_linux';
|
||||
} else if (Platform.isMacOS) {
|
||||
checkFFmpeg();
|
||||
assetName = 'yt-dlp_macos';
|
||||
ytDlpPath = "yt-dlp";
|
||||
}
|
||||
await copyExecutable();
|
||||
}
|
||||
|
||||
Future<void> copyExecutable() async {
|
||||
|
|
@ -79,8 +80,7 @@ class DLServices {
|
|||
var completer = Completer();
|
||||
try {
|
||||
shell.run(cmd).then((result) {
|
||||
FileLogger().d('FFmpeg is already installed.');
|
||||
completer.complete(true);
|
||||
completer.complete(result);
|
||||
result.map((e) {
|
||||
FileLogger().d('Analyse result: $e');
|
||||
FileLogger().d('Analyse result: ${e.toString()}');
|
||||
|
|
@ -96,12 +96,13 @@ class DLServices {
|
|||
} catch (error) {
|
||||
completer.completeError(error);
|
||||
}
|
||||
return completer.future;
|
||||
}
|
||||
|
||||
Future<void> checkFFmpeg() async {
|
||||
var result = await futureShell('ffmpeg -version');
|
||||
FileLogger().d('$result');
|
||||
if (result != null && result.exitCode == 0) {
|
||||
//FileLogger().d('$result');
|
||||
if (result != null) {
|
||||
FileLogger().d('FFmpeg is already installed.');
|
||||
return;
|
||||
}
|
||||
|
|
@ -123,6 +124,14 @@ class DLServices {
|
|||
FileLogger().d('Error installing FFmpeg: ${result.stderr}');
|
||||
}
|
||||
} 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']);
|
||||
} else if (Platform.isWindows) {
|
||||
Directory directory = await getApplicationDocumentsDirectory();
|
||||
|
|
@ -195,7 +204,7 @@ class DLServices {
|
|||
Future analyseUrl(String url) async {
|
||||
FileLogger().d('Analyse $url');
|
||||
|
||||
var command = '${url.trim()} -q --flat-playlist -J';
|
||||
var command = '${'"'}${url.trim()}${'"'} -q --flat-playlist -J';
|
||||
|
||||
var shellLinesController = ShellLinesController();
|
||||
var shellErrorController = ShellLinesController();
|
||||
|
|
@ -210,6 +219,8 @@ class DLServices {
|
|||
stderr: shellErrorController.sink,
|
||||
verbose: false);
|
||||
|
||||
FileLogger().d('''$ytDlpPath $command''');
|
||||
|
||||
await shell.run('''
|
||||
$ytDlpPath $command
|
||||
''').then((result) {
|
||||
|
|
|
|||
|
|
@ -120,8 +120,8 @@ class VideosCubit extends Cubit<VideosState> {
|
|||
|
||||
await moveVideos();
|
||||
|
||||
final Directory directory = Directory('temp');
|
||||
final List<FileSystemEntity> files = directory.listSync();
|
||||
//final Directory directory = Directory('temp');
|
||||
final List<FileSystemEntity> files = tempDir.listSync();
|
||||
for (FileSystemEntity file in files) {
|
||||
final String dirFilename = p.basenameWithoutExtension(file.path);
|
||||
if (dirFilename.contains('_tmp')) {
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
archiveVersion = 1;
|
||||
classes = {
|
||||
};
|
||||
objectVersion = 60;
|
||||
objectVersion = 54;
|
||||
objects = {
|
||||
|
||||
/* Begin PBXAggregateTarget section */
|
||||
|
|
|
|||
|
|
@ -6,4 +6,18 @@ class AppDelegate: FlutterAppDelegate {
|
|||
override func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool {
|
||||
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()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
Loading…
Reference in New Issue