1
1
mirror of https://github.com/neosubhamoy/pytubepp-helper.git synced 2026-02-04 11:22:22 +05:30

(feat): added support for macOS

This commit is contained in:
2024-12-16 22:37:00 +05:30
Verified
parent 1dc8ef659f
commit c235db28c1
11 changed files with 416 additions and 261 deletions

View File

@@ -0,0 +1,12 @@
<?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>Program</key>
<string>/Applications/pytubepp-helper.app/Contents/MacOS/pytubepp-helper</string>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>

View File

@@ -28,9 +28,24 @@ fn connect_with_retry(url: &str, max_attempts: u32) -> Result<websocket::sync::C
}
fn main() -> Result<(), Box<dyn std::error::Error>> {
#[cfg(target_os = "windows")]
{
let _ = Command::new("pytubepp-helper.exe").spawn();
}
#[cfg(target_os = "linux")]
{
let _ = Command::new("pytubepp-helper").spawn();
}
#[cfg(target_os = "macos")]
{
let _ = Command::new("/Applications/pytubepp-helper.app/Contents/MacOS/pytubepp-helper").spawn();
}
// Launch the main application
let _ = Command::new("pytubepp-helper")
.spawn();
// let _ = Command::new("pytubepp-helper")
// .spawn();
// Connect with the Tauri app
let websocket_url = "ws://localhost:3030";

View File

@@ -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/"]
}

View File

@@ -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"]
}

View File

@@ -67,12 +67,19 @@ fn fetch_video_info(url: String) {
#[cfg(target_os = "macos")]
{
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")
.arg("-e")
.arg(format!(
"tell app \"Terminal\" to activate do script \"{}\"",
command
))
.arg(applescript)
.spawn()
.unwrap();
}
@@ -101,12 +108,19 @@ fn install_program(icommand: String) {
#[cfg(target_os = "macos")]
{
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")
.arg("-e")
.arg(format!(
"tell app \"Terminal\" to activate do script \"{}\"",
command
))
.arg(applescript)
.spawn()
.unwrap();
}
@@ -135,12 +149,19 @@ fn download_stream(url: String, stream: String) {
#[cfg(target_os = "macos")]
{
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")
.arg("-e")
.arg(format!(
"tell app \"Terminal\" to activate do script \"{}\"",
command
))
.arg(applescript)
.spawn()
.unwrap();
}

View File

@@ -1,7 +1,7 @@
{
"build": {
"beforeDevCommand": "npm run dev && cargo build --manifest-path=./src-tauri/msghost/Cargo.toml && cargo build --manifest-path=./src-tauri/autostart/Cargo.toml",
"beforeBuildCommand": "npm run build && cargo build --release --manifest-path=./src-tauri/msghost/Cargo.toml && cargo build --release --manifest-path=./src-tauri/autostart/Cargo.toml",
"beforeDevCommand": "cargo build --manifest-path=./src-tauri/msghost/Cargo.toml && cargo build --manifest-path=./src-tauri/autostart/Cargo.toml && 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 copyMacFiles.js && npm run build",
"devPath": "http://localhost:1422",
"distDir": "../dist"
},
@@ -89,6 +89,26 @@
}
]
},
"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",
"$RESOURCE/pytubepp-helper-autostart.plist"
]
},
"path": {
"all": true
},
"window": {
"all": false,
"close": true,
@@ -110,7 +130,7 @@
{
"title": "PytubePP Helper",
"width": 500,
"height": 320
"height": 335
}
],
"security": {
@@ -131,7 +151,14 @@
"minimumSystemVersion": "10.13",
"license": "../LICENSE",
"providerShortName": "neosubhamoy"
}
},
"resources": [
"pytubepp-helper-msghost.json",
"pytubepp-helper-msghost-moz.json",
"pytubepp-helper-msghost",
"pytubepp-helper-autostart",
"pytubepp-helper-autostart.plist"
]
},
"systemTray": {
"iconPath": "icons/32x32.png",