From 118f5e661b2afe6ddf0dea22a035e11d996ef00b Mon Sep 17 00:00:00 2001 From: jscampucci Date: Mon, 26 Aug 2024 10:20:18 +0200 Subject: [PATCH] [setup] installer & external ffmpeg --- lib/services/converter.dart | 20 --------- lib/services/download.dart | 6 +-- pubspec.yaml | 2 +- windows-setup-script.iss | 81 +++++++++++++++++++++++++++++++++++++ 4 files changed, 85 insertions(+), 24 deletions(-) create mode 100644 windows-setup-script.iss diff --git a/lib/services/converter.dart b/lib/services/converter.dart index d09879a..a833b2e 100644 --- a/lib/services/converter.dart +++ b/lib/services/converter.dart @@ -24,26 +24,6 @@ class ConverterService { Future _init() async { tempDir = await getTemporaryDirectory(); - if (Platform.isWindows) { - ffmpegPath = 'ffmpeg.exe'; - } else if (Platform.isLinux) { - ffmpegPath = 'ffmpeg'; - } else if (Platform.isMacOS) { - ffmpegPath = 'ffmpeg'; - } - await checkFFmpeg(); - } - - Future 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 getTmpFile(String filename) async { diff --git a/lib/services/download.dart b/lib/services/download.dart index 2fae99c..2595ceb 100644 --- a/lib/services/download.dart +++ b/lib/services/download.dart @@ -39,7 +39,7 @@ class DLServices { Future _init() async { tempDir = await getTemporaryDirectory(); if (Platform.isWindows) { - checkFFmpeg(); + //checkFFmpeg(); assetName = 'yt-dlp.exe'; } else if (Platform.isLinux) { checkFFmpeg(); @@ -101,7 +101,7 @@ class DLServices { Future checkFFmpeg() async { var result = await futureShell('ffmpeg -version'); FileLogger().d('$result'); - if (result.exitCode == 0) { + if (result && result.exitCode == 0) { FileLogger().d('FFmpeg is already installed.'); return; } @@ -159,7 +159,7 @@ class DLServices { var strType = convertedFormats.contains(video.format) ? 'tmp' : 'done'; var command = - '${video.url.trim()} --sub-langs "all,-live_chat" --embed-subs --embed-thumbnail --embed-metadata --progress -o "temp/${video.filename}_$strType.%(ext)s" -f "$formatCmd"'; + '${video.url.trim()} --sub-langs "all,-live_chat" --embed-subs --embed-thumbnail --embed-metadata --progress -o "${tempDir.path}/${video.filename}_$strType.%(ext)s" -f "$formatCmd"'; var shellLinesController = ShellLinesController(); var shellErrorController = ShellLinesController(); diff --git a/pubspec.yaml b/pubspec.yaml index ba38f13..ea585b0 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -3,7 +3,7 @@ description: noTube publish_to: "none" # Remove this line if you wish to publish to pub.dev -version: 0.0.23 +version: 0.0.50 environment: sdk: ">=3.0.0 <4.0.0" diff --git a/windows-setup-script.iss b/windows-setup-script.iss new file mode 100644 index 0000000..7e785e0 --- /dev/null +++ b/windows-setup-script.iss @@ -0,0 +1,81 @@ +; 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.49" +#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 + +[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; \ No newline at end of file