Compare commits
38 Commits
v0.1.0-bet
...
v0.5.0-bet
69
.github/workflows/release.yml
vendored
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- 'v*.*.*-*'
|
||||||
|
|
||||||
|
name: 🚀 Release on GitHub
|
||||||
|
jobs:
|
||||||
|
release:
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
- platform: 'macos-latest'
|
||||||
|
args: '--target aarch64-apple-darwin'
|
||||||
|
arch: 'aarch64-apple-darwin'
|
||||||
|
- platform: 'macos-latest'
|
||||||
|
args: '--target x86_64-apple-darwin'
|
||||||
|
arch: 'x86_64-apple-darwin'
|
||||||
|
- platform: 'ubuntu-22.04'
|
||||||
|
args: ''
|
||||||
|
arch: ''
|
||||||
|
- platform: 'windows-latest'
|
||||||
|
args: ''
|
||||||
|
arch: ''
|
||||||
|
|
||||||
|
runs-on: ${{ matrix.platform }}
|
||||||
|
steps:
|
||||||
|
- name: 🚚 Checkout repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: 🛠️ Install dependencies
|
||||||
|
if: matrix.platform == 'ubuntu-22.04'
|
||||||
|
run: |
|
||||||
|
sudo apt-get update
|
||||||
|
sudo apt-get install -y libwebkit2gtk-4.0-dev libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf
|
||||||
|
|
||||||
|
- name: 📦 Setup node
|
||||||
|
uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: '22.11.0'
|
||||||
|
cache: 'npm'
|
||||||
|
|
||||||
|
- name: 🛠️ install Rust stable
|
||||||
|
uses: dtolnay/rust-toolchain@stable
|
||||||
|
with:
|
||||||
|
targets: ${{ matrix.platform == 'macos-latest' && 'aarch64-apple-darwin,x86_64-apple-darwin' || '' }}
|
||||||
|
|
||||||
|
- name: 🛠️ Rust cache
|
||||||
|
uses: swatinem/rust-cache@v2
|
||||||
|
with:
|
||||||
|
workspaces: './src-tauri -> target'
|
||||||
|
|
||||||
|
- name: 🛠️ Install frontend dependencies
|
||||||
|
run: npm install
|
||||||
|
|
||||||
|
- name: 🚀 Build and publish
|
||||||
|
uses: tauri-apps/tauri-action@v0
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
TARGET_ARCH: ${{ matrix.arch }}
|
||||||
|
with:
|
||||||
|
tagName: ${{ github.ref_name }}
|
||||||
|
releaseName: ${{ github.event.repository.name }}-${{ github.ref_name }}
|
||||||
|
releaseBody: 'See the assets to download this version and install.'
|
||||||
|
releaseDraft: true
|
||||||
|
prerelease: false
|
||||||
|
args: ${{ matrix.args }}
|
||||||
11
.gitignore
vendored
@@ -23,9 +23,14 @@ dist-ssr
|
|||||||
*.sln
|
*.sln
|
||||||
*.sw?
|
*.sw?
|
||||||
|
|
||||||
# Executables
|
# Executables and manifests
|
||||||
pytubepp-helper-msghost.exe
|
src-tauri/pytubepp-helper-msghost.exe
|
||||||
pytubepp-helper-autostart.exe
|
src-tauri/pytubepp-helper-autostart.exe
|
||||||
|
src-tauri/pytubepp-helper-msghost.json
|
||||||
|
src-tauri/pytubepp-helper-msghost-moz.json
|
||||||
|
src-tauri/pytubepp-helper-msghost
|
||||||
|
src-tauri/pytubepp-helper-autostart
|
||||||
|
src-tauri/pytubepp-helper-autostart.plist
|
||||||
|
|
||||||
# Certificate files
|
# Certificate files
|
||||||
certificate.pfx
|
certificate.pfx
|
||||||
|
|||||||
80
README.md
@@ -5,22 +5,22 @@
|
|||||||
A Helper App for PytubePP Extension/Addon to Communicate with Pytube Post Processor CLI
|
A Helper App for PytubePP Extension/Addon to Communicate with Pytube Post Processor CLI
|
||||||
|
|
||||||
[](https://github.com/neosubhamoy/pytubepp-helper)
|
[](https://github.com/neosubhamoy/pytubepp-helper)
|
||||||
[](https://github.com/neosubhamoy/pytubepp-helper)
|
[](https://github.com/neosubhamoy/pytubepp-helper)
|
||||||
[](https://github.com/neosubhamoy/pytubepp-helper)
|
[](https://github.com/neosubhamoy/pytubepp-helper)
|
||||||
|
|
||||||
#### **🌟 Loved this Project? Don't forget to Star this Repo to show us your appreciation !!**
|
#### **🌟 Loved this Project? Don't forget to Star this Repo to show us your appreciation !!**
|
||||||
|
|
||||||
### 💻 Supported Platforms
|
### 💻 Supported Platforms
|
||||||
- Windows 10 (v1803 or later)/11
|
- Windows 10 (v1803 or later) / 11
|
||||||
- Linux (Coming Soon)
|
- Linux (Debian / RHEL base) (GNOME only)
|
||||||
- MacOS (Maybe later :)
|
- MacOS (v10.13 or later)
|
||||||
|
|
||||||
### 📎 Pre-Requirements
|
### 📎 Pre-Requirements
|
||||||
|
|
||||||
- [Python (>3.8)](https://www.python.org/downloads/)
|
- [Python](https://www.python.org/downloads/) (>3.8)
|
||||||
- [FFmpeg](https://www.ffmpeg.org)
|
- [FFmpeg](https://www.ffmpeg.org)
|
||||||
- [PytubePP](https://github.com/neosubhamoy/pytubepp)
|
- [PytubePP](https://github.com/neosubhamoy/pytubepp)
|
||||||
* These requirements can be installed using PytubePP Helper (post installation) if [WinGet](https://learn.microsoft.com/en-us/windows/package-manager/winget/#install-winget) is installed in your system.
|
* These requirements can be installed using PytubePP Helper (post installation) if [WinGet](https://learn.microsoft.com/en-us/windows/package-manager/winget/#install-winget) (for Windows users) / [Homebrew](https://brew.sh) (for MacOS users) is installed in your system
|
||||||
|
|
||||||
### ⬇️ Download and Installation
|
### ⬇️ Download and Installation
|
||||||
|
|
||||||
@@ -28,24 +28,61 @@ A Helper App for PytubePP Extension/Addon to Communicate with Pytube Post Proces
|
|||||||
|
|
||||||
| Arch\OS | Windows | Linux | MacOS |
|
| Arch\OS | Windows | Linux | MacOS |
|
||||||
| :---- | :---- | :---- | :---- |
|
| :---- | :---- | :---- | :---- |
|
||||||
| x64 | [Download](https://github.com/neosubhamoy/pytubepp-helper/releases/latest) | N/A | N/A |
|
| x64 | ✅ [Download](https://github.com/neosubhamoy/pytubepp-helper/releases/latest) | ✅ [Download](https://github.com/neosubhamoy/pytubepp-helper/releases/latest) | ✅ [Download](https://github.com/neosubhamoy/pytubepp-helper/releases/latest) |
|
||||||
| x86 | N/A | N/A | N/A |
|
| ARM | ❌ N/A | ❌ N/A | ✅ [Download](https://github.com/neosubhamoy/pytubepp-helper/releases/latest) |
|
||||||
| ARM | N/A | N/A | N/A |
|
|
||||||
|
|
||||||
* Windows:
|
* **>> WINDOWS:**
|
||||||
|
|
||||||
2. If you don't have any Pre-Requirements installed first install [WinGet](https://learn.microsoft.com/en-us/windows/package-manager/winget/#install-winget). Then restart your Computer.
|
1. If you don't have any Pre-Requirements installed first install [WinGet](https://learn.microsoft.com/en-us/windows/package-manager/winget/#install-winget). Then restart your Computer.
|
||||||
|
|
||||||
3. Now open PytubePP Helper (from system tray not from start menu or shotcut) you will see (blue) 'install' buttons. First click on the install button on the right side of 'Python', a cmd window will popup to install Python. after the installation is finished then close the cmd window and now install 'FFmpeg' by clicking on the next install button. after the installation is finished close the cmd window and restart your Computer.
|
2. Now open PytubePP Helper (from system tray not from start menu or shotcut) you will see (blue) 'install' buttons. First click on the install button on the right side of 'Python', a cmd window will popup to install Python. after the installation is finished then close the cmd window and now install 'FFmpeg' by clicking on the next install button. after the installation is finished close the cmd window and restart your Computer.
|
||||||
|
|
||||||
4. Again open PytubePP Helper (from system tray not from start menu or shotcut) and install PytubePP at last. after it finishes you can close the cmd window. Now click on the refresh button and you will see the 'Ready' message. Then close PytubePP Helper
|
3. Again open PytubePP Helper and install PytubePP at the end. after it finishes you can close the cmd window. Now click on the 'Refresh' button and you will see the 'Ready' message. Then close PytubePP Helper
|
||||||
|
|
||||||
5. You can now add the [PytubePP Extension](https://github.com/neosubhamoy/pytubepp-extension) in your browser and it should work properly with [PytubePP](https://github.com/neosubhamoy/pytubepp)
|
4. You can now add the [PytubePP Extension](https://github.com/neosubhamoy/pytubepp-extension) in your browser and it should work properly with [PytubePP](https://github.com/neosubhamoy/pytubepp)
|
||||||
|
|
||||||
6. PRO TIPS:
|
5. Pro Tips:
|
||||||
- Make sure PytubePP Helper is always running in the background (system tray) otherwise PytubePP Extension will not work properly.
|
- Make sure PytubePP Helper is always running in the background (system tray) otherwise PytubePP Extension will not work properly.
|
||||||
- Always open PytubePP Helper from system tray if it's already running. if you open PytubePP Helper from start menu or shotcut when PytubePP Helper is already running in system tray then two instances of PytubePP Helper will run on the same time which may cause the app to malfunction!
|
- PytubePP Helper by default always autostarts itself when Windows starts. Make sure autostart is not disabled for PytubePP Helper in Task Manager (Startup apps tab)
|
||||||
- PytubePP Helper by default always autostarts itself when Windows starts. Make sure autosart is not disabled for PytubePP Helper in Task Manager (Startup apps tab)
|
|
||||||
|
* **>> LINUX:**
|
||||||
|
|
||||||
|
> NOTE: Not all Debian / RHEL based distros are supported. Supported distros are: debian (tested on v12), ubuntu (tested on v24.04 LTS), pop, kali, rhel, fedora (tested on v40), centos, rocky. If your distro is not in the supported list it doesn't mean that 'the app will not run at all', so, test it yourself and if it doesn't work then you can request us to add support for your distro via creating a github issue.
|
||||||
|
|
||||||
|
> Sandboxed Browsers may not work properly (eg: Flatpak, Snaps) (have issue with: Browser NativeMessaging API [read here](https://github.com/flatpak/xdg-desktop-portal/issues/655))
|
||||||
|
|
||||||
|
1. For linux users Pre-Requirements are mostly fulfilled as 'Python' is pre installed in most linux distros and 'FFmpeg' is auto installed as a dependency while installing the .deb / .rpm package. You just need to install 'PytubePP' manually by clicking the blue 'install' button opening pytubepp-helper. Now click on the 'Refresh' button and you will see the 'Ready' message. Then close PytubePP Helper.
|
||||||
|
|
||||||
|
> Always make sure your system packages are up-to-date (you may face issues otherwise, the app may not open at all)
|
||||||
|
|
||||||
|
> If you are facing issues with installing 'libwebkit2gtk-4.0' as dependency of pytubepp-helper in Ubuntu 24.04 LTS follow this [guide](https://github.com/tauri-apps/tauri/issues/9662)
|
||||||
|
|
||||||
|
> 'AppIndicator' feature must be enabled for seemless experiance with pytubepp-helper. If your distro doesn't support this by default (eg: fedora) then you need to enable it for your GNOME desktop environment manually, using a GNOME shell extension: [AppIndicator and KStatusNotifierItem Support](https://extensions.gnome.org/extension/615/appindicator-support/)
|
||||||
|
|
||||||
|
2. You can now add the [PytubePP Extension](https://github.com/neosubhamoy/pytubepp-extension) in your browser and it should work properly with [PytubePP](https://github.com/neosubhamoy/pytubepp)
|
||||||
|
|
||||||
|
3. Pro Tips:
|
||||||
|
- Make sure PytubePP Helper is always running in the background (Appindicator) otherwise PytubePP Extension will not work properly.
|
||||||
|
- PytubePP Helper by default always autostarts itself when Linux Distro starts. Make sure autostart is not disabled for PytubePP Helper in your distro's Startup Manager / Applications
|
||||||
|
|
||||||
|
* **>> MAC OS:**
|
||||||
|
1. If you don't have any Pre-Requirements installed first install [Homebrew](https://brew.sh)
|
||||||
|
|
||||||
|
2. Python mostly comes pre-installed in MacOS, But on the case if you are running Python version older than 3.8 upgrade it to a newer version using Homebrew command: `brew upgrade python`
|
||||||
|
|
||||||
|
3. Now, open PytubePP Helper app and click on the (blue) install button on the right side of 'FFmpeg' to install it. Also, install 'PytubePP' following the same step.
|
||||||
|
|
||||||
|
4. Then, click on the 'Register' botton on the top right corner to register 'PytubePP Helper' in your system and also add it to your system's autostart entry. If you see a MacOS notification saying 'pytubepp-helper' is added as a startup app then it's done.
|
||||||
|
|
||||||
|
5. Now click on the 'Refresh' button and you will see the 'Ready' message. Then close PytubePP Helper.
|
||||||
|
|
||||||
|
5. You can now add the [PytubePP Extension](https://github.com/neosubhamoy/pytubepp-extension) in your browser and it should work properly with [PytubePP](https://github.com/neosubhamoy/pytubepp)
|
||||||
|
|
||||||
|
6. Pro Tips:
|
||||||
|
- Make sure PytubePP Helper is always running in the background (top bar) otherwise PytubePP Extension will not work properly.
|
||||||
|
- Always allow all the MacOS security popups if it's from 'pytubepp-helper' otherwise it will not function properly.
|
||||||
|
- Don't quit 'pytubepp-helper' from the dock otherwise it will stop working (always use the close button to just hide the app window not fully quit it)
|
||||||
|
- PytubePP Helper by default always autostarts itself when MacOS starts. Make sure autostart is not disabled for PytubePP Helper in Settings (General > Login Apps)
|
||||||
|
|
||||||
### ❔ How It Works
|
### ❔ How It Works
|
||||||
|
|
||||||
@@ -63,9 +100,10 @@ A Helper App for PytubePP Extension/Addon to Communicate with Pytube Post Proces
|
|||||||
|
|
||||||
### 🛠️ Contributing / Building from Source
|
### 🛠️ Contributing / Building from Source
|
||||||
|
|
||||||
Want to be part of this? Feel free to contribute...!! Pull Requests are always welcome...!! (^_^) Follow this simple steps to start building:
|
Want to be part of this? Feel free to contribute...!! Pull Requests are always welcome...!! (^_^) Follow these simple steps to start building:
|
||||||
|
|
||||||
* Make sure to install Rust, Node.js and Git before proceeding.
|
* Make sure to install Rust, Node.js and Git before proceeding.
|
||||||
|
* Install tauri [Prerequisites](https://tauri.app/v1/guides/getting-started/prerequisites) for your OS / platform
|
||||||
1. Fork this repo in your github account.
|
1. Fork this repo in your github account.
|
||||||
2. Git clone the forked repo in your local machine.
|
2. Git clone the forked repo in your local machine.
|
||||||
3. Install node dependencies
|
3. Install node dependencies
|
||||||
@@ -86,4 +124,6 @@ npm run tauri build
|
|||||||
|
|
||||||
### 📝 License
|
### 📝 License
|
||||||
|
|
||||||
PytubePP Helper is Licensed under the [MIT license](https://github.com/neosubhamoy/pytubepp-helper/blob/main/LICENSE). Anyone can view, modify, use (personal and commercial) or distribute it's sources without any attribution and extra permissions.
|
PytubePP Helper is Licensed under the [MIT license](https://github.com/neosubhamoy/pytubepp-helper/blob/main/LICENSE). Anyone can view, modify, use (personal and commercial) or distribute it's sources without any attribution and extra permissions.
|
||||||
|
|
||||||
|
⚖️ NOTE: YouTube is a trademark of Google LLC. Use of this trademark is subject to Google Permissions. Downloading and using Copyrighted YouTube Content for Commercial pourposes are not allowed by YouTube Terms without proper Permissions from the Creator. We don't promote this kinds of activity, You should use the downloaded contents wisely and at your own responsibility.
|
||||||
BIN
app-icon.png
Normal file
|
After Width: | Height: | Size: 118 KiB |
22
copyFiles.aarch64-apple-darwin.js
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
import fs from 'fs';
|
||||||
|
import path from 'path';
|
||||||
|
import { fileURLToPath } from 'url';
|
||||||
|
|
||||||
|
const __filename = fileURLToPath(import.meta.url);
|
||||||
|
const __dirname = path.dirname(__filename);
|
||||||
|
|
||||||
|
const msghostSrc = path.join(__dirname, 'src-tauri', 'target', 'aarch64-apple-darwin', 'release', 'pytubepp-helper-msghost');
|
||||||
|
const msghostDest = path.join(__dirname, 'src-tauri', 'pytubepp-helper-msghost');
|
||||||
|
const autostartPlistSrc = path.join(__dirname, 'src-tauri', 'autostart', 'pytubepp-helper-autostart.plist');
|
||||||
|
const autostartPlistDest = path.join(__dirname, 'src-tauri', 'pytubepp-helper-autostart.plist');
|
||||||
|
const msghostManifestMacChromeSrc = path.join(__dirname, 'src-tauri', 'msghost-manifest', 'macos', 'chrome', 'com.neosubhamoy.pytubepp.helper.json');
|
||||||
|
const msghostManifestMacChromeDest = path.join(__dirname, 'src-tauri', 'pytubepp-helper-msghost.json');
|
||||||
|
const msghostManifestMacFirefoxSrc = path.join(__dirname, 'src-tauri', 'msghost-manifest', 'macos', 'firefox', 'com.neosubhamoy.pytubepp.helper.json');
|
||||||
|
const msghostManifestMacFirefoxDest = path.join(__dirname, 'src-tauri', 'pytubepp-helper-msghost-moz.json');
|
||||||
|
|
||||||
|
fs.copyFileSync(msghostSrc, msghostDest);
|
||||||
|
// fs.copyFileSync(autostartSrc, autostartDest);
|
||||||
|
fs.copyFileSync(autostartPlistSrc, autostartPlistDest);
|
||||||
|
fs.copyFileSync(msghostManifestMacChromeSrc, msghostManifestMacChromeDest);
|
||||||
|
fs.copyFileSync(msghostManifestMacFirefoxSrc, msghostManifestMacFirefoxDest);
|
||||||
|
console.log('Files copied successfully');
|
||||||
15
copyFiles.js
@@ -5,11 +5,14 @@ import { fileURLToPath } from 'url';
|
|||||||
const __filename = fileURLToPath(import.meta.url);
|
const __filename = fileURLToPath(import.meta.url);
|
||||||
const __dirname = path.dirname(__filename);
|
const __dirname = path.dirname(__filename);
|
||||||
|
|
||||||
const msghostsrc = path.join(__dirname, 'src-tauri', 'target', 'release', 'pytubepp-helper-msghost.exe');
|
const msghostSrc = path.join(__dirname, 'src-tauri', 'target', 'release', 'pytubepp-helper-msghost.exe');
|
||||||
const msghostdest = path.join(__dirname, 'src-tauri', 'pytubepp-helper-msghost.exe');
|
const msghostDest = path.join(__dirname, 'src-tauri', 'pytubepp-helper-msghost.exe');
|
||||||
const autostartsrc = path.join(__dirname, 'src-tauri', 'target', 'release', 'pytubepp-helper-autostart.exe');
|
const msghostManifestWinChromeSrc = path.join(__dirname, 'src-tauri', 'msghost-manifest', 'windows', 'chrome', 'com.neosubhamoy.pytubepp.helper.json');
|
||||||
const autostartdest = path.join(__dirname, 'src-tauri', 'pytubepp-helper-autostart.exe');
|
const msghostManifestWinChromeDest = path.join(__dirname, 'src-tauri', 'pytubepp-helper-msghost.json');
|
||||||
|
const msghostManifestWinFirefoxSrc = path.join(__dirname, 'src-tauri', 'msghost-manifest', 'windows', 'firefox', 'com.neosubhamoy.pytubepp.helper.json');
|
||||||
|
const msghostManifestWinFirefoxDest = path.join(__dirname, 'src-tauri', 'pytubepp-helper-msghost-moz.json');
|
||||||
|
|
||||||
fs.copyFileSync(msghostsrc, msghostdest);
|
fs.copyFileSync(msghostSrc, msghostDest);
|
||||||
fs.copyFileSync(autostartsrc, autostartdest);
|
fs.copyFileSync(msghostManifestWinChromeSrc, msghostManifestWinChromeDest);
|
||||||
|
fs.copyFileSync(msghostManifestWinFirefoxSrc, msghostManifestWinFirefoxDest);
|
||||||
console.log('Files copied successfully');
|
console.log('Files copied successfully');
|
||||||
21
copyFiles.x86_64-apple-darwin.js
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
import fs from 'fs';
|
||||||
|
import path from 'path';
|
||||||
|
import { fileURLToPath } from 'url';
|
||||||
|
|
||||||
|
const __filename = fileURLToPath(import.meta.url);
|
||||||
|
const __dirname = path.dirname(__filename);
|
||||||
|
|
||||||
|
const msghostSrc = path.join(__dirname, 'src-tauri', 'target', 'x86_64-apple-darwin', 'release', 'pytubepp-helper-msghost');
|
||||||
|
const msghostDest = path.join(__dirname, 'src-tauri', 'pytubepp-helper-msghost');
|
||||||
|
const autostartPlistSrc = path.join(__dirname, 'src-tauri', 'autostart', 'pytubepp-helper-autostart.plist');
|
||||||
|
const autostartPlistDest = path.join(__dirname, 'src-tauri', 'pytubepp-helper-autostart.plist');
|
||||||
|
const msghostManifestMacChromeSrc = path.join(__dirname, 'src-tauri', 'msghost-manifest', 'macos', 'chrome', 'com.neosubhamoy.pytubepp.helper.json');
|
||||||
|
const msghostManifestMacChromeDest = path.join(__dirname, 'src-tauri', 'pytubepp-helper-msghost.json');
|
||||||
|
const msghostManifestMacFirefoxSrc = path.join(__dirname, 'src-tauri', 'msghost-manifest', 'macos', 'firefox', 'com.neosubhamoy.pytubepp.helper.json');
|
||||||
|
const msghostManifestMacFirefoxDest = path.join(__dirname, 'src-tauri', 'pytubepp-helper-msghost-moz.json');
|
||||||
|
|
||||||
|
fs.copyFileSync(msghostSrc, msghostDest);
|
||||||
|
fs.copyFileSync(autostartPlistSrc, autostartPlistDest);
|
||||||
|
fs.copyFileSync(msghostManifestMacChromeSrc, msghostManifestMacChromeDest);
|
||||||
|
fs.copyFileSync(msghostManifestMacFirefoxSrc, msghostManifestMacFirefoxDest);
|
||||||
|
console.log('Files copied successfully');
|
||||||
1100
package-lock.json
generated
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "pytubepp-helper",
|
"name": "pytubepp-helper",
|
||||||
"private": true,
|
"private": true,
|
||||||
"version": "0.1.0",
|
"version": "0.5.0",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite",
|
"dev": "vite",
|
||||||
|
|||||||
59
signFiles.js
@@ -1,59 +0,0 @@
|
|||||||
import { exec } from 'child_process';
|
|
||||||
import { promisify } from 'util';
|
|
||||||
import dotenv from 'dotenv';
|
|
||||||
import path from 'path';
|
|
||||||
|
|
||||||
dotenv.config();
|
|
||||||
|
|
||||||
const execPromise = promisify(exec);
|
|
||||||
|
|
||||||
// Common configuration
|
|
||||||
const config = {
|
|
||||||
pfxPath: 'certificate.pfx',
|
|
||||||
pfxPassword: process.env.PFX_PASS,
|
|
||||||
companyName: 'Subhamoy Biswas',
|
|
||||||
companyUrl: 'https://neosubhamoy.com',
|
|
||||||
timestampServer: 'http://timestamp.sectigo.com',
|
|
||||||
};
|
|
||||||
|
|
||||||
// Array of files to sign with their individual configurations
|
|
||||||
const filesToSign = [
|
|
||||||
{
|
|
||||||
path: 'src-tauri/target/release/pytubepp-helper-msghost.exe',
|
|
||||||
programName: 'PytubePP Helper Native Messaging Host',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: 'src-tauri/target/release/pytubepp-helper-autostart.exe',
|
|
||||||
programName: 'PytubePP Helper (Autostart)',
|
|
||||||
},
|
|
||||||
// Add more files as needed
|
|
||||||
];
|
|
||||||
|
|
||||||
const signFile = async (fileConfig) => {
|
|
||||||
const { path: filePath, programName } = fileConfig;
|
|
||||||
|
|
||||||
const command = `signtool sign /f "${config.pfxPath}" /p ${config.pfxPassword} /d "${programName}" /du "${config.companyUrl}" /n "${config.companyName}" /t ${config.timestampServer} /fd sha256 "${filePath}"`;
|
|
||||||
|
|
||||||
try {
|
|
||||||
const { stdout, stderr } = await execPromise(command);
|
|
||||||
console.log(`Successfully signed ${path.basename(filePath)}`);
|
|
||||||
console.log(stdout);
|
|
||||||
} catch (error) {
|
|
||||||
console.error(`Failed to sign ${path.basename(filePath)}`);
|
|
||||||
console.error(error.message);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const signAllFiles = async () => {
|
|
||||||
if (!config.pfxPassword) {
|
|
||||||
console.error('PFX password not found in environment variables.');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (const file of filesToSign) {
|
|
||||||
await signFile(file);
|
|
||||||
}
|
|
||||||
console.log('All files processed.');
|
|
||||||
};
|
|
||||||
|
|
||||||
signAllFiles();
|
|
||||||
137
src-tauri/Cargo.lock
generated
@@ -803,6 +803,16 @@ dependencies = [
|
|||||||
"windows-sys 0.59.0",
|
"windows-sys 0.59.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "fix-path-env"
|
||||||
|
version = "0.0.0"
|
||||||
|
source = "git+https://github.com/tauri-apps/fix-path-env-rs#0e479e2804edc1a7e5f15ece2b48ee30858c2838"
|
||||||
|
dependencies = [
|
||||||
|
"home",
|
||||||
|
"strip-ansi-escapes",
|
||||||
|
"thiserror",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "flate2"
|
name = "flate2"
|
||||||
version = "1.0.31"
|
version = "1.0.31"
|
||||||
@@ -1311,6 +1321,15 @@ version = "0.4.3"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70"
|
checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "home"
|
||||||
|
version = "0.5.9"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "e3d1354bf6b7235cb4a0576c2619fd4ed18183f689b12b006a0ee7329eeff9a5"
|
||||||
|
dependencies = [
|
||||||
|
"windows-sys 0.52.0",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "html5ever"
|
name = "html5ever"
|
||||||
version = "0.26.0"
|
version = "0.26.0"
|
||||||
@@ -2085,6 +2104,17 @@ dependencies = [
|
|||||||
"vcpkg",
|
"vcpkg",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "os_info"
|
||||||
|
version = "3.8.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "ae99c7fa6dd38c7cafe1ec085e804f8f555a2f8659b0dbe03f1f9963a9b51092"
|
||||||
|
dependencies = [
|
||||||
|
"log 0.4.22",
|
||||||
|
"serde",
|
||||||
|
"windows-sys 0.52.0",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "os_pipe"
|
name = "os_pipe"
|
||||||
version = "1.2.1"
|
version = "1.2.1"
|
||||||
@@ -2443,8 +2473,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "pytubepp-helper"
|
name = "pytubepp-helper"
|
||||||
version = "0.1.0"
|
version = "0.5.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"fix-path-env",
|
||||||
"futures-util",
|
"futures-util",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
@@ -2454,22 +2485,12 @@ dependencies = [
|
|||||||
"tokio-tungstenite",
|
"tokio-tungstenite",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "pytubepp-helper-autostart"
|
|
||||||
version = "0.1.0"
|
|
||||||
dependencies = [
|
|
||||||
"serde_json",
|
|
||||||
"websocket",
|
|
||||||
"winresource",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "pytubepp-helper-msghost"
|
name = "pytubepp-helper-msghost"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"websocket",
|
"websocket",
|
||||||
"winresource",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -3206,6 +3227,15 @@ dependencies = [
|
|||||||
"quote",
|
"quote",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "strip-ansi-escapes"
|
||||||
|
version = "0.2.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "55ff8ef943b384c414f54aefa961dd2bd853add74ec75e7ac74cf91dba62bcfa"
|
||||||
|
dependencies = [
|
||||||
|
"vte",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "strsim"
|
name = "strsim"
|
||||||
version = "0.11.1"
|
version = "0.11.1"
|
||||||
@@ -3234,6 +3264,19 @@ dependencies = [
|
|||||||
"unicode-ident",
|
"unicode-ident",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "sys-locale"
|
||||||
|
version = "0.2.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "f8a11bd9c338fdba09f7881ab41551932ad42e405f61d01e8406baea71c07aee"
|
||||||
|
dependencies = [
|
||||||
|
"js-sys",
|
||||||
|
"libc",
|
||||||
|
"wasm-bindgen",
|
||||||
|
"web-sys",
|
||||||
|
"windows-sys 0.45.0",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "system-deps"
|
name = "system-deps"
|
||||||
version = "5.0.0"
|
version = "5.0.0"
|
||||||
@@ -3361,6 +3404,7 @@ dependencies = [
|
|||||||
"objc",
|
"objc",
|
||||||
"once_cell",
|
"once_cell",
|
||||||
"open",
|
"open",
|
||||||
|
"os_info",
|
||||||
"os_pipe",
|
"os_pipe",
|
||||||
"percent-encoding 2.3.1",
|
"percent-encoding 2.3.1",
|
||||||
"rand 0.8.5",
|
"rand 0.8.5",
|
||||||
@@ -3373,6 +3417,7 @@ dependencies = [
|
|||||||
"serialize-to-javascript",
|
"serialize-to-javascript",
|
||||||
"shared_child",
|
"shared_child",
|
||||||
"state",
|
"state",
|
||||||
|
"sys-locale",
|
||||||
"tar",
|
"tar",
|
||||||
"tauri-macros",
|
"tauri-macros",
|
||||||
"tauri-runtime",
|
"tauri-runtime",
|
||||||
@@ -4002,6 +4047,12 @@ version = "0.7.6"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9"
|
checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "utf8parse"
|
||||||
|
version = "0.2.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "uuid"
|
name = "uuid"
|
||||||
version = "1.10.0"
|
version = "1.10.0"
|
||||||
@@ -4067,6 +4118,26 @@ dependencies = [
|
|||||||
"libc",
|
"libc",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "vte"
|
||||||
|
version = "0.11.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "f5022b5fbf9407086c180e9557be968742d839e68346af7792b8592489732197"
|
||||||
|
dependencies = [
|
||||||
|
"utf8parse",
|
||||||
|
"vte_generate_state_changes",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "vte_generate_state_changes"
|
||||||
|
version = "0.1.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "2e369bee1b05d510a7b4ed645f5faa90619e05437111783ea5848f28d97d3c2e"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "walkdir"
|
name = "walkdir"
|
||||||
version = "2.5.0"
|
version = "2.5.0"
|
||||||
@@ -4150,6 +4221,16 @@ version = "0.2.93"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "c62a0a307cb4a311d3a07867860911ca130c3494e8c2719593806c08bc5d0484"
|
checksum = "c62a0a307cb4a311d3a07867860911ca130c3494e8c2719593806c08bc5d0484"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "web-sys"
|
||||||
|
version = "0.3.70"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "26fdeaafd9bd129f65e7c031593c24d62186301e0c72c8978fa1678be7d532c0"
|
||||||
|
dependencies = [
|
||||||
|
"js-sys",
|
||||||
|
"wasm-bindgen",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "webkit2gtk"
|
name = "webkit2gtk"
|
||||||
version = "0.18.2"
|
version = "0.18.2"
|
||||||
@@ -4392,6 +4473,15 @@ dependencies = [
|
|||||||
"windows_x86_64_msvc 0.42.2",
|
"windows_x86_64_msvc 0.42.2",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows-sys"
|
||||||
|
version = "0.45.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0"
|
||||||
|
dependencies = [
|
||||||
|
"windows-targets 0.42.2",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "windows-sys"
|
name = "windows-sys"
|
||||||
version = "0.48.0"
|
version = "0.48.0"
|
||||||
@@ -4419,6 +4509,21 @@ dependencies = [
|
|||||||
"windows-targets 0.52.6",
|
"windows-targets 0.52.6",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows-targets"
|
||||||
|
version = "0.42.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071"
|
||||||
|
dependencies = [
|
||||||
|
"windows_aarch64_gnullvm 0.42.2",
|
||||||
|
"windows_aarch64_msvc 0.42.2",
|
||||||
|
"windows_i686_gnu 0.42.2",
|
||||||
|
"windows_i686_msvc 0.42.2",
|
||||||
|
"windows_x86_64_gnu 0.42.2",
|
||||||
|
"windows_x86_64_gnullvm 0.42.2",
|
||||||
|
"windows_x86_64_msvc 0.42.2",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "windows-targets"
|
name = "windows-targets"
|
||||||
version = "0.48.5"
|
version = "0.48.5"
|
||||||
@@ -4655,16 +4760,6 @@ dependencies = [
|
|||||||
"windows-sys 0.48.0",
|
"windows-sys 0.48.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "winresource"
|
|
||||||
version = "0.1.17"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "77e2aaaf8cfa92078c0c0375423d631f82f2f57979c2884fdd5f604a11e45329"
|
|
||||||
dependencies = [
|
|
||||||
"toml 0.7.8",
|
|
||||||
"version_check 0.9.5",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wry"
|
name = "wry"
|
||||||
version = "0.24.10"
|
version = "0.24.10"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "pytubepp-helper"
|
name = "pytubepp-helper"
|
||||||
version = "0.1.0"
|
version = "0.5.0"
|
||||||
description = "PytubePP Helper"
|
description = "PytubePP Helper"
|
||||||
authors = ["neosubhamoy"]
|
authors = ["neosubhamoy"]
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
@@ -11,12 +11,13 @@ edition = "2021"
|
|||||||
tauri-build = { version = "1", features = [] }
|
tauri-build = { version = "1", features = [] }
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
tauri = { version = "1", features = [ "process-relaunch", "window-start-dragging", "window-close", "window-unmaximize", "process-exit", "window-show", "window-unminimize", "window-hide", "window-minimize", "window-maximize", "system-tray", "shell-all"] }
|
tauri = { version = "1", features = [ "os-all", "process-relaunch", "window-start-dragging", "window-close", "window-unmaximize", "process-exit", "window-show", "window-unminimize", "window-hide", "window-minimize", "window-maximize", "system-tray", "shell-all"] }
|
||||||
serde = { version = "1", features = ["derive"] }
|
serde = { version = "1", features = ["derive"] }
|
||||||
serde_json = "1"
|
serde_json = "1"
|
||||||
tokio = { version = "1.39.2", features = ["full"] }
|
tokio = { version = "1.39.2", features = ["full"] }
|
||||||
tokio-tungstenite = "*"
|
tokio-tungstenite = "*"
|
||||||
futures-util = "0.3.30"
|
futures-util = "0.3.30"
|
||||||
|
fix-path-env = { git = "https://github.com/tauri-apps/fix-path-env-rs" }
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
# This feature is used for production builds or when a dev server is not specified, DO NOT REMOVE!!
|
# This feature is used for production builds or when a dev server is not specified, DO NOT REMOVE!!
|
||||||
@@ -25,6 +26,5 @@ custom-protocol = ["tauri/custom-protocol"]
|
|||||||
[workspace]
|
[workspace]
|
||||||
members = [
|
members = [
|
||||||
".",
|
".",
|
||||||
"msghost",
|
"msghost"
|
||||||
"autostart"
|
|
||||||
]
|
]
|
||||||
|
|||||||
7
src-tauri/autostart/Cargo.lock
generated
@@ -1,7 +0,0 @@
|
|||||||
# This file is automatically @generated by Cargo.
|
|
||||||
# It is not intended for manual editing.
|
|
||||||
version = 3
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "pytubepp-helper-autostart"
|
|
||||||
version = "0.1.0"
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
[package]
|
|
||||||
name = "pytubepp-helper-autostart"
|
|
||||||
version = "0.1.0"
|
|
||||||
description = "PytubePP Helper (Autostart)"
|
|
||||||
authors = ["neosubhamoy"]
|
|
||||||
edition = "2021"
|
|
||||||
build = "build.rs"
|
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
|
||||||
|
|
||||||
[dependencies]
|
|
||||||
websocket = "0.27.1"
|
|
||||||
serde_json = "1.0"
|
|
||||||
|
|
||||||
[build-dependencies]
|
|
||||||
winresource = "0.1.17"
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
extern crate winresource;
|
|
||||||
|
|
||||||
fn main() {
|
|
||||||
if std::env::var("CARGO_CFG_TARGET_OS").unwrap() == "windows" {
|
|
||||||
let res = winresource::WindowsResource::new();
|
|
||||||
res.compile().unwrap();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
8
src-tauri/autostart/pytubepp-helper-autostart.desktop
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
[Desktop Entry]
|
||||||
|
Type=Application
|
||||||
|
Name=pytubepp-helper
|
||||||
|
Icon=pytubepp-helper
|
||||||
|
Comment=pytubepp-helper autostart
|
||||||
|
Exec=/usr/bin/pytubepp-helper --hidden
|
||||||
|
StartupNotify=false
|
||||||
|
Terminal=false
|
||||||
15
src-tauri/autostart/pytubepp-helper-autostart.plist
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
|
<plist version="1.0">
|
||||||
|
<dict>
|
||||||
|
<key>Label</key>
|
||||||
|
<string>com.neosubhamoy.pytubepp.helper</string>
|
||||||
|
<key>ProgramArguments</key>
|
||||||
|
<array>
|
||||||
|
<string>/Applications/pytubepp-helper.app/Contents/MacOS/pytubepp-helper</string>
|
||||||
|
<string>--hidden</string>
|
||||||
|
</array>
|
||||||
|
<key>RunAtLoad</key>
|
||||||
|
<true/>
|
||||||
|
</dict>
|
||||||
|
</plist>
|
||||||
@@ -1,55 +0,0 @@
|
|||||||
#![windows_subsystem = "windows"]
|
|
||||||
|
|
||||||
use std::process::Command;
|
|
||||||
use websocket::client::ClientBuilder;
|
|
||||||
use websocket::OwnedMessage;
|
|
||||||
use std::thread::sleep;
|
|
||||||
use std::time::Duration;
|
|
||||||
|
|
||||||
fn connect_with_retry(url: &str, max_attempts: u32) -> Result<websocket::sync::Client<std::net::TcpStream>, Box<dyn std::error::Error>> {
|
|
||||||
let mut attempts = 0;
|
|
||||||
loop {
|
|
||||||
match ClientBuilder::new(url).unwrap().connect_insecure() {
|
|
||||||
Ok(client) => {
|
|
||||||
eprintln!("Successfully connected to Tauri app :)");
|
|
||||||
return Ok(client);
|
|
||||||
}
|
|
||||||
Err(e) => {
|
|
||||||
attempts += 1;
|
|
||||||
if attempts >= max_attempts {
|
|
||||||
return Err(Box::new(e));
|
|
||||||
}
|
|
||||||
let wait_time = Duration::from_secs(2u64.pow(attempts));
|
|
||||||
eprintln!("Connection attempt {} failed. Retrying in {:?}...", attempts, wait_time);
|
|
||||||
sleep(wait_time);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|
||||||
// Launch the main application
|
|
||||||
let _ = Command::new("pytubepp-helper.exe")
|
|
||||||
.spawn();
|
|
||||||
|
|
||||||
// Connect with the Tauri app
|
|
||||||
let websocket_url = "ws://localhost:3030";
|
|
||||||
eprintln!("Attempting to connect to {}", websocket_url);
|
|
||||||
|
|
||||||
let mut client = match connect_with_retry(websocket_url, 2) {
|
|
||||||
Ok(client) => client,
|
|
||||||
Err(e) => {
|
|
||||||
eprintln!("Failed to connect after multiple attempts: {:?}", e);
|
|
||||||
return Err(e);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// Send message to Tauri app
|
|
||||||
client.send_message(&OwnedMessage::Text(serde_json::json!({
|
|
||||||
"url": "",
|
|
||||||
"command": "autostart",
|
|
||||||
"argument": ""
|
|
||||||
}).to_string()))?;
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
Before Width: | Height: | Size: 3.4 KiB After Width: | Height: | Size: 8.2 KiB |
|
Before Width: | Height: | Size: 6.4 KiB After Width: | Height: | Size: 20 KiB |
|
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 1.8 KiB |
|
Before Width: | Height: | Size: 2.8 KiB After Width: | Height: | Size: 6.7 KiB |
|
Before Width: | Height: | Size: 3.8 KiB After Width: | Height: | Size: 9.1 KiB |
|
Before Width: | Height: | Size: 3.9 KiB After Width: | Height: | Size: 9.9 KiB |
|
Before Width: | Height: | Size: 7.6 KiB After Width: | Height: | Size: 23 KiB |
|
Before Width: | Height: | Size: 903 B After Width: | Height: | Size: 1.7 KiB |
|
Before Width: | Height: | Size: 8.4 KiB After Width: | Height: | Size: 26 KiB |
|
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 2.7 KiB |
|
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 4.3 KiB |
|
Before Width: | Height: | Size: 2.4 KiB After Width: | Height: | Size: 5.5 KiB |
|
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 3.1 KiB |
|
Before Width: | Height: | Size: 171 KiB After Width: | Height: | Size: 33 KiB |
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 47 KiB |
770
src-tauri/installer/windows/nsis-template.nsi
Normal file
@@ -0,0 +1,770 @@
|
|||||||
|
Unicode true
|
||||||
|
; Set the compression algorithm. Default is LZMA.
|
||||||
|
!if "" == ""
|
||||||
|
SetCompressor /SOLID lzma
|
||||||
|
!else
|
||||||
|
SetCompressor /SOLID ""
|
||||||
|
!endif
|
||||||
|
|
||||||
|
!include MUI2.nsh
|
||||||
|
!include FileFunc.nsh
|
||||||
|
!include x64.nsh
|
||||||
|
!include WordFunc.nsh
|
||||||
|
!include "StrFunc.nsh"
|
||||||
|
!include "Win\COM.nsh"
|
||||||
|
!include "Win\Propkey.nsh"
|
||||||
|
${StrCase}
|
||||||
|
${StrLoc}
|
||||||
|
|
||||||
|
!define MANUFACTURER "neosubhamoy"
|
||||||
|
!define PRODUCTNAME "pytubepp-helper"
|
||||||
|
!define VERSION "0.5.0"
|
||||||
|
!define VERSIONWITHBUILD "0.5.0.0"
|
||||||
|
!define SHORTDESCRIPTION "PytubePP Helper"
|
||||||
|
!define INSTALLMODE "currentUser"
|
||||||
|
!define LICENSE "..\..\..\..\..\LICENSE"
|
||||||
|
!define INSTALLERICON ""
|
||||||
|
!define SIDEBARIMAGE ""
|
||||||
|
!define HEADERIMAGE ""
|
||||||
|
!define MAINBINARYNAME "pytubepp-helper"
|
||||||
|
!define MAINBINARYSRCPATH "..\..\pytubepp-helper.exe"
|
||||||
|
!define BUNDLEID "com.neosubhamoy.pytubepp.helper"
|
||||||
|
!define COPYRIGHT "© Subhamoy Biswas - All Rights Reserved"
|
||||||
|
!define OUTFILE "nsis-output.exe"
|
||||||
|
!define ARCH "x64"
|
||||||
|
!define PLUGINSPATH ""
|
||||||
|
!define ALLOWDOWNGRADES "true"
|
||||||
|
!define DISPLAYLANGUAGESELECTOR ""
|
||||||
|
!define INSTALLWEBVIEW2MODE "downloadBootstrapper"
|
||||||
|
!define WEBVIEW2INSTALLERARGS "/silent"
|
||||||
|
!define WEBVIEW2BOOTSTRAPPERPATH ""
|
||||||
|
!define WEBVIEW2INSTALLERPATH ""
|
||||||
|
!define UNINSTKEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCTNAME}"
|
||||||
|
!define MANUPRODUCTKEY "Software\${MANUFACTURER}\${PRODUCTNAME}"
|
||||||
|
!define UNINSTALLERSIGNCOMMAND ""
|
||||||
|
!define ESTIMATEDSIZE "0x002311"
|
||||||
|
!define AUTOSTART_EXEC "pytubepp-helper.exe"
|
||||||
|
!define CHROME_REG_PATH "Software\Google\Chrome\NativeMessagingHosts\com.neosubhamoy.pytubepp.helper"
|
||||||
|
!define FIREFOX_REG_PATH "Software\Mozilla\NativeMessagingHosts\com.neosubhamoy.pytubepp.helper"
|
||||||
|
!define RUN_REG_PATH "Software\Microsoft\Windows\CurrentVersion\Run"
|
||||||
|
|
||||||
|
Name "${PRODUCTNAME}"
|
||||||
|
BrandingText "${COPYRIGHT}"
|
||||||
|
OutFile "${OUTFILE}"
|
||||||
|
|
||||||
|
VIProductVersion "${VERSIONWITHBUILD}"
|
||||||
|
VIAddVersionKey "ProductName" "${PRODUCTNAME}"
|
||||||
|
VIAddVersionKey "FileDescription" "${SHORTDESCRIPTION}"
|
||||||
|
VIAddVersionKey "LegalCopyright" "${COPYRIGHT}"
|
||||||
|
VIAddVersionKey "FileVersion" "${VERSION}"
|
||||||
|
VIAddVersionKey "ProductVersion" "${VERSION}"
|
||||||
|
|
||||||
|
; Plugins path, currently exists for linux only
|
||||||
|
!if "${PLUGINSPATH}" != ""
|
||||||
|
!addplugindir "${PLUGINSPATH}"
|
||||||
|
!endif
|
||||||
|
|
||||||
|
!if "${UNINSTALLERSIGNCOMMAND}" != ""
|
||||||
|
!uninstfinalize '${UNINSTALLERSIGNCOMMAND}'
|
||||||
|
!endif
|
||||||
|
|
||||||
|
; Handle install mode, `perUser`, `perMachine` or `both`
|
||||||
|
!if "${INSTALLMODE}" == "perMachine"
|
||||||
|
RequestExecutionLevel highest
|
||||||
|
!endif
|
||||||
|
|
||||||
|
!if "${INSTALLMODE}" == "currentUser"
|
||||||
|
RequestExecutionLevel user
|
||||||
|
!endif
|
||||||
|
|
||||||
|
!if "${INSTALLMODE}" == "both"
|
||||||
|
!define MULTIUSER_MUI
|
||||||
|
!define MULTIUSER_INSTALLMODE_INSTDIR "${PRODUCTNAME}"
|
||||||
|
!define MULTIUSER_INSTALLMODE_COMMANDLINE
|
||||||
|
!if "${ARCH}" == "x64"
|
||||||
|
!define MULTIUSER_USE_PROGRAMFILES64
|
||||||
|
!else if "${ARCH}" == "arm64"
|
||||||
|
!define MULTIUSER_USE_PROGRAMFILES64
|
||||||
|
!endif
|
||||||
|
!define MULTIUSER_INSTALLMODE_DEFAULT_REGISTRY_KEY "${UNINSTKEY}"
|
||||||
|
!define MULTIUSER_INSTALLMODE_DEFAULT_REGISTRY_VALUENAME "CurrentUser"
|
||||||
|
!define MULTIUSER_INSTALLMODEPAGE_SHOWUSERNAME
|
||||||
|
!define MULTIUSER_INSTALLMODE_FUNCTION RestorePreviousInstallLocation
|
||||||
|
!define MULTIUSER_EXECUTIONLEVEL Highest
|
||||||
|
!include MultiUser.nsh
|
||||||
|
!endif
|
||||||
|
|
||||||
|
; installer icon
|
||||||
|
!if "${INSTALLERICON}" != ""
|
||||||
|
!define MUI_ICON "${INSTALLERICON}"
|
||||||
|
!endif
|
||||||
|
|
||||||
|
; installer sidebar image
|
||||||
|
!if "${SIDEBARIMAGE}" != ""
|
||||||
|
!define MUI_WELCOMEFINISHPAGE_BITMAP "${SIDEBARIMAGE}"
|
||||||
|
!endif
|
||||||
|
|
||||||
|
; installer header image
|
||||||
|
!if "${HEADERIMAGE}" != ""
|
||||||
|
!define MUI_HEADERIMAGE
|
||||||
|
!define MUI_HEADERIMAGE_BITMAP "${HEADERIMAGE}"
|
||||||
|
!endif
|
||||||
|
|
||||||
|
; Define registry key to store installer language
|
||||||
|
!define MUI_LANGDLL_REGISTRY_ROOT "HKCU"
|
||||||
|
!define MUI_LANGDLL_REGISTRY_KEY "${MANUPRODUCTKEY}"
|
||||||
|
!define MUI_LANGDLL_REGISTRY_VALUENAME "Installer Language"
|
||||||
|
|
||||||
|
; Installer pages, must be ordered as they appear
|
||||||
|
; 1. Welcome Page
|
||||||
|
!define MUI_PAGE_CUSTOMFUNCTION_PRE SkipIfPassive
|
||||||
|
!insertmacro MUI_PAGE_WELCOME
|
||||||
|
|
||||||
|
; 2. License Page (if defined)
|
||||||
|
!if "${LICENSE}" != ""
|
||||||
|
!define MUI_PAGE_CUSTOMFUNCTION_PRE SkipIfPassive
|
||||||
|
!insertmacro MUI_PAGE_LICENSE "${LICENSE}"
|
||||||
|
!endif
|
||||||
|
|
||||||
|
; 3. Install mode (if it is set to `both`)
|
||||||
|
!if "${INSTALLMODE}" == "both"
|
||||||
|
!define MUI_PAGE_CUSTOMFUNCTION_PRE SkipIfPassive
|
||||||
|
!insertmacro MULTIUSER_PAGE_INSTALLMODE
|
||||||
|
!endif
|
||||||
|
|
||||||
|
|
||||||
|
; 4. Custom page to ask user if he wants to reinstall/uninstall
|
||||||
|
; only if a previous installtion was detected
|
||||||
|
Var ReinstallPageCheck
|
||||||
|
Page custom PageReinstall PageLeaveReinstall
|
||||||
|
Function PageReinstall
|
||||||
|
; Uninstall previous WiX installation if exists.
|
||||||
|
;
|
||||||
|
; A WiX installer stores the isntallation info in registry
|
||||||
|
; using a UUID and so we have to loop through all keys under
|
||||||
|
; `HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall`
|
||||||
|
; and check if `DisplayName` and `Publisher` keys match ${PRODUCTNAME} and ${MANUFACTURER}
|
||||||
|
;
|
||||||
|
; This has a potentional issue that there maybe another installation that matches
|
||||||
|
; our ${PRODUCTNAME} and ${MANUFACTURER} but wasn't installed by our WiX installer,
|
||||||
|
; however, this should be fine since the user will have to confirm the uninstallation
|
||||||
|
; and they can chose to abort it if doesn't make sense.
|
||||||
|
StrCpy $0 0
|
||||||
|
wix_loop:
|
||||||
|
EnumRegKey $1 HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" $0
|
||||||
|
StrCmp $1 "" wix_done ; Exit loop if there is no more keys to loop on
|
||||||
|
IntOp $0 $0 + 1
|
||||||
|
ReadRegStr $R0 HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$1" "DisplayName"
|
||||||
|
ReadRegStr $R1 HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$1" "Publisher"
|
||||||
|
StrCmp "$R0$R1" "${PRODUCTNAME}${MANUFACTURER}" 0 wix_loop
|
||||||
|
ReadRegStr $R0 HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$1" "UninstallString"
|
||||||
|
${StrCase} $R1 $R0 "L"
|
||||||
|
${StrLoc} $R0 $R1 "msiexec" ">"
|
||||||
|
StrCmp $R0 0 0 wix_done
|
||||||
|
StrCpy $R7 "wix"
|
||||||
|
StrCpy $R6 "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$1"
|
||||||
|
Goto compare_version
|
||||||
|
wix_done:
|
||||||
|
|
||||||
|
; Check if there is an existing installation, if not, abort the reinstall page
|
||||||
|
ReadRegStr $R0 SHCTX "${UNINSTKEY}" ""
|
||||||
|
ReadRegStr $R1 SHCTX "${UNINSTKEY}" "UninstallString"
|
||||||
|
${IfThen} "$R0$R1" == "" ${|} Abort ${|}
|
||||||
|
|
||||||
|
; Compare this installar version with the existing installation
|
||||||
|
; and modify the messages presented to the user accordingly
|
||||||
|
compare_version:
|
||||||
|
StrCpy $R4 "$(older)"
|
||||||
|
${If} $R7 == "wix"
|
||||||
|
ReadRegStr $R0 HKLM "$R6" "DisplayVersion"
|
||||||
|
${Else}
|
||||||
|
ReadRegStr $R0 SHCTX "${UNINSTKEY}" "DisplayVersion"
|
||||||
|
${EndIf}
|
||||||
|
${IfThen} $R0 == "" ${|} StrCpy $R4 "$(unknown)" ${|}
|
||||||
|
|
||||||
|
nsis_tauri_utils::SemverCompare "${VERSION}" $R0
|
||||||
|
Pop $R0
|
||||||
|
; Reinstalling the same version
|
||||||
|
${If} $R0 == 0
|
||||||
|
StrCpy $R1 "$(alreadyInstalledLong)"
|
||||||
|
StrCpy $R2 "$(addOrReinstall)"
|
||||||
|
StrCpy $R3 "$(uninstallApp)"
|
||||||
|
!insertmacro MUI_HEADER_TEXT "$(alreadyInstalled)" "$(chooseMaintenanceOption)"
|
||||||
|
StrCpy $R5 "2"
|
||||||
|
; Upgrading
|
||||||
|
${ElseIf} $R0 == 1
|
||||||
|
StrCpy $R1 "$(olderOrUnknownVersionInstalled)"
|
||||||
|
StrCpy $R2 "$(uninstallBeforeInstalling)"
|
||||||
|
StrCpy $R3 "$(dontUninstall)"
|
||||||
|
!insertmacro MUI_HEADER_TEXT "$(alreadyInstalled)" "$(choowHowToInstall)"
|
||||||
|
StrCpy $R5 "1"
|
||||||
|
; Downgrading
|
||||||
|
${ElseIf} $R0 == -1
|
||||||
|
StrCpy $R1 "$(newerVersionInstalled)"
|
||||||
|
StrCpy $R2 "$(uninstallBeforeInstalling)"
|
||||||
|
!if "${ALLOWDOWNGRADES}" == "true"
|
||||||
|
StrCpy $R3 "$(dontUninstall)"
|
||||||
|
!else
|
||||||
|
StrCpy $R3 "$(dontUninstallDowngrade)"
|
||||||
|
!endif
|
||||||
|
!insertmacro MUI_HEADER_TEXT "$(alreadyInstalled)" "$(choowHowToInstall)"
|
||||||
|
StrCpy $R5 "1"
|
||||||
|
${Else}
|
||||||
|
Abort
|
||||||
|
${EndIf}
|
||||||
|
|
||||||
|
Call SkipIfPassive
|
||||||
|
|
||||||
|
nsDialogs::Create 1018
|
||||||
|
Pop $R4
|
||||||
|
${IfThen} $(^RTL) == 1 ${|} nsDialogs::SetRTL $(^RTL) ${|}
|
||||||
|
|
||||||
|
${NSD_CreateLabel} 0 0 100% 24u $R1
|
||||||
|
Pop $R1
|
||||||
|
|
||||||
|
${NSD_CreateRadioButton} 30u 50u -30u 8u $R2
|
||||||
|
Pop $R2
|
||||||
|
${NSD_OnClick} $R2 PageReinstallUpdateSelection
|
||||||
|
|
||||||
|
${NSD_CreateRadioButton} 30u 70u -30u 8u $R3
|
||||||
|
Pop $R3
|
||||||
|
; disable this radio button if downgrading and downgrades are disabled
|
||||||
|
!if "${ALLOWDOWNGRADES}" == "false"
|
||||||
|
${IfThen} $R0 == -1 ${|} EnableWindow $R3 0 ${|}
|
||||||
|
!endif
|
||||||
|
${NSD_OnClick} $R3 PageReinstallUpdateSelection
|
||||||
|
|
||||||
|
; Check the first radio button if this the first time
|
||||||
|
; we enter this page or if the second button wasn't
|
||||||
|
; selected the last time we were on this page
|
||||||
|
${If} $ReinstallPageCheck != 2
|
||||||
|
SendMessage $R2 ${BM_SETCHECK} ${BST_CHECKED} 0
|
||||||
|
${Else}
|
||||||
|
SendMessage $R3 ${BM_SETCHECK} ${BST_CHECKED} 0
|
||||||
|
${EndIf}
|
||||||
|
|
||||||
|
${NSD_SetFocus} $R2
|
||||||
|
nsDialogs::Show
|
||||||
|
FunctionEnd
|
||||||
|
Function PageReinstallUpdateSelection
|
||||||
|
${NSD_GetState} $R2 $R1
|
||||||
|
${If} $R1 == ${BST_CHECKED}
|
||||||
|
StrCpy $ReinstallPageCheck 1
|
||||||
|
${Else}
|
||||||
|
StrCpy $ReinstallPageCheck 2
|
||||||
|
${EndIf}
|
||||||
|
FunctionEnd
|
||||||
|
Function PageLeaveReinstall
|
||||||
|
${NSD_GetState} $R2 $R1
|
||||||
|
|
||||||
|
; $R5 holds whether we are reinstalling the same version or not
|
||||||
|
; $R5 == "1" -> different versions
|
||||||
|
; $R5 == "2" -> same version
|
||||||
|
;
|
||||||
|
; $R1 holds the radio buttons state. its meaning is dependant on the context
|
||||||
|
StrCmp $R5 "1" 0 +2 ; Existing install is not the same version?
|
||||||
|
StrCmp $R1 "1" reinst_uninstall reinst_done ; $R1 == "1", then user chose to uninstall existing version, otherwise skip uninstalling
|
||||||
|
StrCmp $R1 "1" reinst_done ; Same version? skip uninstalling
|
||||||
|
|
||||||
|
reinst_uninstall:
|
||||||
|
HideWindow
|
||||||
|
ClearErrors
|
||||||
|
|
||||||
|
${If} $R7 == "wix"
|
||||||
|
ReadRegStr $R1 HKLM "$R6" "UninstallString"
|
||||||
|
ExecWait '$R1' $0
|
||||||
|
${Else}
|
||||||
|
ReadRegStr $4 SHCTX "${MANUPRODUCTKEY}" ""
|
||||||
|
ReadRegStr $R1 SHCTX "${UNINSTKEY}" "UninstallString"
|
||||||
|
ExecWait '$R1 /P _?=$4' $0
|
||||||
|
${EndIf}
|
||||||
|
|
||||||
|
BringToFront
|
||||||
|
|
||||||
|
${IfThen} ${Errors} ${|} StrCpy $0 2 ${|} ; ExecWait failed, set fake exit code
|
||||||
|
|
||||||
|
${If} $0 <> 0
|
||||||
|
${OrIf} ${FileExists} "$INSTDIR\${MAINBINARYNAME}.exe"
|
||||||
|
${If} $0 = 1 ; User aborted uninstaller?
|
||||||
|
StrCmp $R5 "2" 0 +2 ; Is the existing install the same version?
|
||||||
|
Quit ; ...yes, already installed, we are done
|
||||||
|
Abort
|
||||||
|
${EndIf}
|
||||||
|
MessageBox MB_ICONEXCLAMATION "$(unableToUninstall)"
|
||||||
|
Abort
|
||||||
|
${Else}
|
||||||
|
StrCpy $0 $R1 1
|
||||||
|
${IfThen} $0 == '"' ${|} StrCpy $R1 $R1 -1 1 ${|} ; Strip quotes from UninstallString
|
||||||
|
Delete $R1
|
||||||
|
RMDir $INSTDIR
|
||||||
|
${EndIf}
|
||||||
|
reinst_done:
|
||||||
|
FunctionEnd
|
||||||
|
|
||||||
|
; 5. Choose install directoy page
|
||||||
|
!define MUI_PAGE_CUSTOMFUNCTION_PRE SkipIfPassive
|
||||||
|
!insertmacro MUI_PAGE_DIRECTORY
|
||||||
|
|
||||||
|
; 6. Start menu shortcut page
|
||||||
|
!define MUI_PAGE_CUSTOMFUNCTION_PRE SkipIfPassive
|
||||||
|
Var AppStartMenuFolder
|
||||||
|
!insertmacro MUI_PAGE_STARTMENU Application $AppStartMenuFolder
|
||||||
|
|
||||||
|
; 7. Installation page
|
||||||
|
!insertmacro MUI_PAGE_INSTFILES
|
||||||
|
|
||||||
|
; 8. Finish page
|
||||||
|
;
|
||||||
|
; Don't auto jump to finish page after installation page,
|
||||||
|
; because the installation page has useful info that can be used debug any issues with the installer.
|
||||||
|
!define MUI_FINISHPAGE_NOAUTOCLOSE
|
||||||
|
; Use show readme button in the finish page as a button create a desktop shortcut
|
||||||
|
!define MUI_FINISHPAGE_SHOWREADME
|
||||||
|
!define MUI_FINISHPAGE_SHOWREADME_TEXT "$(createDesktop)"
|
||||||
|
!define MUI_FINISHPAGE_SHOWREADME_FUNCTION CreateDesktopShortcut
|
||||||
|
; Show run app after installation.
|
||||||
|
!define MUI_FINISHPAGE_RUN
|
||||||
|
!define MUI_FINISHPAGE_RUN_FUNCTION RunMainBinary
|
||||||
|
!define MUI_PAGE_CUSTOMFUNCTION_PRE SkipIfPassive
|
||||||
|
!insertmacro MUI_PAGE_FINISH
|
||||||
|
|
||||||
|
Function RunMainBinary
|
||||||
|
nsis_tauri_utils::RunAsUser "$INSTDIR\${MAINBINARYNAME}.exe" ""
|
||||||
|
FunctionEnd
|
||||||
|
|
||||||
|
; Uninstaller Pages
|
||||||
|
; 1. Confirm uninstall page
|
||||||
|
Var DeleteAppDataCheckbox
|
||||||
|
Var DeleteAppDataCheckboxState
|
||||||
|
!define /ifndef WS_EX_LAYOUTRTL 0x00400000
|
||||||
|
!define MUI_PAGE_CUSTOMFUNCTION_SHOW un.ConfirmShow
|
||||||
|
Function un.ConfirmShow
|
||||||
|
FindWindow $1 "#32770" "" $HWNDPARENT ; Find inner dialog
|
||||||
|
${If} $(^RTL) == 1
|
||||||
|
System::Call 'USER32::CreateWindowEx(i${__NSD_CheckBox_EXSTYLE}|${WS_EX_LAYOUTRTL},t"${__NSD_CheckBox_CLASS}",t "$(deleteAppData)",i${__NSD_CheckBox_STYLE},i 50,i 100,i 400, i 25,i$1,i0,i0,i0)i.s'
|
||||||
|
${Else}
|
||||||
|
System::Call 'USER32::CreateWindowEx(i${__NSD_CheckBox_EXSTYLE},t"${__NSD_CheckBox_CLASS}",t "$(deleteAppData)",i${__NSD_CheckBox_STYLE},i 0,i 100,i 400, i 25,i$1,i0,i0,i0)i.s'
|
||||||
|
${EndIf}
|
||||||
|
Pop $DeleteAppDataCheckbox
|
||||||
|
SendMessage $HWNDPARENT ${WM_GETFONT} 0 0 $1
|
||||||
|
SendMessage $DeleteAppDataCheckbox ${WM_SETFONT} $1 1
|
||||||
|
FunctionEnd
|
||||||
|
!define MUI_PAGE_CUSTOMFUNCTION_LEAVE un.ConfirmLeave
|
||||||
|
Function un.ConfirmLeave
|
||||||
|
SendMessage $DeleteAppDataCheckbox ${BM_GETCHECK} 0 0 $DeleteAppDataCheckboxState
|
||||||
|
FunctionEnd
|
||||||
|
!insertmacro MUI_UNPAGE_CONFIRM
|
||||||
|
|
||||||
|
; 2. Uninstalling Page
|
||||||
|
!insertmacro MUI_UNPAGE_INSTFILES
|
||||||
|
|
||||||
|
;Languages
|
||||||
|
!insertmacro MUI_LANGUAGE "English"
|
||||||
|
!insertmacro MUI_RESERVEFILE_LANGDLL
|
||||||
|
!include "English.nsh"
|
||||||
|
|
||||||
|
!macro SetContext
|
||||||
|
!if "${INSTALLMODE}" == "currentUser"
|
||||||
|
SetShellVarContext current
|
||||||
|
!else if "${INSTALLMODE}" == "perMachine"
|
||||||
|
SetShellVarContext all
|
||||||
|
!endif
|
||||||
|
|
||||||
|
${If} ${RunningX64}
|
||||||
|
!if "${ARCH}" == "x64"
|
||||||
|
SetRegView 64
|
||||||
|
!else if "${ARCH}" == "arm64"
|
||||||
|
SetRegView 64
|
||||||
|
!else
|
||||||
|
SetRegView 32
|
||||||
|
!endif
|
||||||
|
${EndIf}
|
||||||
|
!macroend
|
||||||
|
|
||||||
|
Var PassiveMode
|
||||||
|
Function .onInit
|
||||||
|
${GetOptions} $CMDLINE "/P" $PassiveMode
|
||||||
|
IfErrors +2 0
|
||||||
|
StrCpy $PassiveMode 1
|
||||||
|
|
||||||
|
!if "${DISPLAYLANGUAGESELECTOR}" == "true"
|
||||||
|
!insertmacro MUI_LANGDLL_DISPLAY
|
||||||
|
!endif
|
||||||
|
|
||||||
|
!insertmacro SetContext
|
||||||
|
|
||||||
|
${If} $INSTDIR == ""
|
||||||
|
; Set default install location
|
||||||
|
!if "${INSTALLMODE}" == "perMachine"
|
||||||
|
${If} ${RunningX64}
|
||||||
|
!if "${ARCH}" == "x64"
|
||||||
|
StrCpy $INSTDIR "$PROGRAMFILES64\${PRODUCTNAME}"
|
||||||
|
!else if "${ARCH}" == "arm64"
|
||||||
|
StrCpy $INSTDIR "$PROGRAMFILES64\${PRODUCTNAME}"
|
||||||
|
!else
|
||||||
|
StrCpy $INSTDIR "$PROGRAMFILES\${PRODUCTNAME}"
|
||||||
|
!endif
|
||||||
|
${Else}
|
||||||
|
StrCpy $INSTDIR "$PROGRAMFILES\${PRODUCTNAME}"
|
||||||
|
${EndIf}
|
||||||
|
!else if "${INSTALLMODE}" == "currentUser"
|
||||||
|
StrCpy $INSTDIR "$LOCALAPPDATA\${PRODUCTNAME}"
|
||||||
|
!endif
|
||||||
|
|
||||||
|
Call RestorePreviousInstallLocation
|
||||||
|
${EndIf}
|
||||||
|
|
||||||
|
|
||||||
|
!if "${INSTALLMODE}" == "both"
|
||||||
|
!insertmacro MULTIUSER_INIT
|
||||||
|
!endif
|
||||||
|
FunctionEnd
|
||||||
|
|
||||||
|
|
||||||
|
Section EarlyChecks
|
||||||
|
; Abort silent installer if downgrades is disabled
|
||||||
|
!if "${ALLOWDOWNGRADES}" == "false"
|
||||||
|
IfSilent 0 silent_downgrades_done
|
||||||
|
; If downgrading
|
||||||
|
${If} $R0 == -1
|
||||||
|
System::Call 'kernel32::AttachConsole(i -1)i.r0'
|
||||||
|
${If} $0 != 0
|
||||||
|
System::Call 'kernel32::GetStdHandle(i -11)i.r0'
|
||||||
|
System::call 'kernel32::SetConsoleTextAttribute(i r0, i 0x0004)' ; set red color
|
||||||
|
FileWrite $0 "$(silentDowngrades)"
|
||||||
|
${EndIf}
|
||||||
|
Abort
|
||||||
|
${EndIf}
|
||||||
|
silent_downgrades_done:
|
||||||
|
!endif
|
||||||
|
|
||||||
|
SectionEnd
|
||||||
|
|
||||||
|
Section WebView2
|
||||||
|
; Check if Webview2 is already installed and skip this section
|
||||||
|
${If} ${RunningX64}
|
||||||
|
ReadRegStr $4 HKLM "SOFTWARE\WOW6432Node\Microsoft\EdgeUpdate\Clients\{F3017226-FE2A-4295-8BDF-00C3A9A7E4C5}" "pv"
|
||||||
|
${Else}
|
||||||
|
ReadRegStr $4 HKLM "SOFTWARE\Microsoft\EdgeUpdate\Clients\{F3017226-FE2A-4295-8BDF-00C3A9A7E4C5}" "pv"
|
||||||
|
${EndIf}
|
||||||
|
ReadRegStr $5 HKCU "SOFTWARE\Microsoft\EdgeUpdate\Clients\{F3017226-FE2A-4295-8BDF-00C3A9A7E4C5}" "pv"
|
||||||
|
|
||||||
|
StrCmp $4 "" 0 webview2_done
|
||||||
|
StrCmp $5 "" 0 webview2_done
|
||||||
|
|
||||||
|
; Webview2 install modes
|
||||||
|
!if "${INSTALLWEBVIEW2MODE}" == "downloadBootstrapper"
|
||||||
|
Delete "$TEMP\MicrosoftEdgeWebview2Setup.exe"
|
||||||
|
DetailPrint "$(webview2Downloading)"
|
||||||
|
NSISdl::download "https://go.microsoft.com/fwlink/p/?LinkId=2124703" "$TEMP\MicrosoftEdgeWebview2Setup.exe"
|
||||||
|
Pop $0
|
||||||
|
${If} $0 == 0
|
||||||
|
DetailPrint "$(webview2DownloadSuccess)"
|
||||||
|
${Else}
|
||||||
|
DetailPrint "$(webview2DownloadError)"
|
||||||
|
Abort "$(webview2AbortError)"
|
||||||
|
${EndIf}
|
||||||
|
StrCpy $6 "$TEMP\MicrosoftEdgeWebview2Setup.exe"
|
||||||
|
Goto install_webview2
|
||||||
|
!endif
|
||||||
|
|
||||||
|
!if "${INSTALLWEBVIEW2MODE}" == "embedBootstrapper"
|
||||||
|
Delete "$TEMP\MicrosoftEdgeWebview2Setup.exe"
|
||||||
|
File "/oname=$TEMP\MicrosoftEdgeWebview2Setup.exe" "${WEBVIEW2BOOTSTRAPPERPATH}"
|
||||||
|
DetailPrint "$(installingWebview2)"
|
||||||
|
StrCpy $6 "$TEMP\MicrosoftEdgeWebview2Setup.exe"
|
||||||
|
Goto install_webview2
|
||||||
|
!endif
|
||||||
|
|
||||||
|
!if "${INSTALLWEBVIEW2MODE}" == "offlineInstaller"
|
||||||
|
Delete "$TEMP\MicrosoftEdgeWebView2RuntimeInstaller.exe"
|
||||||
|
File "/oname=$TEMP\MicrosoftEdgeWebView2RuntimeInstaller.exe" "${WEBVIEW2INSTALLERPATH}"
|
||||||
|
DetailPrint "$(installingWebview2)"
|
||||||
|
StrCpy $6 "$TEMP\MicrosoftEdgeWebView2RuntimeInstaller.exe"
|
||||||
|
Goto install_webview2
|
||||||
|
!endif
|
||||||
|
|
||||||
|
Goto webview2_done
|
||||||
|
|
||||||
|
install_webview2:
|
||||||
|
DetailPrint "$(installingWebview2)"
|
||||||
|
; $6 holds the path to the webview2 installer
|
||||||
|
ExecWait "$6 ${WEBVIEW2INSTALLERARGS} /install" $1
|
||||||
|
${If} $1 == 0
|
||||||
|
DetailPrint "$(webview2InstallSuccess)"
|
||||||
|
${Else}
|
||||||
|
DetailPrint "$(webview2InstallError)"
|
||||||
|
Abort "$(webview2AbortError)"
|
||||||
|
${EndIf}
|
||||||
|
webview2_done:
|
||||||
|
SectionEnd
|
||||||
|
|
||||||
|
!macro CheckIfAppIsRunning
|
||||||
|
!if "${INSTALLMODE}" == "currentUser"
|
||||||
|
nsis_tauri_utils::FindProcessCurrentUser "${MAINBINARYNAME}.exe"
|
||||||
|
!else
|
||||||
|
nsis_tauri_utils::FindProcess "${MAINBINARYNAME}.exe"
|
||||||
|
!endif
|
||||||
|
Pop $R0
|
||||||
|
${If} $R0 = 0
|
||||||
|
IfSilent kill 0
|
||||||
|
${IfThen} $PassiveMode != 1 ${|} MessageBox MB_OKCANCEL "$(appRunningOkKill)" IDOK kill IDCANCEL cancel ${|}
|
||||||
|
kill:
|
||||||
|
!if "${INSTALLMODE}" == "currentUser"
|
||||||
|
nsis_tauri_utils::KillProcessCurrentUser "${MAINBINARYNAME}.exe"
|
||||||
|
!else
|
||||||
|
nsis_tauri_utils::KillProcess "${MAINBINARYNAME}.exe"
|
||||||
|
!endif
|
||||||
|
Pop $R0
|
||||||
|
Sleep 500
|
||||||
|
${If} $R0 = 0
|
||||||
|
Goto app_check_done
|
||||||
|
${Else}
|
||||||
|
IfSilent silent ui
|
||||||
|
silent:
|
||||||
|
System::Call 'kernel32::AttachConsole(i -1)i.r0'
|
||||||
|
${If} $0 != 0
|
||||||
|
System::Call 'kernel32::GetStdHandle(i -11)i.r0'
|
||||||
|
System::call 'kernel32::SetConsoleTextAttribute(i r0, i 0x0004)' ; set red color
|
||||||
|
FileWrite $0 "$(appRunning)$\n"
|
||||||
|
${EndIf}
|
||||||
|
Abort
|
||||||
|
ui:
|
||||||
|
Abort "$(failedToKillApp)"
|
||||||
|
${EndIf}
|
||||||
|
cancel:
|
||||||
|
Abort "$(appRunning)"
|
||||||
|
${EndIf}
|
||||||
|
app_check_done:
|
||||||
|
!macroend
|
||||||
|
|
||||||
|
Section Install
|
||||||
|
SetOutPath $INSTDIR
|
||||||
|
|
||||||
|
!insertmacro CheckIfAppIsRunning
|
||||||
|
|
||||||
|
; Copy main executable
|
||||||
|
File "${MAINBINARYSRCPATH}"
|
||||||
|
|
||||||
|
; Copy resources
|
||||||
|
CreateDirectory "$INSTDIR\"
|
||||||
|
; File /a "/oname=pytubepp-helper-autostart.exe" "..\..\..\..\pytubepp-helper-autostart.exe"
|
||||||
|
File /a "/oname=pytubepp-helper-msghost-moz.json" "..\..\..\..\pytubepp-helper-msghost-moz.json"
|
||||||
|
File /a "/oname=pytubepp-helper-msghost.exe" "..\..\..\..\pytubepp-helper-msghost.exe"
|
||||||
|
File /a "/oname=pytubepp-helper-msghost.json" "..\..\..\..\pytubepp-helper-msghost.json"
|
||||||
|
|
||||||
|
; Copy external binaries
|
||||||
|
|
||||||
|
; Create uninstaller
|
||||||
|
WriteUninstaller "$INSTDIR\uninstall.exe"
|
||||||
|
|
||||||
|
; Save $INSTDIR in registry for future installations
|
||||||
|
WriteRegStr SHCTX "${MANUPRODUCTKEY}" "" $INSTDIR
|
||||||
|
|
||||||
|
!if "${INSTALLMODE}" == "both"
|
||||||
|
; Save install mode to be selected by default for the next installation such as updating
|
||||||
|
; or when uninstalling
|
||||||
|
WriteRegStr SHCTX "${UNINSTKEY}" $MultiUser.InstallMode 1
|
||||||
|
!endif
|
||||||
|
|
||||||
|
; Registry information for add/remove programs
|
||||||
|
WriteRegStr SHCTX "${UNINSTKEY}" "DisplayName" "${PRODUCTNAME}"
|
||||||
|
WriteRegStr SHCTX "${UNINSTKEY}" "DisplayIcon" "$\"$INSTDIR\${MAINBINARYNAME}.exe$\""
|
||||||
|
WriteRegStr SHCTX "${UNINSTKEY}" "DisplayVersion" "${VERSION}"
|
||||||
|
WriteRegStr SHCTX "${UNINSTKEY}" "Publisher" "${MANUFACTURER}"
|
||||||
|
WriteRegStr SHCTX "${UNINSTKEY}" "InstallLocation" "$\"$INSTDIR$\""
|
||||||
|
WriteRegStr SHCTX "${UNINSTKEY}" "UninstallString" "$\"$INSTDIR\uninstall.exe$\""
|
||||||
|
WriteRegDWORD SHCTX "${UNINSTKEY}" "NoModify" "1"
|
||||||
|
WriteRegDWORD SHCTX "${UNINSTKEY}" "NoRepair" "1"
|
||||||
|
WriteRegDWORD SHCTX "${UNINSTKEY}" "EstimatedSize" "${ESTIMATEDSIZE}"
|
||||||
|
|
||||||
|
; Add Registry Keys for Chrome Native Messaging Host
|
||||||
|
WriteRegStr HKCU "${CHROME_REG_PATH}" "" "$INSTDIR\pytubepp-helper-msghost.json"
|
||||||
|
|
||||||
|
; Add Registry Keys for Firefox Native Messaging Host
|
||||||
|
WriteRegStr HKCU "${FIREFOX_REG_PATH}" "" "$INSTDIR\pytubepp-helper-msghost-moz.json"
|
||||||
|
|
||||||
|
; Add entry for automatic startup with Windows
|
||||||
|
WriteRegStr HKCU "${RUN_REG_PATH}" "${PRODUCTNAME}" "$\"$INSTDIR\${AUTOSTART_EXEC}$\" --hidden"
|
||||||
|
|
||||||
|
; Create start menu shortcut (GUI)
|
||||||
|
!insertmacro MUI_STARTMENU_WRITE_BEGIN Application
|
||||||
|
Call CreateStartMenuShortcut
|
||||||
|
!insertmacro MUI_STARTMENU_WRITE_END
|
||||||
|
|
||||||
|
; Create shortcuts for silent and passive installers, which
|
||||||
|
; can be disabled by passing `/NS` flag
|
||||||
|
; GUI installer has buttons for users to control creating them
|
||||||
|
IfSilent check_ns_flag 0
|
||||||
|
${IfThen} $PassiveMode == 1 ${|} Goto check_ns_flag ${|}
|
||||||
|
Goto shortcuts_done
|
||||||
|
check_ns_flag:
|
||||||
|
${GetOptions} $CMDLINE "/NS" $R0
|
||||||
|
IfErrors 0 shortcuts_done
|
||||||
|
Call CreateDesktopShortcut
|
||||||
|
Call CreateStartMenuShortcut
|
||||||
|
shortcuts_done:
|
||||||
|
|
||||||
|
; Auto close this page for passive mode
|
||||||
|
${IfThen} $PassiveMode == 1 ${|} SetAutoClose true ${|}
|
||||||
|
SectionEnd
|
||||||
|
|
||||||
|
Function .onInstSuccess
|
||||||
|
; Check for `/R` flag only in silent and passive installers because
|
||||||
|
; GUI installer has a toggle for the user to (re)start the app
|
||||||
|
IfSilent check_r_flag 0
|
||||||
|
${IfThen} $PassiveMode == 1 ${|} Goto check_r_flag ${|}
|
||||||
|
Goto run_done
|
||||||
|
check_r_flag:
|
||||||
|
${GetOptions} $CMDLINE "/R" $R0
|
||||||
|
IfErrors run_done 0
|
||||||
|
${GetOptions} $CMDLINE "/ARGS" $R0
|
||||||
|
nsis_tauri_utils::RunAsUser "$INSTDIR\${MAINBINARYNAME}.exe" "$R0"
|
||||||
|
run_done:
|
||||||
|
FunctionEnd
|
||||||
|
|
||||||
|
Function un.onInit
|
||||||
|
!insertmacro SetContext
|
||||||
|
|
||||||
|
!if "${INSTALLMODE}" == "both"
|
||||||
|
!insertmacro MULTIUSER_UNINIT
|
||||||
|
!endif
|
||||||
|
|
||||||
|
!insertmacro MUI_UNGETLANGUAGE
|
||||||
|
FunctionEnd
|
||||||
|
|
||||||
|
!macro DeleteAppUserModelId
|
||||||
|
!insertmacro ComHlpr_CreateInProcInstance ${CLSID_DestinationList} ${IID_ICustomDestinationList} r1 ""
|
||||||
|
${If} $1 P<> 0
|
||||||
|
${ICustomDestinationList::DeleteList} $1 '("${BUNDLEID}")'
|
||||||
|
${IUnknown::Release} $1 ""
|
||||||
|
${EndIf}
|
||||||
|
!insertmacro ComHlpr_CreateInProcInstance ${CLSID_ApplicationDestinations} ${IID_IApplicationDestinations} r1 ""
|
||||||
|
${If} $1 P<> 0
|
||||||
|
${IApplicationDestinations::SetAppID} $1 '("${BUNDLEID}")i.r0'
|
||||||
|
${If} $0 >= 0
|
||||||
|
${IApplicationDestinations::RemoveAllDestinations} $1 ''
|
||||||
|
${EndIf}
|
||||||
|
${IUnknown::Release} $1 ""
|
||||||
|
${EndIf}
|
||||||
|
!macroend
|
||||||
|
|
||||||
|
; From https://stackoverflow.com/a/42816728/16993372
|
||||||
|
!macro UnpinShortcut shortcut
|
||||||
|
!insertmacro ComHlpr_CreateInProcInstance ${CLSID_StartMenuPin} ${IID_IStartMenuPinnedList} r0 ""
|
||||||
|
${If} $0 P<> 0
|
||||||
|
System::Call 'SHELL32::SHCreateItemFromParsingName(ws, p0, g "${IID_IShellItem}", *p0r1)' "${shortcut}"
|
||||||
|
${If} $1 P<> 0
|
||||||
|
${IStartMenuPinnedList::RemoveFromList} $0 '(r1)'
|
||||||
|
${IUnknown::Release} $1 ""
|
||||||
|
${EndIf}
|
||||||
|
${IUnknown::Release} $0 ""
|
||||||
|
${EndIf}
|
||||||
|
!macroend
|
||||||
|
|
||||||
|
Section Uninstall
|
||||||
|
!insertmacro CheckIfAppIsRunning
|
||||||
|
|
||||||
|
; Delete the app directory and its content from disk
|
||||||
|
; Copy main executable
|
||||||
|
Delete "$INSTDIR\${MAINBINARYNAME}.exe"
|
||||||
|
|
||||||
|
; Delete resources
|
||||||
|
; Delete "$INSTDIR\pytubepp-helper-autostart.exe"
|
||||||
|
Delete "$INSTDIR\pytubepp-helper-msghost-moz.json"
|
||||||
|
Delete "$INSTDIR\pytubepp-helper-msghost.exe"
|
||||||
|
Delete "$INSTDIR\pytubepp-helper-msghost.json"
|
||||||
|
|
||||||
|
; Delete external binaries
|
||||||
|
|
||||||
|
; Remove the Registry entries
|
||||||
|
DeleteRegKey HKCU "${CHROME_REG_PATH}"
|
||||||
|
DeleteRegKey HKCU "${FIREFOX_REG_PATH}"
|
||||||
|
DeleteRegValue HKCU "${RUN_REG_PATH}" "${PRODUCTNAME}"
|
||||||
|
|
||||||
|
; Delete uninstaller
|
||||||
|
Delete "$INSTDIR\uninstall.exe"
|
||||||
|
|
||||||
|
RMDir "$INSTDIR"
|
||||||
|
|
||||||
|
!insertmacro DeleteAppUserModelId
|
||||||
|
!insertmacro UnpinShortcut "$SMPROGRAMS\$AppStartMenuFolder\${MAINBINARYNAME}.lnk"
|
||||||
|
!insertmacro UnpinShortcut "$DESKTOP\${MAINBINARYNAME}.lnk"
|
||||||
|
|
||||||
|
; Remove start menu shortcut
|
||||||
|
!insertmacro MUI_STARTMENU_GETFOLDER Application $AppStartMenuFolder
|
||||||
|
Delete "$SMPROGRAMS\$AppStartMenuFolder\${MAINBINARYNAME}.lnk"
|
||||||
|
RMDir "$SMPROGRAMS\$AppStartMenuFolder"
|
||||||
|
|
||||||
|
; Remove desktop shortcuts
|
||||||
|
Delete "$DESKTOP\${MAINBINARYNAME}.lnk"
|
||||||
|
|
||||||
|
; Remove registry information for add/remove programs
|
||||||
|
!if "${INSTALLMODE}" == "both"
|
||||||
|
DeleteRegKey SHCTX "${UNINSTKEY}"
|
||||||
|
!else if "${INSTALLMODE}" == "perMachine"
|
||||||
|
DeleteRegKey HKLM "${UNINSTKEY}"
|
||||||
|
!else
|
||||||
|
DeleteRegKey HKCU "${UNINSTKEY}"
|
||||||
|
!endif
|
||||||
|
|
||||||
|
DeleteRegValue HKCU "${MANUPRODUCTKEY}" "Installer Language"
|
||||||
|
|
||||||
|
; Delete app data
|
||||||
|
${If} $DeleteAppDataCheckboxState == 1
|
||||||
|
SetShellVarContext current
|
||||||
|
RmDir /r "$APPDATA\${BUNDLEID}"
|
||||||
|
RmDir /r "$LOCALAPPDATA\${BUNDLEID}"
|
||||||
|
${EndIf}
|
||||||
|
|
||||||
|
${GetOptions} $CMDLINE "/P" $R0
|
||||||
|
IfErrors +2 0
|
||||||
|
SetAutoClose true
|
||||||
|
SectionEnd
|
||||||
|
|
||||||
|
Function RestorePreviousInstallLocation
|
||||||
|
ReadRegStr $4 SHCTX "${MANUPRODUCTKEY}" ""
|
||||||
|
StrCmp $4 "" +2 0
|
||||||
|
StrCpy $INSTDIR $4
|
||||||
|
FunctionEnd
|
||||||
|
|
||||||
|
Function SkipIfPassive
|
||||||
|
${IfThen} $PassiveMode == 1 ${|} Abort ${|}
|
||||||
|
FunctionEnd
|
||||||
|
|
||||||
|
!macro SetLnkAppUserModelId shortcut
|
||||||
|
!insertmacro ComHlpr_CreateInProcInstance ${CLSID_ShellLink} ${IID_IShellLink} r0 ""
|
||||||
|
${If} $0 P<> 0
|
||||||
|
${IUnknown::QueryInterface} $0 '("${IID_IPersistFile}",.r1)'
|
||||||
|
${If} $1 P<> 0
|
||||||
|
${IPersistFile::Load} $1 '("${shortcut}", ${STGM_READWRITE})'
|
||||||
|
${IUnknown::QueryInterface} $0 '("${IID_IPropertyStore}",.r2)'
|
||||||
|
${If} $2 P<> 0
|
||||||
|
System::Call 'Oleaut32::SysAllocString(w "${BUNDLEID}") i.r3'
|
||||||
|
System::Call '*${SYSSTRUCT_PROPERTYKEY}(${PKEY_AppUserModel_ID})p.r4'
|
||||||
|
System::Call '*${SYSSTRUCT_PROPVARIANT}(${VT_BSTR},,&i4 $3)p.r5'
|
||||||
|
${IPropertyStore::SetValue} $2 '($4,$5)'
|
||||||
|
|
||||||
|
System::Call 'Oleaut32::SysFreeString($3)'
|
||||||
|
System::Free $4
|
||||||
|
System::Free $5
|
||||||
|
${IPropertyStore::Commit} $2 ""
|
||||||
|
${IUnknown::Release} $2 ""
|
||||||
|
${IPersistFile::Save} $1 '("${shortcut}",1)'
|
||||||
|
${EndIf}
|
||||||
|
${IUnknown::Release} $1 ""
|
||||||
|
${EndIf}
|
||||||
|
${IUnknown::Release} $0 ""
|
||||||
|
${EndIf}
|
||||||
|
!macroend
|
||||||
|
|
||||||
|
Function CreateDesktopShortcut
|
||||||
|
CreateShortcut "$DESKTOP\${MAINBINARYNAME}.lnk" "$INSTDIR\${MAINBINARYNAME}.exe"
|
||||||
|
!insertmacro SetLnkAppUserModelId "$DESKTOP\${MAINBINARYNAME}.lnk"
|
||||||
|
FunctionEnd
|
||||||
|
|
||||||
|
Function CreateStartMenuShortcut
|
||||||
|
CreateDirectory "$SMPROGRAMS\$AppStartMenuFolder"
|
||||||
|
CreateShortcut "$SMPROGRAMS\$AppStartMenuFolder\${MAINBINARYNAME}.lnk" "$INSTDIR\${MAINBINARYNAME}.exe"
|
||||||
|
!insertmacro SetLnkAppUserModelId "$SMPROGRAMS\$AppStartMenuFolder\${MAINBINARYNAME}.lnk"
|
||||||
|
FunctionEnd
|
||||||
@@ -10,7 +10,7 @@
|
|||||||
<RegistryValue Type="string" Value="[INSTALLDIR]pytubepp-helper-msghost-moz.json" KeyPath="no" />
|
<RegistryValue Type="string" Value="[INSTALLDIR]pytubepp-helper-msghost-moz.json" KeyPath="no" />
|
||||||
</RegistryKey>
|
</RegistryKey>
|
||||||
<RegistryKey Root="HKCU" Key="Software\Microsoft\Windows\CurrentVersion\Run">
|
<RegistryKey Root="HKCU" Key="Software\Microsoft\Windows\CurrentVersion\Run">
|
||||||
<RegistryValue Name="pytubepp-helper" Type="string" Value="[INSTALLDIR]pytubepp-helper-autostart.exe" KeyPath="no" />
|
<RegistryValue Name="pytubepp-helper" Type="string" Value=""[INSTALLDIR]pytubepp-helper.exe" --hidden" KeyPath="no" />
|
||||||
</RegistryKey>
|
</RegistryKey>
|
||||||
</Component>
|
</Component>
|
||||||
</DirectoryRef>
|
</DirectoryRef>
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"name": "com.neosubhamoy.pytubepp.helper",
|
||||||
|
"description": "A helper app for pytubepp-extension to communicate with pytubepp-cli",
|
||||||
|
"path": "/usr/bin/pytubepp-helper-msghost",
|
||||||
|
"type": "stdio",
|
||||||
|
"allowed_origins": ["chrome-extension://adebedkaedobamilbbobbajepnnkkfcg/", "chrome-extension://mmhhbpdhkogpcieblpdilflfoimajepp/", "chrome-extension://ebneapoekcjelholncnlpdohjbjabhbi/", "chrome-extension://cohjehldppmnbfogjdjpbjknhlhmfhjj/"]
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"name": "com.neosubhamoy.pytubepp.helper",
|
||||||
|
"description": "A helper app for pytubepp-extention to communicate with pytubepp-cli",
|
||||||
|
"path": "/usr/bin/pytubepp-helper-msghost",
|
||||||
|
"type": "stdio",
|
||||||
|
"allowed_extensions": ["pytubepp-addon@neosubhamoy.com"]
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"name": "com.neosubhamoy.pytubepp.helper",
|
||||||
|
"description": "A helper app for pytubepp-extension to communicate with pytubepp-cli",
|
||||||
|
"path": "/Applications/pytubepp-helper.app/Contents/Resources/pytubepp-helper-msghost",
|
||||||
|
"type": "stdio",
|
||||||
|
"allowed_origins": ["chrome-extension://adebedkaedobamilbbobbajepnnkkfcg/", "chrome-extension://mmhhbpdhkogpcieblpdilflfoimajepp/", "chrome-extension://ebneapoekcjelholncnlpdohjbjabhbi/", "chrome-extension://cohjehldppmnbfogjdjpbjknhlhmfhjj/"]
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"name": "com.neosubhamoy.pytubepp.helper",
|
||||||
|
"description": "A helper app for pytubepp-extention to communicate with pytubepp-cli",
|
||||||
|
"path": "/Applications/pytubepp-helper.app/Contents/Resources/pytubepp-helper-msghost",
|
||||||
|
"type": "stdio",
|
||||||
|
"allowed_extensions": ["pytubepp-addon@neosubhamoy.com"]
|
||||||
|
}
|
||||||
@@ -2,15 +2,11 @@
|
|||||||
name = "pytubepp-helper-msghost"
|
name = "pytubepp-helper-msghost"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
description = "PytubePP Helper Native Messaging Host"
|
description = "PytubePP Helper Native Messaging Host"
|
||||||
authors = ["neosubhamoy"]
|
authors = ["neosubhamoy <hey@neosubhamoy.com>"]
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
build = "build.rs"
|
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
websocket = "0.27.1"
|
websocket = "0.27.1"
|
||||||
serde_json = "1.0"
|
serde_json = "1.0"
|
||||||
|
|
||||||
[build-dependencies]
|
|
||||||
winresource = "0.1.17"
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
extern crate winresource;
|
|
||||||
|
|
||||||
fn main() {
|
|
||||||
if std::env::var("CARGO_CFG_TARGET_OS").unwrap() == "windows" {
|
|
||||||
let res = winresource::WindowsResource::new();
|
|
||||||
res.compile().unwrap();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,11 +1,11 @@
|
|||||||
// Prevents additional console window on Windows in release, DO NOT REMOVE!!
|
// Prevents additional console window on Windows in release, DO NOT REMOVE!!
|
||||||
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
|
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
|
||||||
|
|
||||||
use std::{process::Command, sync::Arc, env};
|
use std::{process::Command, sync::Arc, env, time::Duration};
|
||||||
use serde_json::Value;
|
use serde_json::Value;
|
||||||
use tauri::{CustomMenuItem, Manager, SystemTray, SystemTrayEvent, SystemTrayMenu};
|
use tauri::{CustomMenuItem, Manager, SystemTray, SystemTrayEvent, SystemTrayMenu};
|
||||||
use tokio::{net::{TcpListener, TcpStream}, sync::{Mutex, oneshot}};
|
use tokio::{net::{TcpListener, TcpStream}, sync::{Mutex, oneshot}, time::sleep};
|
||||||
use tokio_tungstenite::accept_async;
|
use tokio_tungstenite::{accept_async, connect_async};
|
||||||
use futures_util::{SinkExt, StreamExt};
|
use futures_util::{SinkExt, StreamExt};
|
||||||
|
|
||||||
struct ResponseChannel {
|
struct ResponseChannel {
|
||||||
@@ -17,10 +17,19 @@ struct WebSocketState {
|
|||||||
response_channel: ResponseChannel,
|
response_channel: ResponseChannel,
|
||||||
}
|
}
|
||||||
|
|
||||||
// #[tauri::command]
|
async fn is_another_instance_running() -> bool {
|
||||||
// async fn handle_websocket_message(message: String) -> Result<String, String> {
|
match connect_async("ws://127.0.0.1:3030").await {
|
||||||
// Ok(format!("{}", message))
|
Ok(_) => true,
|
||||||
// }
|
Err(_) => false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn try_bind_ws_port() -> Option<TcpListener> {
|
||||||
|
match TcpListener::bind("127.0.0.1:3030").await {
|
||||||
|
Ok(listener) => Some(listener),
|
||||||
|
Err(_) => None
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
async fn send_to_extension(
|
async fn send_to_extension(
|
||||||
@@ -64,7 +73,7 @@ fn fetch_video_info(url: String) {
|
|||||||
{
|
{
|
||||||
let command = format!("pytubepp \"{}\" -i", &url);
|
let command = format!("pytubepp \"{}\" -i", &url);
|
||||||
Command::new("gnome-terminal")
|
Command::new("gnome-terminal")
|
||||||
.args(["--", command.as_str()])
|
.args(["--", "bash", "-c", command.as_str()])
|
||||||
.spawn()
|
.spawn()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
}
|
}
|
||||||
@@ -72,22 +81,29 @@ fn fetch_video_info(url: String) {
|
|||||||
#[cfg(target_os = "macos")]
|
#[cfg(target_os = "macos")]
|
||||||
{
|
{
|
||||||
let command = format!("pytubepp \"{}\" -i", &url);
|
let command = format!("pytubepp \"{}\" -i", &url);
|
||||||
|
let escaped_command = command.replace("\"", "\\\"");
|
||||||
|
|
||||||
|
let applescript = format!(
|
||||||
|
"tell application \"Terminal\"\n\
|
||||||
|
do script \"{}\"\n\
|
||||||
|
activate\n\
|
||||||
|
end tell",
|
||||||
|
escaped_command
|
||||||
|
);
|
||||||
|
|
||||||
Command::new("osascript")
|
Command::new("osascript")
|
||||||
.arg("-e")
|
.arg("-e")
|
||||||
.arg(format!(
|
.arg(applescript)
|
||||||
"tell app \"Terminal\" to activate do script \"{}\"",
|
|
||||||
command
|
|
||||||
))
|
|
||||||
.spawn()
|
.spawn()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
fn install_program(installer: String ,program: String) {
|
fn install_program(icommand: String) {
|
||||||
#[cfg(target_os = "windows")]
|
#[cfg(target_os = "windows")]
|
||||||
{
|
{
|
||||||
let command = format!("{} install {}", &installer, &program);
|
let command = format!("{}", &icommand);
|
||||||
Command::new("cmd")
|
Command::new("cmd")
|
||||||
.args(["/k", command.as_str()])
|
.args(["/k", command.as_str()])
|
||||||
.spawn()
|
.spawn()
|
||||||
@@ -96,22 +112,29 @@ fn install_program(installer: String ,program: String) {
|
|||||||
|
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
{
|
{
|
||||||
let command = format!("{} install {}", &installer, &program);
|
let command = format!("{}", &icommand);
|
||||||
Command::new("gnome-terminal")
|
Command::new("gnome-terminal")
|
||||||
.args(["--", command.as_str()])
|
.args(["--", "bash", "-c", command.as_str()])
|
||||||
.spawn()
|
.spawn()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_os = "macos")]
|
#[cfg(target_os = "macos")]
|
||||||
{
|
{
|
||||||
let command = format!("{} install {}", &installer, &program);
|
let command = format!("{}", &icommand);
|
||||||
|
let escaped_command = command.replace("\"", "\\\"");
|
||||||
|
|
||||||
|
let applescript = format!(
|
||||||
|
"tell application \"Terminal\"\n\
|
||||||
|
do script \"{}\"\n\
|
||||||
|
activate\n\
|
||||||
|
end tell",
|
||||||
|
escaped_command
|
||||||
|
);
|
||||||
|
|
||||||
Command::new("osascript")
|
Command::new("osascript")
|
||||||
.arg("-e")
|
.arg("-e")
|
||||||
.arg(format!(
|
.arg(applescript)
|
||||||
"tell app \"Terminal\" to activate do script \"{}\"",
|
|
||||||
command
|
|
||||||
))
|
|
||||||
.spawn()
|
.spawn()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
}
|
}
|
||||||
@@ -132,7 +155,7 @@ fn download_stream(url: String, stream: String) {
|
|||||||
{
|
{
|
||||||
let command = format!("pytubepp \"{}\" -s {}", &url, &stream);
|
let command = format!("pytubepp \"{}\" -s {}", &url, &stream);
|
||||||
Command::new("gnome-terminal")
|
Command::new("gnome-terminal")
|
||||||
.args(["--", command.as_str()])
|
.args(["--", "bash", "-c", command.as_str()])
|
||||||
.spawn()
|
.spawn()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
}
|
}
|
||||||
@@ -140,12 +163,19 @@ fn download_stream(url: String, stream: String) {
|
|||||||
#[cfg(target_os = "macos")]
|
#[cfg(target_os = "macos")]
|
||||||
{
|
{
|
||||||
let command = format!("pytubepp \"{}\" -s {}", &url, &stream);
|
let command = format!("pytubepp \"{}\" -s {}", &url, &stream);
|
||||||
|
let escaped_command = command.replace("\"", "\\\"");
|
||||||
|
|
||||||
|
let applescript = format!(
|
||||||
|
"tell application \"Terminal\"\n\
|
||||||
|
do script \"{}\"\n\
|
||||||
|
activate\n\
|
||||||
|
end tell",
|
||||||
|
escaped_command
|
||||||
|
);
|
||||||
|
|
||||||
Command::new("osascript")
|
Command::new("osascript")
|
||||||
.arg("-e")
|
.arg("-e")
|
||||||
.arg(format!(
|
.arg(applescript)
|
||||||
"tell app \"Terminal\" to activate do script \"{}\"",
|
|
||||||
command
|
|
||||||
))
|
|
||||||
.spawn()
|
.spawn()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
}
|
}
|
||||||
@@ -153,10 +183,41 @@ fn download_stream(url: String, stream: String) {
|
|||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() {
|
async fn main() {
|
||||||
|
let _ = fix_path_env::fix();
|
||||||
|
|
||||||
|
// Check if another instance is running
|
||||||
|
if is_another_instance_running().await {
|
||||||
|
println!("Another instance is already running. Exiting...");
|
||||||
|
std::process::exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Try to bind to the WebSocket port with a few retries
|
||||||
|
let mut listener = None;
|
||||||
|
for _ in 0..3 {
|
||||||
|
if let Some(l) = try_bind_ws_port().await {
|
||||||
|
listener = Some(l);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
sleep(Duration::from_millis(100)).await;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If we couldn't bind to the port after retries, assume another instance is running
|
||||||
|
let listener = match listener {
|
||||||
|
Some(l) => l,
|
||||||
|
None => {
|
||||||
|
println!("Could not bind to WebSocket port. Another instance might be running. Exiting...");
|
||||||
|
std::process::exit(0);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
let args: Vec<String> = env::args().collect();
|
||||||
|
let start_hidden = args.contains(&"--hidden".to_string());
|
||||||
|
|
||||||
let websocket_state = Arc::new(Mutex::new(WebSocketState {
|
let websocket_state = Arc::new(Mutex::new(WebSocketState {
|
||||||
sender: None,
|
sender: None,
|
||||||
response_channel: ResponseChannel { sender: None },
|
response_channel: ResponseChannel { sender: None },
|
||||||
}));
|
}));
|
||||||
|
|
||||||
let tray_menu = SystemTrayMenu::new()
|
let tray_menu = SystemTrayMenu::new()
|
||||||
.add_item(CustomMenuItem::new("show".to_string(), "Show"))
|
.add_item(CustomMenuItem::new("show".to_string(), "Show"))
|
||||||
.add_item(CustomMenuItem::new("quit".to_string(), "Quit"));
|
.add_item(CustomMenuItem::new("quit".to_string(), "Quit"));
|
||||||
@@ -190,10 +251,16 @@ async fn main() {
|
|||||||
})
|
})
|
||||||
.manage(websocket_state.clone())
|
.manage(websocket_state.clone())
|
||||||
.setup(move |app| {
|
.setup(move |app| {
|
||||||
|
let window = app.get_window("main").unwrap();
|
||||||
|
|
||||||
|
if start_hidden {
|
||||||
|
window.hide().unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
let app_handle = app.handle();
|
let app_handle = app.handle();
|
||||||
let ws_state = websocket_state.clone();
|
let ws_state = websocket_state.clone();
|
||||||
|
|
||||||
tokio::spawn(async move {
|
tokio::spawn(async move {
|
||||||
let listener = TcpListener::bind("127.0.0.1:3030").await.unwrap();
|
|
||||||
println!("WebSocket server listening on ws://127.0.0.1:3030");
|
println!("WebSocket server listening on ws://127.0.0.1:3030");
|
||||||
while let Ok((stream, _)) = listener.accept().await {
|
while let Ok((stream, _)) = listener.accept().await {
|
||||||
let app_handle = app_handle.clone();
|
let app_handle = app_handle.clone();
|
||||||
@@ -204,7 +271,6 @@ async fn main() {
|
|||||||
Ok(())
|
Ok(())
|
||||||
})
|
})
|
||||||
.invoke_handler(tauri::generate_handler![
|
.invoke_handler(tauri::generate_handler![
|
||||||
// handle_websocket_message,
|
|
||||||
send_to_extension,
|
send_to_extension,
|
||||||
fetch_video_info,
|
fetch_video_info,
|
||||||
install_program,
|
install_program,
|
||||||
|
|||||||
@@ -1,80 +1,17 @@
|
|||||||
{
|
{
|
||||||
"build": {
|
"build": {
|
||||||
"beforeDevCommand": "cargo build --manifest-path=./src-tauri/msghost/Cargo.toml && cargo build --manifest-path=./src-tauri/autostart/Cargo.toml && npm run dev",
|
"beforeDevCommand": "npm run dev",
|
||||||
"beforeBuildCommand": "cargo build --release --manifest-path=./src-tauri/msghost/Cargo.toml && cargo build --release --manifest-path=./src-tauri/autostart/Cargo.toml && node signFiles.js && node copyFiles.js && npm run build",
|
"beforeBuildCommand": "npm run build",
|
||||||
"devPath": "http://localhost:1420",
|
"devPath": "http://localhost:1422",
|
||||||
"distDir": "../dist"
|
"distDir": "../dist"
|
||||||
},
|
},
|
||||||
"package": {
|
"package": {
|
||||||
"productName": "pytubepp-helper",
|
"productName": "pytubepp-helper",
|
||||||
"version": "0.1.0"
|
"version": "0.5.0"
|
||||||
},
|
},
|
||||||
"tauri": {
|
"tauri": {
|
||||||
"allowlist": {
|
"allowlist": {
|
||||||
"all": false,
|
"all": false
|
||||||
"shell": {
|
|
||||||
"all": true,
|
|
||||||
"execute": true,
|
|
||||||
"sidecar": true,
|
|
||||||
"open": true,
|
|
||||||
"scope": [
|
|
||||||
{
|
|
||||||
"name": "is-winget-installed",
|
|
||||||
"cmd": "winget",
|
|
||||||
"args": ["--version"]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "is-python-installed",
|
|
||||||
"cmd": "python",
|
|
||||||
"args": ["--version"]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "is-pip-installed",
|
|
||||||
"cmd": "pip",
|
|
||||||
"args": ["--version"]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "is-ffmpeg-installed",
|
|
||||||
"cmd": "ffmpeg",
|
|
||||||
"args": ["-version"]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "is-pytubepp-installed",
|
|
||||||
"cmd": "pytubepp",
|
|
||||||
"args": ["--version"]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "fetch-video-info",
|
|
||||||
"cmd": "pytubefix",
|
|
||||||
"args": [{ "validator": "\\S+"}, "--list"]
|
|
||||||
}
|
|
||||||
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"fs": {
|
|
||||||
"scope": [
|
|
||||||
"$RESOURCE/pytubepp-helper-msghost.json",
|
|
||||||
"$RESOURCE/pytubepp-helper-msghost-moz.json",
|
|
||||||
"$RESOURCE/pytubepp-helper-msghost.exe",
|
|
||||||
"$RESOURCE/pytubepp-helper-autostart.exe"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"window": {
|
|
||||||
"all": false,
|
|
||||||
"close": true,
|
|
||||||
"hide": true,
|
|
||||||
"show": true,
|
|
||||||
"maximize": true,
|
|
||||||
"minimize": true,
|
|
||||||
"unmaximize": true,
|
|
||||||
"unminimize": true,
|
|
||||||
"startDragging": true
|
|
||||||
},
|
|
||||||
"process": {
|
|
||||||
"all": false,
|
|
||||||
"exit": true,
|
|
||||||
"relaunch": true
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
"windows": [
|
"windows": [
|
||||||
{
|
{
|
||||||
@@ -96,26 +33,7 @@
|
|||||||
"icons/128x128@2x.png",
|
"icons/128x128@2x.png",
|
||||||
"icons/icon.icns",
|
"icons/icon.icns",
|
||||||
"icons/icon.ico"
|
"icons/icon.ico"
|
||||||
],
|
|
||||||
"windows": {
|
|
||||||
"certificateThumbprint": "c12a1579698a3cc86ef3b2c942172cd995149b10",
|
|
||||||
"digestAlgorithm": "sha256",
|
|
||||||
"timestampUrl": "http://timestamp.sectigo.com",
|
|
||||||
"wix": {
|
|
||||||
"fragmentPaths": ["installer/windows/wix-fragment-registry.wxs"],
|
|
||||||
"componentRefs": ["PytubeppHelperFragmentRegistryEntries"]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"resources": [
|
|
||||||
"pytubepp-helper-msghost.json",
|
|
||||||
"pytubepp-helper-msghost-moz.json",
|
|
||||||
"pytubepp-helper-msghost.exe",
|
|
||||||
"pytubepp-helper-autostart.exe"
|
|
||||||
]
|
]
|
||||||
},
|
|
||||||
"systemTray": {
|
|
||||||
"iconPath": "icons/icon.ico",
|
|
||||||
"iconAsTemplate": true
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
159
src-tauri/tauri.linux.conf.json
Normal file
@@ -0,0 +1,159 @@
|
|||||||
|
{
|
||||||
|
"build": {
|
||||||
|
"beforeDevCommand": "npm run dev && cargo build --manifest-path=./src-tauri/msghost/Cargo.toml",
|
||||||
|
"beforeBuildCommand": "npm run build && cargo build --release --manifest-path=./src-tauri/msghost/Cargo.toml",
|
||||||
|
"devPath": "http://localhost:1422",
|
||||||
|
"distDir": "../dist"
|
||||||
|
},
|
||||||
|
"tauri": {
|
||||||
|
"allowlist": {
|
||||||
|
"all": false,
|
||||||
|
"os": {
|
||||||
|
"all": true
|
||||||
|
},
|
||||||
|
"shell": {
|
||||||
|
"all": true,
|
||||||
|
"execute": true,
|
||||||
|
"sidecar": true,
|
||||||
|
"open": true,
|
||||||
|
"scope": [
|
||||||
|
{
|
||||||
|
"name": "detect-windows",
|
||||||
|
"cmd": "systeminfo",
|
||||||
|
"args": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "detect-macos",
|
||||||
|
"cmd": "sw_vers",
|
||||||
|
"args": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "detect-distro",
|
||||||
|
"cmd": "grep",
|
||||||
|
"args": ["^ID=", "/etc/os-release"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "is-apt-installed",
|
||||||
|
"cmd": "apt",
|
||||||
|
"args": ["--version"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "is-dnf-installed",
|
||||||
|
"cmd": "dnf",
|
||||||
|
"args": ["--version"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "is-python3-installed",
|
||||||
|
"cmd": "python3",
|
||||||
|
"args": ["--version"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "is-pip3-installed",
|
||||||
|
"cmd": "pip3",
|
||||||
|
"args": ["--version"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "is-winget-installed",
|
||||||
|
"cmd": "winget",
|
||||||
|
"args": ["--version"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "is-homebrew-installed",
|
||||||
|
"cmd": "brew",
|
||||||
|
"args": ["--version"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "is-python-installed",
|
||||||
|
"cmd": "python",
|
||||||
|
"args": ["--version"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "is-pip-installed",
|
||||||
|
"cmd": "pip",
|
||||||
|
"args": ["--version"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "is-ffmpeg-installed",
|
||||||
|
"cmd": "ffmpeg",
|
||||||
|
"args": ["-version"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "is-pytubepp-installed",
|
||||||
|
"cmd": "pytubepp",
|
||||||
|
"args": ["--version"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "fetch-video-info",
|
||||||
|
"cmd": "pytubepp",
|
||||||
|
"args": [{ "validator": "\\S+" }, "--raw-info"]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"window": {
|
||||||
|
"all": false,
|
||||||
|
"close": true,
|
||||||
|
"hide": true,
|
||||||
|
"show": true,
|
||||||
|
"maximize": true,
|
||||||
|
"minimize": true,
|
||||||
|
"unmaximize": true,
|
||||||
|
"unminimize": true,
|
||||||
|
"startDragging": true
|
||||||
|
},
|
||||||
|
"process": {
|
||||||
|
"all": false,
|
||||||
|
"exit": true,
|
||||||
|
"relaunch": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"windows": [
|
||||||
|
{
|
||||||
|
"title": "PytubePP Helper",
|
||||||
|
"width": 500,
|
||||||
|
"height": 320
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"security": {
|
||||||
|
"csp": null
|
||||||
|
},
|
||||||
|
"bundle": {
|
||||||
|
"active": true,
|
||||||
|
"targets": ["deb", "rpm"],
|
||||||
|
"identifier": "com.neosubhamoy.pytubepp.helper",
|
||||||
|
"icon": [
|
||||||
|
"icons/32x32.png",
|
||||||
|
"icons/128x128.png",
|
||||||
|
"icons/128x128@2x.png",
|
||||||
|
"icons/icon.icns",
|
||||||
|
"icons/icon.ico"
|
||||||
|
],
|
||||||
|
"deb": {
|
||||||
|
"depends": ["python3-pip", "ffmpeg"],
|
||||||
|
"files": {
|
||||||
|
"/etc/opt/chrome/native-messaging-hosts/com.neosubhamoy.pytubepp.helper.json": "./msghost-manifest/linux/chrome/com.neosubhamoy.pytubepp.helper.json",
|
||||||
|
"/etc/chromium/native-messaging-hosts/com.neosubhamoy.pytubepp.helper.json": "./msghost-manifest/linux/chrome/com.neosubhamoy.pytubepp.helper.json",
|
||||||
|
"/usr/lib/mozilla/native-messaging-hosts/com.neosubhamoy.pytubepp.helper.json": "./msghost-manifest/linux/firefox/com.neosubhamoy.pytubepp.helper.json",
|
||||||
|
"/usr/bin/pytubepp-helper-msghost": "./target/release/pytubepp-helper-msghost",
|
||||||
|
"/etc/xdg/autostart/pytubepp-helper-autostart.desktop": "./autostart/pytubepp-helper-autostart.desktop"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"rpm": {
|
||||||
|
"epoch": 0,
|
||||||
|
"release": "1",
|
||||||
|
"license": "MIT",
|
||||||
|
"depends": ["python3-pip", "ffmpeg-free"],
|
||||||
|
"files": {
|
||||||
|
"/etc/opt/chrome/native-messaging-hosts/com.neosubhamoy.pytubepp.helper.json": "./msghost-manifest/linux/chrome/com.neosubhamoy.pytubepp.helper.json",
|
||||||
|
"/etc/chromium/native-messaging-hosts/com.neosubhamoy.pytubepp.helper.json": "./msghost-manifest/linux/chrome/com.neosubhamoy.pytubepp.helper.json",
|
||||||
|
"/usr/lib/mozilla/native-messaging-hosts/com.neosubhamoy.pytubepp.helper.json": "./msghost-manifest/linux/firefox/com.neosubhamoy.pytubepp.helper.json",
|
||||||
|
"/usr/bin/pytubepp-helper-msghost": "./target/release/pytubepp-helper-msghost",
|
||||||
|
"/etc/xdg/autostart/pytubepp-helper-autostart.desktop": "./autostart/pytubepp-helper-autostart.desktop"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"systemTray": {
|
||||||
|
"iconPath": "icons/32x32.png",
|
||||||
|
"iconAsTemplate": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
166
src-tauri/tauri.macos.conf.json
Normal file
@@ -0,0 +1,166 @@
|
|||||||
|
{
|
||||||
|
"build": {
|
||||||
|
"beforeDevCommand": "[[ -n \"$TARGET_ARCH\" ]] && ARCH=\"$TARGET_ARCH\" || ARCH=\"$(uname -m | sed 's/^arm64$/aarch64/')-apple-darwin\" && cargo build --target=$ARCH --manifest-path=./src-tauri/msghost/Cargo.toml && npm run dev",
|
||||||
|
"beforeBuildCommand": "[[ -n \"$TARGET_ARCH\" ]] && ARCH=\"$TARGET_ARCH\" || ARCH=\"$(uname -m | sed 's/^arm64$/aarch64/')-apple-darwin\" && cargo build --release --target=$ARCH --manifest-path=./src-tauri/msghost/Cargo.toml && node copyFiles.${ARCH}.js && npm run build",
|
||||||
|
"devPath": "http://localhost:1422",
|
||||||
|
"distDir": "../dist"
|
||||||
|
},
|
||||||
|
"tauri": {
|
||||||
|
"allowlist": {
|
||||||
|
"all": false,
|
||||||
|
"os": {
|
||||||
|
"all": true
|
||||||
|
},
|
||||||
|
"shell": {
|
||||||
|
"all": true,
|
||||||
|
"execute": true,
|
||||||
|
"sidecar": true,
|
||||||
|
"open": true,
|
||||||
|
"scope": [
|
||||||
|
{
|
||||||
|
"name": "detect-windows",
|
||||||
|
"cmd": "systeminfo",
|
||||||
|
"args": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "detect-macos",
|
||||||
|
"cmd": "sw_vers",
|
||||||
|
"args": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "detect-distro",
|
||||||
|
"cmd": "grep",
|
||||||
|
"args": ["^ID=", "/etc/os-release"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "is-apt-installed",
|
||||||
|
"cmd": "apt",
|
||||||
|
"args": ["--version"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "is-dnf-installed",
|
||||||
|
"cmd": "dnf",
|
||||||
|
"args": ["--version"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "is-python3-installed",
|
||||||
|
"cmd": "python3",
|
||||||
|
"args": ["--version"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "is-pip3-installed",
|
||||||
|
"cmd": "pip3",
|
||||||
|
"args": ["--version"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "is-winget-installed",
|
||||||
|
"cmd": "winget",
|
||||||
|
"args": ["--version"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "is-homebrew-installed",
|
||||||
|
"cmd": "brew",
|
||||||
|
"args": ["--version"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "is-python-installed",
|
||||||
|
"cmd": "python",
|
||||||
|
"args": ["--version"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "is-pip-installed",
|
||||||
|
"cmd": "pip",
|
||||||
|
"args": ["--version"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "is-ffmpeg-installed",
|
||||||
|
"cmd": "ffmpeg",
|
||||||
|
"args": ["-version"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "is-pytubepp-installed",
|
||||||
|
"cmd": "pytubepp",
|
||||||
|
"args": ["--version"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "fetch-video-info",
|
||||||
|
"cmd": "pytubepp",
|
||||||
|
"args": [{ "validator": "\\S+" }, "--raw-info"]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"fs": {
|
||||||
|
"all": true,
|
||||||
|
"copyFile": true,
|
||||||
|
"exists": true,
|
||||||
|
"createDir": true,
|
||||||
|
"scope": [
|
||||||
|
"$HOME/Library/LaunchAgents/",
|
||||||
|
"$HOME/Library/Application Support/Google/Chrome/NativeMessagingHosts/",
|
||||||
|
"$HOME/Library/Application Support/Chromium/NativeMessagingHosts/",
|
||||||
|
"$HOME/Library/Application Support/Mozilla/NativeMessagingHosts/",
|
||||||
|
"$RESOURCE/pytubepp-helper-msghost.json",
|
||||||
|
"$RESOURCE/pytubepp-helper-msghost-moz.json",
|
||||||
|
"$RESOURCE/pytubepp-helper-msghost",
|
||||||
|
"$RESOURCE/pytubepp-helper-autostart.plist"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"path": {
|
||||||
|
"all": true
|
||||||
|
},
|
||||||
|
"window": {
|
||||||
|
"all": false,
|
||||||
|
"close": true,
|
||||||
|
"hide": true,
|
||||||
|
"show": true,
|
||||||
|
"maximize": true,
|
||||||
|
"minimize": true,
|
||||||
|
"unmaximize": true,
|
||||||
|
"unminimize": true,
|
||||||
|
"startDragging": true
|
||||||
|
},
|
||||||
|
"process": {
|
||||||
|
"all": false,
|
||||||
|
"exit": true,
|
||||||
|
"relaunch": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"windows": [
|
||||||
|
{
|
||||||
|
"title": "PytubePP Helper",
|
||||||
|
"width": 500,
|
||||||
|
"height": 335
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"security": {
|
||||||
|
"csp": null
|
||||||
|
},
|
||||||
|
"bundle": {
|
||||||
|
"active": true,
|
||||||
|
"targets": ["app", "dmg"],
|
||||||
|
"identifier": "com.neosubhamoy.pytubepp.helper",
|
||||||
|
"icon": [
|
||||||
|
"icons/32x32.png",
|
||||||
|
"icons/128x128.png",
|
||||||
|
"icons/128x128@2x.png",
|
||||||
|
"icons/icon.icns",
|
||||||
|
"icons/icon.ico"
|
||||||
|
],
|
||||||
|
"macOS": {
|
||||||
|
"minimumSystemVersion": "10.13",
|
||||||
|
"license": "../LICENSE",
|
||||||
|
"providerShortName": "neosubhamoy"
|
||||||
|
},
|
||||||
|
"resources": [
|
||||||
|
"pytubepp-helper-msghost.json",
|
||||||
|
"pytubepp-helper-msghost-moz.json",
|
||||||
|
"pytubepp-helper-msghost",
|
||||||
|
"pytubepp-helper-autostart.plist"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"systemTray": {
|
||||||
|
"iconPath": "icons/32x32.png",
|
||||||
|
"iconAsTemplate": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
158
src-tauri/tauri.windows.conf.json
Normal file
@@ -0,0 +1,158 @@
|
|||||||
|
{
|
||||||
|
"build": {
|
||||||
|
"beforeDevCommand": "cargo build --manifest-path=./src-tauri/msghost/Cargo.toml && npm run dev",
|
||||||
|
"beforeBuildCommand": "cargo build --release --manifest-path=./src-tauri/msghost/Cargo.toml && node copyFiles.js && npm run build",
|
||||||
|
"devPath": "http://localhost:1422",
|
||||||
|
"distDir": "../dist"
|
||||||
|
},
|
||||||
|
"tauri": {
|
||||||
|
"allowlist": {
|
||||||
|
"all": false,
|
||||||
|
"os": {
|
||||||
|
"all": true
|
||||||
|
},
|
||||||
|
"shell": {
|
||||||
|
"all": true,
|
||||||
|
"execute": true,
|
||||||
|
"sidecar": true,
|
||||||
|
"open": true,
|
||||||
|
"scope": [
|
||||||
|
{
|
||||||
|
"name": "detect-windows",
|
||||||
|
"cmd": "systeminfo",
|
||||||
|
"args": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "detect-macos",
|
||||||
|
"cmd": "sw_vers",
|
||||||
|
"args": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "detect-distro",
|
||||||
|
"cmd": "grep",
|
||||||
|
"args": ["^ID=", "/etc/os-release"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "is-apt-installed",
|
||||||
|
"cmd": "apt",
|
||||||
|
"args": ["--version"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "is-dnf-installed",
|
||||||
|
"cmd": "dnf",
|
||||||
|
"args": ["--version"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "is-python3-installed",
|
||||||
|
"cmd": "python3",
|
||||||
|
"args": ["--version"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "is-pip3-installed",
|
||||||
|
"cmd": "pip3",
|
||||||
|
"args": ["--version"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "is-winget-installed",
|
||||||
|
"cmd": "winget",
|
||||||
|
"args": ["--version"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "is-homebrew-installed",
|
||||||
|
"cmd": "brew",
|
||||||
|
"args": ["--version"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "is-python-installed",
|
||||||
|
"cmd": "python",
|
||||||
|
"args": ["--version"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "is-pip-installed",
|
||||||
|
"cmd": "pip",
|
||||||
|
"args": ["--version"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "is-ffmpeg-installed",
|
||||||
|
"cmd": "ffmpeg",
|
||||||
|
"args": ["-version"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "is-pytubepp-installed",
|
||||||
|
"cmd": "pytubepp",
|
||||||
|
"args": ["--version"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "fetch-video-info",
|
||||||
|
"cmd": "pytubepp",
|
||||||
|
"args": [{ "validator": "\\S+" }, "--raw-info"]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"fs": {
|
||||||
|
"scope": [
|
||||||
|
"$RESOURCE/pytubepp-helper-msghost.json",
|
||||||
|
"$RESOURCE/pytubepp-helper-msghost-moz.json",
|
||||||
|
"$RESOURCE/pytubepp-helper-msghost.exe"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"window": {
|
||||||
|
"all": false,
|
||||||
|
"close": true,
|
||||||
|
"hide": true,
|
||||||
|
"show": true,
|
||||||
|
"maximize": true,
|
||||||
|
"minimize": true,
|
||||||
|
"unmaximize": true,
|
||||||
|
"unminimize": true,
|
||||||
|
"startDragging": true
|
||||||
|
},
|
||||||
|
"process": {
|
||||||
|
"all": false,
|
||||||
|
"exit": true,
|
||||||
|
"relaunch": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"windows": [
|
||||||
|
{
|
||||||
|
"title": "PytubePP Helper",
|
||||||
|
"width": 500,
|
||||||
|
"height": 320
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"security": {
|
||||||
|
"csp": null
|
||||||
|
},
|
||||||
|
"bundle": {
|
||||||
|
"active": true,
|
||||||
|
"targets": ["msi", "nsis"],
|
||||||
|
"identifier": "com.neosubhamoy.pytubepp.helper",
|
||||||
|
"icon": [
|
||||||
|
"icons/32x32.png",
|
||||||
|
"icons/128x128.png",
|
||||||
|
"icons/128x128@2x.png",
|
||||||
|
"icons/icon.icns",
|
||||||
|
"icons/icon.ico"
|
||||||
|
],
|
||||||
|
"windows": {
|
||||||
|
"wix": {
|
||||||
|
"fragmentPaths": ["installer/windows/wix-fragment-registry.wxs"],
|
||||||
|
"componentRefs": ["PytubeppHelperFragmentRegistryEntries"],
|
||||||
|
"license": "../LICENSE"
|
||||||
|
},
|
||||||
|
"nsis": {
|
||||||
|
"template": "installer/windows/nsis-template.nsi"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"resources": [
|
||||||
|
"pytubepp-helper-msghost.json",
|
||||||
|
"pytubepp-helper-msghost-moz.json",
|
||||||
|
"pytubepp-helper-msghost.exe"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"systemTray": {
|
||||||
|
"iconPath": "icons/icon.ico",
|
||||||
|
"iconAsTemplate": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
296
src/App.tsx
@@ -1,13 +1,15 @@
|
|||||||
|
import clsx from "clsx";
|
||||||
import { useState, useEffect } from "react";
|
import { useState, useEffect } from "react";
|
||||||
import "./index.css";
|
import "./index.css";
|
||||||
import { invoke } from "@tauri-apps/api/tauri";
|
import { invoke } from "@tauri-apps/api/tauri";
|
||||||
import { listen } from '@tauri-apps/api/event';
|
import { listen } from '@tauri-apps/api/event';
|
||||||
import { appWindow } from '@tauri-apps/api/window';
|
import { appWindow } from '@tauri-apps/api/window';
|
||||||
|
import { platform } from '@tauri-apps/api/os';
|
||||||
import { ThemeProvider } from "@/components/theme-provider";
|
import { ThemeProvider } from "@/components/theme-provider";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert"
|
import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert"
|
||||||
import { InstalledPrograms, WebSocketMessage, } from "./types";
|
import { InstalledPrograms, WebSocketMessage, } from "./types";
|
||||||
import { compareVersions, extract_version, is_installed, sendStreamInfo } from "./lib/utils";
|
import { compareVersions, extractVersion, isInstalled, sendStreamInfo, detectWindows, detectDistro, extractDistroId, detectDistroBase, detectMacOs, registerMacFiles } from "./lib/utils";
|
||||||
import { CircleCheck, TriangleAlert, CircleAlert } from 'lucide-react';
|
import { CircleCheck, TriangleAlert, CircleAlert } from 'lucide-react';
|
||||||
|
|
||||||
function App() {
|
function App() {
|
||||||
@@ -19,12 +21,30 @@ function App() {
|
|||||||
|
|
||||||
appWindow.onCloseRequested(handleCloseRequested);
|
appWindow.onCloseRequested(handleCloseRequested);
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
const [isWindows, setIsWindows] = useState<boolean>(false)
|
||||||
|
const [windowsVersion, setWindowsVersion] = useState<string | null>(null)
|
||||||
|
const [isMacOs, setIsMacOs] = useState<boolean>(false)
|
||||||
|
const [macOsVersion, setMacOsVersion] = useState<string | null>(null)
|
||||||
|
const [distroId, setDistroId] = useState<string | null>(null)
|
||||||
|
const [distroBase, setDistroBase] = useState<string | null>(null)
|
||||||
const [installedPrograms, setInstalledPrograms] = useState<InstalledPrograms>({
|
const [installedPrograms, setInstalledPrograms] = useState<InstalledPrograms>({
|
||||||
winget: {
|
winget: {
|
||||||
installed: false,
|
installed: false,
|
||||||
version: null,
|
version: null,
|
||||||
},
|
},
|
||||||
|
apt: {
|
||||||
|
installed: false,
|
||||||
|
version: null,
|
||||||
|
},
|
||||||
|
dnf: {
|
||||||
|
installed: false,
|
||||||
|
version: null,
|
||||||
|
},
|
||||||
|
brew: {
|
||||||
|
installed: false,
|
||||||
|
version: null,
|
||||||
|
},
|
||||||
python: {
|
python: {
|
||||||
installed: false,
|
installed: false,
|
||||||
version: null,
|
version: null,
|
||||||
@@ -33,6 +53,14 @@ function App() {
|
|||||||
installed: false,
|
installed: false,
|
||||||
version: null,
|
version: null,
|
||||||
},
|
},
|
||||||
|
python3: {
|
||||||
|
installed: false,
|
||||||
|
version: null,
|
||||||
|
},
|
||||||
|
pip3: {
|
||||||
|
installed: false,
|
||||||
|
version: null,
|
||||||
|
},
|
||||||
ffmpeg: {
|
ffmpeg: {
|
||||||
installed: false,
|
installed: false,
|
||||||
version: null,
|
version: null,
|
||||||
@@ -71,78 +99,247 @@ function App() {
|
|||||||
};
|
};
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
function check_all_programs() {
|
function checkAllPrograms() {
|
||||||
is_installed('winget', '--version').then((result) => {
|
isInstalled('winget', '--version').then((result) => {
|
||||||
setInstalledPrograms((prevState) => ({
|
setInstalledPrograms((prevState) => ({
|
||||||
...prevState,
|
...prevState,
|
||||||
winget: {
|
winget: {
|
||||||
installed: result.installed,
|
installed: result.installed,
|
||||||
version: result.output ? extract_version(result.output) : null,
|
version: result.output ? extractVersion(result.output) : null,
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
is_installed('python', '--version').then((result) => {
|
isInstalled('apt', '--version').then((result) => {
|
||||||
|
setInstalledPrograms((prevState) => ({
|
||||||
|
...prevState,
|
||||||
|
apt: {
|
||||||
|
installed: result.installed,
|
||||||
|
version: result.output ? extractVersion(result.output) : null,
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
});
|
||||||
|
isInstalled('dnf', '--version').then((result) => {
|
||||||
|
setInstalledPrograms((prevState) => ({
|
||||||
|
...prevState,
|
||||||
|
dnf: {
|
||||||
|
installed: result.installed,
|
||||||
|
version: result.output ? extractVersion(result.output) : null,
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
});
|
||||||
|
isInstalled('homebrew', '--version').then((result) => {
|
||||||
|
setInstalledPrograms((prevState) => ({
|
||||||
|
...prevState,
|
||||||
|
brew: {
|
||||||
|
installed: result.installed,
|
||||||
|
version: result.output ? extractVersion(result.output) : null,
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
});
|
||||||
|
isInstalled('python', '--version').then((result) => {
|
||||||
setInstalledPrograms((prevState) => ({
|
setInstalledPrograms((prevState) => ({
|
||||||
...prevState,
|
...prevState,
|
||||||
python: {
|
python: {
|
||||||
installed: result.installed,
|
installed: result.installed,
|
||||||
version: result.output ? extract_version(result.output) : null,
|
version: result.output ? extractVersion(result.output) : null,
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
is_installed('pip', '--version').then((result) => {
|
isInstalled('pip', '--version').then((result) => {
|
||||||
setInstalledPrograms((prevState) => ({
|
setInstalledPrograms((prevState) => ({
|
||||||
...prevState,
|
...prevState,
|
||||||
pip: {
|
pip: {
|
||||||
installed: result.installed,
|
installed: result.installed,
|
||||||
version: result.output ? extract_version(result.output) : null,
|
version: result.output ? extractVersion(result.output) : null,
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
is_installed('ffmpeg', '-version').then((result) => {
|
isInstalled('python3', '--version').then((result) => {
|
||||||
|
setInstalledPrograms((prevState) => ({
|
||||||
|
...prevState,
|
||||||
|
python3: {
|
||||||
|
installed: result.installed,
|
||||||
|
version: result.output ? extractVersion(result.output) : null,
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
});
|
||||||
|
isInstalled('pip3', '--version').then((result) => {
|
||||||
|
setInstalledPrograms((prevState) => ({
|
||||||
|
...prevState,
|
||||||
|
pip3: {
|
||||||
|
installed: result.installed,
|
||||||
|
version: result.output ? extractVersion(result.output) : null,
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
});
|
||||||
|
isInstalled('ffmpeg', '-version').then((result) => {
|
||||||
setInstalledPrograms((prevState) => ({
|
setInstalledPrograms((prevState) => ({
|
||||||
...prevState,
|
...prevState,
|
||||||
ffmpeg: {
|
ffmpeg: {
|
||||||
installed: result.installed,
|
installed: result.installed,
|
||||||
version: result.output ? extract_version(result.output) : null,
|
version: result.output ? extractVersion(result.output) : null,
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
is_installed('pytubepp', '--version').then((result) => {
|
isInstalled('pytubepp', '--version').then((result) => {
|
||||||
setInstalledPrograms((prevState) => ({
|
setInstalledPrograms((prevState) => ({
|
||||||
...prevState,
|
...prevState,
|
||||||
pytubepp: {
|
pytubepp: {
|
||||||
installed: result.installed,
|
installed: result.installed,
|
||||||
version: result.output ? extract_version(result.output) : null,
|
version: result.output ? extractVersion(result.output) : null,
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
check_all_programs();
|
checkAllPrograms();
|
||||||
}
|
const runPlatformSpecificChecks = async () => {
|
||||||
, []);
|
const currentPlatform = await platform();
|
||||||
|
|
||||||
|
switch (currentPlatform) {
|
||||||
|
case 'win32':
|
||||||
|
const windowsResult = await detectWindows();
|
||||||
|
if (windowsResult) {
|
||||||
|
setIsWindows(true);
|
||||||
|
setWindowsVersion(extractVersion(windowsResult));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'darwin':
|
||||||
|
const macResult = await detectMacOs();
|
||||||
|
if (macResult) {
|
||||||
|
setIsMacOs(true);
|
||||||
|
setMacOsVersion(extractVersion(macResult));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'linux':
|
||||||
|
const distroResult = await detectDistro();
|
||||||
|
if (distroResult) {
|
||||||
|
setDistroId(extractDistroId(distroResult));
|
||||||
|
setDistroBase(detectDistroBase(extractDistroId(distroResult)));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
console.log('Unsupported platform');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
runPlatformSpecificChecks().catch(console.error);
|
||||||
|
}, [])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ThemeProvider defaultTheme="dark" storageKey="vite-ui-theme">
|
<ThemeProvider defaultTheme="dark" storageKey="vite-ui-theme">
|
||||||
<div className="container">
|
<div className="container">
|
||||||
<div className="topbar flex justify-between items-center mt-5">
|
<div className={clsx("topbar flex justify-between items-center mt-5", !isWindows && "mx-3")}>
|
||||||
<h1 className="text-xl font-bold">PytubePP Helper</h1>
|
<h1 className="text-xl font-bold">PytubePP Helper</h1>
|
||||||
<Button size="sm" onClick={check_all_programs}>Refresh</Button>
|
<div>
|
||||||
|
{ isMacOs && macOsVersion && compareVersions(macOsVersion, '10.13') > 0 ?
|
||||||
|
<Button size="sm" onClick={registerMacFiles}>Register</Button>
|
||||||
|
:
|
||||||
|
null
|
||||||
|
}
|
||||||
|
<Button className="ml-3" size="sm" onClick={checkAllPrograms}>Refresh</Button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="programstats mt-5">
|
{ distroId && distroBase && distroBase === 'debian' ? /* Section for Debian */
|
||||||
|
<div className="programstats mt-5 mx-3">
|
||||||
<div className="programitem flex items-center justify-between">
|
<div className="programitem flex items-center justify-between">
|
||||||
<p><b>Python:</b> {installedPrograms.python.installed ? 'installed' : 'not installed'} {installedPrograms.python.version ? `(${installedPrograms.python.version})` : ''}</p>
|
<p><b>Python:</b> {installedPrograms.python3.installed ? 'installed' : 'not installed'} {installedPrograms.python3.version ? `(${installedPrograms.python3.version})` : ''}</p>
|
||||||
{installedPrograms.python.installed ? installedPrograms.python.version ? compareVersions(installedPrograms.python.version, '3.8') < 0 ? <TriangleAlert className="w-5 h-5 my-2 text-orange-400"/> : <CircleCheck className="w-5 h-5 my-2 text-green-400"/> : installedPrograms.winget.installed ? <Button variant="link" className="text-blue-600 px-0" onClick={async () => { await invoke('install_program', {installer: 'winget', program: 'Python.Python.3.11'})}}>install</Button> : <TriangleAlert className="w-5 h-5 my-2 text-orange-400"/> : null}
|
{installedPrograms.python3.installed ? installedPrograms.python3.version ? compareVersions(installedPrograms.python3.version, '3.8') < 0 ? <TriangleAlert className="w-5 h-5 my-2 text-orange-400"/> : <CircleCheck className="w-5 h-5 my-2 text-green-400"/> : installedPrograms.apt.installed ? <Button variant="link" className="text-blue-600 px-0" onClick={async () => { await invoke('install_program', {icommand: 'sudo apt install python3 -y'})}}>install</Button> : <TriangleAlert className="w-5 h-5 my-2 text-orange-400"/> : null}
|
||||||
</div>
|
</div>
|
||||||
<div className="programitem flex items-center justify-between">
|
<div className="programitem flex items-center justify-between">
|
||||||
<p><b>FFmpeg:</b> {installedPrograms.ffmpeg.installed ? 'installed' : 'not installed'} {installedPrograms.ffmpeg.version ? `(${installedPrograms.ffmpeg.version})` : ''}</p>
|
<p><b>FFmpeg:</b> {installedPrograms.ffmpeg.installed ? 'installed' : 'not installed'} {installedPrograms.ffmpeg.version ? `(${installedPrograms.ffmpeg.version})` : ''}</p>
|
||||||
{installedPrograms.ffmpeg.installed ? <CircleCheck className="w-5 h-5 my-2 text-green-400"/> : installedPrograms.winget.installed ? <Button variant="link" className="text-blue-600 px-0" onClick={async () => { await invoke('install_program', {installer: 'winget', program: 'ffmpeg'})}}>install</Button> : null}
|
{installedPrograms.ffmpeg.installed ? <CircleCheck className="w-5 h-5 my-2 text-green-400"/> : installedPrograms.apt.installed ? <Button variant="link" className="text-blue-600 px-0" onClick={async () => { await invoke('install_program', {icommand: 'sudo apt install ffmpeg -y'})}}>install</Button> : null}
|
||||||
</div>
|
</div>
|
||||||
<div className="programitem flex items-center justify-between">
|
<div className="programitem flex items-center justify-between">
|
||||||
<p><b>PytubePP:</b> {installedPrograms.pytubepp.installed ? 'installed' : 'not installed'} {installedPrograms.pytubepp.version ? `(${installedPrograms.pytubepp.version})` : ''}</p>
|
<p><b>PytubePP:</b> {installedPrograms.pytubepp.installed ? 'installed' : 'not installed'} {installedPrograms.pytubepp.version ? `(${installedPrograms.pytubepp.version})` : ''}</p>
|
||||||
{installedPrograms.pytubepp.installed ? <CircleCheck className="w-5 h-5 my-2 text-green-400"/> : installedPrograms.pip.installed ? <Button variant="link" className="text-blue-600 px-0" onClick={async () => { await invoke('install_program', {installer: 'pip', program: 'pytubepp'})}}>install</Button> : null}
|
{installedPrograms.pytubepp.installed ? <CircleCheck className="w-5 h-5 my-2 text-green-400"/> : installedPrograms.pip3.installed ? <Button variant="link" className="text-blue-600 px-0" onClick={async () => { await invoke('install_program', {icommand: 'pip3 install pytubepp --break-system-packages'})}}>install</Button> : null}
|
||||||
|
</div>
|
||||||
|
{(!installedPrograms.apt.installed && (!installedPrograms.python3.installed || !installedPrograms.ffmpeg.installed)) ?
|
||||||
|
<Alert className="mt-5" variant="destructive">
|
||||||
|
<CircleAlert className="h-5 w-5" />
|
||||||
|
<AlertTitle>APT Not Found</AlertTitle>
|
||||||
|
<AlertDescription>
|
||||||
|
APT is required to install necessary debian packages. Please install it manually for your distro.
|
||||||
|
</AlertDescription>
|
||||||
|
</Alert>
|
||||||
|
: null}
|
||||||
|
{(!installedPrograms.pip3.installed && !installedPrograms.pytubepp.installed) ?
|
||||||
|
<Alert className="mt-5" variant="destructive">
|
||||||
|
<CircleAlert className="h-5 w-5" />
|
||||||
|
<AlertTitle>PIP Not Found</AlertTitle>
|
||||||
|
<AlertDescription>
|
||||||
|
PIP is required to install necessary python packages. Please install it now to continue: <Button variant="link" className="text-blue-600 p-0" onClick={async () => { await invoke('install_program', {icommand: 'sudo apt install python3-pip -y'})}}>install</Button>
|
||||||
|
</AlertDescription>
|
||||||
|
</Alert>
|
||||||
|
: null}
|
||||||
|
{(installedPrograms.python3.installed && installedPrograms.ffmpeg.installed && installedPrograms.pytubepp.installed) ?
|
||||||
|
<Alert className="mt-5">
|
||||||
|
<CircleCheck className="h-5 w-5" />
|
||||||
|
<AlertTitle>Ready</AlertTitle>
|
||||||
|
<AlertDescription>
|
||||||
|
Everything looks ok! You can close this window now. Make sure it's always running in the background.
|
||||||
|
</AlertDescription>
|
||||||
|
</Alert>
|
||||||
|
: null}
|
||||||
|
</div>
|
||||||
|
: distroId && distroBase && distroBase === 'rhel' ? /* Section for RHEL */
|
||||||
|
<div className="programstats mt-5 mx-3">
|
||||||
|
<div className="programitem flex items-center justify-between">
|
||||||
|
<p><b>Python:</b> {installedPrograms.python3.installed ? 'installed' : 'not installed'} {installedPrograms.python3.version ? `(${installedPrograms.python3.version})` : ''}</p>
|
||||||
|
{installedPrograms.python3.installed ? installedPrograms.python3.version ? compareVersions(installedPrograms.python3.version, '3.8') < 0 ? <TriangleAlert className="w-5 h-5 my-2 text-orange-400"/> : <CircleCheck className="w-5 h-5 my-2 text-green-400"/> : installedPrograms.dnf.installed ? <Button variant="link" className="text-blue-600 px-0" onClick={async () => { await invoke('install_program', {icommand: 'sudo dnf install python3 -y'})}}>install</Button> : <TriangleAlert className="w-5 h-5 my-2 text-orange-400"/> : null}
|
||||||
|
</div>
|
||||||
|
<div className="programitem flex items-center justify-between">
|
||||||
|
<p><b>FFmpeg:</b> {installedPrograms.ffmpeg.installed ? 'installed' : 'not installed'} {installedPrograms.ffmpeg.version ? `(${installedPrograms.ffmpeg.version})` : ''}</p>
|
||||||
|
{installedPrograms.ffmpeg.installed ? <CircleCheck className="w-5 h-5 my-2 text-green-400"/> : installedPrograms.dnf.installed ? <Button variant="link" className="text-blue-600 px-0" onClick={async () => { await invoke('install_program', {icommand: 'sudo dnf install ffmpeg-free -y'})}}>install</Button> : null}
|
||||||
|
</div>
|
||||||
|
<div className="programitem flex items-center justify-between">
|
||||||
|
<p><b>PytubePP:</b> {installedPrograms.pytubepp.installed ? 'installed' : 'not installed'} {installedPrograms.pytubepp.version ? `(${installedPrograms.pytubepp.version})` : ''}</p>
|
||||||
|
{installedPrograms.pytubepp.installed ? <CircleCheck className="w-5 h-5 my-2 text-green-400"/> : installedPrograms.pip3.installed ? <Button variant="link" className="text-blue-600 px-0" onClick={async () => { await invoke('install_program', {icommand: 'pip3 install pytubepp'})}}>install</Button> : null}
|
||||||
|
</div>
|
||||||
|
{(!installedPrograms.dnf.installed && (!installedPrograms.python3.installed || !installedPrograms.ffmpeg.installed)) ?
|
||||||
|
<Alert className="mt-5" variant="destructive">
|
||||||
|
<CircleAlert className="h-5 w-5" />
|
||||||
|
<AlertTitle>DNF Not Found</AlertTitle>
|
||||||
|
<AlertDescription>
|
||||||
|
DNF is required to install necessary rpm packages. Please install it manually for your distro.
|
||||||
|
</AlertDescription>
|
||||||
|
</Alert>
|
||||||
|
: null}
|
||||||
|
{(!installedPrograms.pip3.installed && !installedPrograms.pytubepp.installed) ?
|
||||||
|
<Alert className="mt-5" variant="destructive">
|
||||||
|
<CircleAlert className="h-5 w-5" />
|
||||||
|
<AlertTitle>PIP Not Found</AlertTitle>
|
||||||
|
<AlertDescription>
|
||||||
|
PIP is required to install necessary python packages. Please install it now to continue: <Button variant="link" className="text-blue-600 p-0" onClick={async () => { await invoke('install_program', {icommand: 'sudo dnf install python3-pip -y'})}}>install</Button>
|
||||||
|
</AlertDescription>
|
||||||
|
</Alert>
|
||||||
|
: null}
|
||||||
|
{(installedPrograms.python3.installed && installedPrograms.ffmpeg.installed && installedPrograms.pytubepp.installed) ?
|
||||||
|
<Alert className="mt-5">
|
||||||
|
<CircleCheck className="h-5 w-5" />
|
||||||
|
<AlertTitle>Ready</AlertTitle>
|
||||||
|
<AlertDescription>
|
||||||
|
Everything looks ok! You can close this window now. Make sure it's always running in the background.
|
||||||
|
</AlertDescription>
|
||||||
|
</Alert>
|
||||||
|
: null}
|
||||||
|
</div>
|
||||||
|
: isWindows && windowsVersion && parseInt(windowsVersion) >= 17134 ? /* Section for Windows */
|
||||||
|
<div className="programstats mt-5">
|
||||||
|
<div className="programitem flex items-center justify-between">
|
||||||
|
<p><b>Python:</b> {installedPrograms.python.installed ? 'installed' : 'not installed'} {installedPrograms.python.version ? `(${installedPrograms.python.version})` : ''}</p>
|
||||||
|
{installedPrograms.python.installed ? installedPrograms.python.version ? compareVersions(installedPrograms.python.version, '3.8') < 0 ? <TriangleAlert className="w-5 h-5 my-2 text-orange-400"/> : <CircleCheck className="w-5 h-5 my-2 text-green-400"/> : installedPrograms.winget.installed ? <Button variant="link" className="text-blue-600 px-0" onClick={async () => { await invoke('install_program', {icommand: 'winget install Python.Python.3.12'})}}>install</Button> : <TriangleAlert className="w-5 h-5 my-2 text-orange-400"/> : null}
|
||||||
|
</div>
|
||||||
|
<div className="programitem flex items-center justify-between">
|
||||||
|
<p><b>FFmpeg:</b> {installedPrograms.ffmpeg.installed ? 'installed' : 'not installed'} {installedPrograms.ffmpeg.version ? `(${installedPrograms.ffmpeg.version})` : ''}</p>
|
||||||
|
{installedPrograms.ffmpeg.installed ? <CircleCheck className="w-5 h-5 my-2 text-green-400"/> : installedPrograms.winget.installed ? <Button variant="link" className="text-blue-600 px-0" onClick={async () => { await invoke('install_program', {icommand: 'winget install ffmpeg'})}}>install</Button> : null}
|
||||||
|
</div>
|
||||||
|
<div className="programitem flex items-center justify-between">
|
||||||
|
<p><b>PytubePP:</b> {installedPrograms.pytubepp.installed ? 'installed' : 'not installed'} {installedPrograms.pytubepp.version ? `(${installedPrograms.pytubepp.version})` : ''}</p>
|
||||||
|
{installedPrograms.pytubepp.installed ? <CircleCheck className="w-5 h-5 my-2 text-green-400"/> : installedPrograms.pip.installed ? <Button variant="link" className="text-blue-600 px-0" onClick={async () => { await invoke('install_program', {icommand: 'pip install pytubepp'})}}>install</Button> : null}
|
||||||
</div>
|
</div>
|
||||||
{(!installedPrograms.winget.installed && (!installedPrograms.python.installed || !installedPrograms.ffmpeg.installed)) ?
|
{(!installedPrograms.winget.installed && (!installedPrograms.python.installed || !installedPrograms.ffmpeg.installed)) ?
|
||||||
<Alert className="mt-5" variant="destructive">
|
<Alert className="mt-5" variant="destructive">
|
||||||
@@ -163,6 +360,59 @@ function App() {
|
|||||||
</Alert>
|
</Alert>
|
||||||
: null}
|
: null}
|
||||||
</div>
|
</div>
|
||||||
|
: isMacOs && macOsVersion && compareVersions(macOsVersion, '10.13') > 0 ? /* Section for macOS */
|
||||||
|
<div className="programstats mt-5 mx-3">
|
||||||
|
<div className="programitem flex items-center justify-between">
|
||||||
|
<p><b>Python:</b> {installedPrograms.python3.installed ? 'installed' : 'not installed'} {installedPrograms.python3.version ? `(${installedPrograms.python3.version})` : ''}</p>
|
||||||
|
{installedPrograms.python3.installed ? installedPrograms.python3.version ? compareVersions(installedPrograms.python3.version, '3.8') < 0 ? <TriangleAlert className="w-5 h-5 my-2 text-orange-400"/> : <CircleCheck className="w-5 h-5 my-2 text-green-400"/> : installedPrograms.brew.installed ? <Button variant="link" className="text-blue-600 px-0" onClick={async () => { await invoke('install_program', {icommand: 'brew install python3 -y'})}}>install</Button> : <TriangleAlert className="w-5 h-5 my-2 text-orange-400"/> : null}
|
||||||
|
</div>
|
||||||
|
<div className="programitem flex items-center justify-between">
|
||||||
|
<p><b>FFmpeg:</b> {installedPrograms.ffmpeg.installed ? 'installed' : 'not installed'} {installedPrograms.ffmpeg.version ? `(${installedPrograms.ffmpeg.version})` : ''}</p>
|
||||||
|
{installedPrograms.ffmpeg.installed ? <CircleCheck className="w-5 h-5 my-2 text-green-400"/> : installedPrograms.brew.installed ? <Button variant="link" className="text-blue-600 px-0" onClick={async () => { await invoke('install_program', {icommand: 'brew install ffmpeg -y'})}}>install</Button> : null}
|
||||||
|
</div>
|
||||||
|
<div className="programitem flex items-center justify-between">
|
||||||
|
<p><b>PytubePP:</b> {installedPrograms.pytubepp.installed ? 'installed' : 'not installed'} {installedPrograms.pytubepp.version ? `(${installedPrograms.pytubepp.version})` : ''}</p>
|
||||||
|
{installedPrograms.pytubepp.installed ? <CircleCheck className="w-5 h-5 my-2 text-green-400"/> : installedPrograms.pip3.installed ? <Button variant="link" className="text-blue-600 px-0" onClick={async () => { await invoke('install_program', {icommand: 'pip3 install pytubepp --break-system-packages'})}}>install</Button> : null}
|
||||||
|
</div>
|
||||||
|
{(!installedPrograms.brew.installed && (!installedPrograms.python3.installed || !installedPrograms.ffmpeg.installed)) ?
|
||||||
|
<Alert className="mt-5" variant="destructive">
|
||||||
|
<CircleAlert className="h-5 w-5" />
|
||||||
|
<AlertTitle>Homebrew Not Found</AlertTitle>
|
||||||
|
<AlertDescription>
|
||||||
|
Homebrew is required to install necessary unix packages. Please install it manually for your mac.
|
||||||
|
</AlertDescription>
|
||||||
|
</Alert>
|
||||||
|
: null}
|
||||||
|
{(!installedPrograms.pip3.installed && !installedPrograms.pytubepp.installed) ?
|
||||||
|
<Alert className="mt-5" variant="destructive">
|
||||||
|
<CircleAlert className="h-5 w-5" />
|
||||||
|
<AlertTitle>PIP Not Found</AlertTitle>
|
||||||
|
<AlertDescription>
|
||||||
|
PIP is required to install necessary python packages. Please install it now to continue: <Button variant="link" className="text-blue-600 p-0" onClick={async () => { await invoke('install_program', {icommand: 'brew install python3-pip -y'})}}>install</Button>
|
||||||
|
</AlertDescription>
|
||||||
|
</Alert>
|
||||||
|
: null}
|
||||||
|
{(installedPrograms.python3.installed && installedPrograms.ffmpeg.installed && installedPrograms.pytubepp.installed) ?
|
||||||
|
<Alert className="mt-5">
|
||||||
|
<CircleCheck className="h-5 w-5" />
|
||||||
|
<AlertTitle>Ready</AlertTitle>
|
||||||
|
<AlertDescription>
|
||||||
|
Everything looks ok! You can close this window now. Make sure it's always running in the background.
|
||||||
|
</AlertDescription>
|
||||||
|
</Alert>
|
||||||
|
: null}
|
||||||
|
</div>
|
||||||
|
:
|
||||||
|
<div className="programstats mt-5 mx-3">
|
||||||
|
<Alert className="mt-5" variant="destructive">
|
||||||
|
<CircleAlert className="h-5 w-5" />
|
||||||
|
<AlertTitle>Unsupported OS</AlertTitle>
|
||||||
|
<AlertDescription>
|
||||||
|
Sorry, your os/distro is currently not supported. If you think this is just a mistake or you want to request us to add support for your os/distro you can create a github issue <a className="underline" href="https://github.com/neosubhamoy/pytubepp-helper/issues" target="_blank">here</a>.
|
||||||
|
</AlertDescription>
|
||||||
|
</Alert>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
</div>
|
</div>
|
||||||
</ThemeProvider>
|
</ThemeProvider>
|
||||||
);
|
);
|
||||||
|
|||||||
159
src/lib/utils.ts
@@ -1,46 +1,15 @@
|
|||||||
import { type ClassValue, clsx } from "clsx"
|
import { type ClassValue, clsx } from "clsx"
|
||||||
import { twMerge } from "tailwind-merge"
|
import { twMerge } from "tailwind-merge"
|
||||||
import { Command } from '@tauri-apps/api/shell';
|
import { Command } from '@tauri-apps/api/shell';
|
||||||
import { Stream } from "@/types";
|
|
||||||
import { invoke } from "@tauri-apps/api";
|
import { invoke } from "@tauri-apps/api";
|
||||||
|
import { fs } from '@tauri-apps/api';
|
||||||
export function extract_xml(input: string): string[] {
|
import { join, resourceDir, homeDir } from '@tauri-apps/api/path';
|
||||||
const regex = /<Stream: [^>]+>/g;
|
|
||||||
const matches = input.match(regex);
|
|
||||||
return matches ? matches : [];
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function parseAttributes(attributesString: string): Partial<Stream> {
|
|
||||||
const attributes: Partial<Stream> = {};
|
|
||||||
const regex = /(\w+)="([^"]*)"/g;
|
|
||||||
let match;
|
|
||||||
|
|
||||||
while ((match = regex.exec(attributesString)) !== null) {
|
|
||||||
const key = match[1];
|
|
||||||
const value = match[2];
|
|
||||||
if (['itag', 'mime_type', 'res', 'fps', 'vcodec'].includes(key)) {
|
|
||||||
attributes[key as keyof Partial<Stream>] = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return attributes;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function convert_xml_to_json(xmlStrings: string[]): Stream[] {
|
|
||||||
return xmlStrings
|
|
||||||
.map(xmlString => {
|
|
||||||
const attributesString = xmlString.replace('<Stream: ', '').replace('>', '');
|
|
||||||
return parseAttributes(attributesString);
|
|
||||||
})
|
|
||||||
.filter(stream => stream.res !== undefined) as Stream[];
|
|
||||||
}
|
|
||||||
|
|
||||||
export function cn(...inputs: ClassValue[]) {
|
export function cn(...inputs: ClassValue[]) {
|
||||||
return twMerge(clsx(inputs))
|
return twMerge(clsx(inputs))
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function is_installed(program: string, arg: string): Promise<{ installed: boolean, output: string | null }> {
|
export async function isInstalled(program: string, arg: string): Promise<{ installed: boolean, output: string | null }> {
|
||||||
try{
|
try{
|
||||||
const output = await new Command('is-' + program + '-installed', [arg]).execute();
|
const output = await new Command('is-' + program + '-installed', [arg]).execute();
|
||||||
if (output.code === 0) {
|
if (output.code === 0) {
|
||||||
@@ -54,15 +23,81 @@ export async function is_installed(program: string, arg: string): Promise<{ inst
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function extract_version(output: string): string | null {
|
export async function detectWindows(): Promise<string | null> {
|
||||||
const versionPatterns = [
|
try{
|
||||||
/ffmpeg version (\d+\.\d+)/, // Pattern for ffmpeg
|
const output = await new Command('detect-windows', []).execute();
|
||||||
/Python (\d+\.\d+\.\d+)/, // Pattern for Python
|
if (output.code === 0) {
|
||||||
/pytubefix (\d+\.\d+\.\d+)/, // Pattern for pytubefix
|
return output.stdout;
|
||||||
/pytubepp (\d+\.\d+\.\d+)/, // Pattern for pytubepp
|
} else {
|
||||||
/v(\d+\.\d+\.\d+)/, // Pattern for winget
|
return output.stdout;
|
||||||
/pip (\d+\.\d+)/, // Pattern for pip
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function detectMacOs(): Promise<string | null> {
|
||||||
|
try{
|
||||||
|
const output = await new Command('detect-macos', []).execute();
|
||||||
|
if (output.code === 0) {
|
||||||
|
return output.stdout;
|
||||||
|
} else {
|
||||||
|
return output.stdout;
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function detectDistro(): Promise<string | null> {
|
||||||
|
try{
|
||||||
|
const output = await new Command('detect-distro', ['^ID=', '/etc/os-release']).execute();
|
||||||
|
if (output.code === 0) {
|
||||||
|
return output.stdout;
|
||||||
|
} else {
|
||||||
|
return output.stdout;
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function detectDistroBase(distro: string | null): string | null{
|
||||||
|
if(distro) {
|
||||||
|
if(['debian', 'ubuntu', 'pop', 'kali'].includes(distro)) {
|
||||||
|
return 'debian';
|
||||||
|
} else if (['rhel', 'fedora', 'centos', 'rocky'].includes(distro)) {
|
||||||
|
return 'rhel';
|
||||||
|
} else {
|
||||||
|
return 'other';
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function extractDistroId(input: string): string | null {
|
||||||
|
const regex = /ID=([a-zA-Z]+)/;
|
||||||
|
const match = input.match(regex);
|
||||||
|
return match ? match[1] : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function extractVersion(output: string): string | null {
|
||||||
|
const versionPatterns = [
|
||||||
|
/ffmpeg version (\d+\.\d+)/, // Pattern for ffmpeg
|
||||||
|
/Python (\d+\.\d+\.\d+)/, // Pattern for Python
|
||||||
|
/pytubefix (\d+\.\d+\.\d+)/, // Pattern for pytubefix
|
||||||
|
/pytubepp (\d+\.\d+\.\d+)/, // Pattern for pytubepp
|
||||||
|
/v(\d+\.\d+\.\d+)/, // Pattern for winget
|
||||||
|
/pip (\d+\.\d+)/, // Pattern for pip
|
||||||
|
/OS Version:.*Build (\d+)/, // Pattern for Windows build
|
||||||
|
/apt (\d+\.\d+\.\d+)/, // Pattern for apt
|
||||||
|
/(\d+\.\d+\.\d+)/, // Pattern for dnf
|
||||||
|
/ProductVersion:\s+(\d+\.\d+(\.\d+)?)/, // Pattern for macOS version
|
||||||
|
/Homebrew (\d+\.\d+\.\d+)/, // Pattern for Homebrew
|
||||||
];
|
];
|
||||||
for (const pattern of versionPatterns) {
|
for (const pattern of versionPatterns) {
|
||||||
const match = output.match(pattern);
|
const match = output.match(pattern);
|
||||||
@@ -76,13 +111,12 @@ export function extract_version(output: string): string | null {
|
|||||||
export async function sendStreamInfo(url: string) {
|
export async function sendStreamInfo(url: string) {
|
||||||
const fetchData = async () => {
|
const fetchData = async () => {
|
||||||
try {
|
try {
|
||||||
const output = await new Command('fetch-video-info', [url, '--list']).execute();
|
const output = await new Command('fetch-video-info', [url, '--raw-info']).execute();
|
||||||
if (output.code === 0) {
|
if (output.code === 0) {
|
||||||
console.log(output.stdout);
|
console.log(output.stdout);
|
||||||
const sendStreamData = async () => {
|
const sendStreamData = async () => {
|
||||||
try {
|
try {
|
||||||
const streamsstr = JSON.stringify(convert_xml_to_json(extract_xml(output.stdout)))
|
await invoke('receive_frontend_response', { response: output.stdout });
|
||||||
await invoke('receive_frontend_response', { response: streamsstr });
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
}
|
}
|
||||||
@@ -109,4 +143,37 @@ export function compareVersions (v1: string, v2: string) {
|
|||||||
if (part1 < part2) return -1;
|
if (part1 < part2) return -1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export async function registerMacFiles() {
|
||||||
|
try {
|
||||||
|
const filesToCopy = [
|
||||||
|
{ source: 'pytubepp-helper-autostart.plist', destination: 'Library/LaunchAgents/com.neosubhamoy.pytubepp.helper.plist', dir: 'Library/LaunchAgents/' },
|
||||||
|
{ source: 'pytubepp-helper-msghost.json', destination: 'Library/Application Support/Google/Chrome/NativeMessagingHosts/com.neosubhamoy.pytubepp.helper.json', dir: 'Library/Application Support/Google/Chrome/NativeMessagingHosts/' },
|
||||||
|
{ source: 'pytubepp-helper-msghost.json', destination: 'Library/Application Support/Chromium/NativeMessagingHosts/com.neosubhamoy.pytubepp.helper.json', dir: 'Library/Application Support/Chromium/NativeMessagingHosts/' },
|
||||||
|
{ source: 'pytubepp-helper-msghost-moz.json', destination: 'Library/Application Support/Mozilla/NativeMessagingHosts/com.neosubhamoy.pytubepp.helper.json', dir: 'Library/Application Support/Mozilla/NativeMessagingHosts/' },
|
||||||
|
];
|
||||||
|
|
||||||
|
const resourceDirPath = await resourceDir();
|
||||||
|
const homeDirPath = await homeDir();
|
||||||
|
|
||||||
|
for (const file of filesToCopy) {
|
||||||
|
const sourcePath = await join(resourceDirPath, file.source);
|
||||||
|
const destinationDir = await join(homeDirPath, file.dir);
|
||||||
|
const destinationPath = await join(homeDirPath, file.destination);
|
||||||
|
|
||||||
|
const dirExists = await fs.exists(destinationDir);
|
||||||
|
if (dirExists) {
|
||||||
|
await fs.copyFile(sourcePath, destinationPath);
|
||||||
|
console.log(`File ${file.source} copied successfully to ${destinationPath}`);
|
||||||
|
} else {
|
||||||
|
await fs.createDir(destinationDir, { recursive: true })
|
||||||
|
console.log(`Created dir ${destinationDir}`);
|
||||||
|
await fs.copyFile(sourcePath, destinationPath);
|
||||||
|
console.log(`File ${file.source} copied successfully to ${destinationPath}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error copying files:', error);
|
||||||
|
}
|
||||||
|
}
|
||||||
20
src/types.ts
@@ -3,6 +3,18 @@ export interface InstalledPrograms {
|
|||||||
installed: boolean;
|
installed: boolean;
|
||||||
version: string | null;
|
version: string | null;
|
||||||
};
|
};
|
||||||
|
apt: {
|
||||||
|
installed: boolean;
|
||||||
|
version: string | null;
|
||||||
|
};
|
||||||
|
dnf: {
|
||||||
|
installed: boolean;
|
||||||
|
version: string | null;
|
||||||
|
};
|
||||||
|
brew: {
|
||||||
|
installed: boolean;
|
||||||
|
version: string | null;
|
||||||
|
};
|
||||||
python: {
|
python: {
|
||||||
installed: boolean;
|
installed: boolean;
|
||||||
version: string | null;
|
version: string | null;
|
||||||
@@ -11,6 +23,14 @@ export interface InstalledPrograms {
|
|||||||
installed: boolean;
|
installed: boolean;
|
||||||
version: string | null;
|
version: string | null;
|
||||||
};
|
};
|
||||||
|
python3: {
|
||||||
|
installed: boolean;
|
||||||
|
version: string | null;
|
||||||
|
};
|
||||||
|
pip3: {
|
||||||
|
installed: boolean;
|
||||||
|
version: string | null;
|
||||||
|
};
|
||||||
ffmpeg: {
|
ffmpeg: {
|
||||||
installed: boolean;
|
installed: boolean;
|
||||||
version: string | null;
|
version: string | null;
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ export default defineConfig(async () => ({
|
|||||||
clearScreen: false,
|
clearScreen: false,
|
||||||
// 2. tauri expects a fixed port, fail if that port is not available
|
// 2. tauri expects a fixed port, fail if that port is not available
|
||||||
server: {
|
server: {
|
||||||
port: 1420,
|
port: 1422,
|
||||||
strictPort: true,
|
strictPort: true,
|
||||||
watch: {
|
watch: {
|
||||||
// 3. tell vite to ignore watching `src-tauri`
|
// 3. tell vite to ignore watching `src-tauri`
|
||||||
|
|||||||